mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 00:39:50 +03:00
Merge branch 'v2_web' of https://github.com/proddy/EMS-ESP into web
This commit is contained in:
@@ -73,6 +73,9 @@ void Solar::show_values(uuid::console::Shell & shell) {
|
||||
shell.printfln(F(" Pump working time: %d days %d hours %d minutes"), pumpWorkMin_ / 1440, (pumpWorkMin_ % 1440) / 60, pumpWorkMin_ % 60);
|
||||
}
|
||||
|
||||
print_value(shell, 2, F("Tank Heated"), tankHeated_, nullptr, EMS_VALUE_BOOL);
|
||||
print_value(shell, 2, F("Collector"), collectorOnOff_, nullptr, EMS_VALUE_BOOL);
|
||||
|
||||
print_value(shell, 2, F("Energy last hour"), energyLastHour_, F_(wh), 10);
|
||||
print_value(shell, 2, F("Energy today"), energyToday_, F_(wh));
|
||||
print_value(shell, 2, F("Energy total"), energyTotal_, F_(kwh), 10);
|
||||
@@ -87,30 +90,47 @@ void Solar::publish_values() {
|
||||
if (Helpers::hasValue(collectorTemp_)) {
|
||||
doc["collectortemp"] = (float)collectorTemp_ / 10;
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(bottomTemp_)) {
|
||||
doc["bottomtemp"] = (float)bottomTemp_ / 10;
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(bottomTemp2_)) {
|
||||
doc["bottomtemp2"] = (float)bottomTemp2_ / 10;
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(pumpModulation_)) {
|
||||
doc["pumpmodulation"] = pumpModulation_;
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(pump_, true)) {
|
||||
doc["pump"] = Helpers::render_value(s, pump_, EMS_VALUE_BOOL);
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(valveStatus_, true)) {
|
||||
doc["valvestatus"] = Helpers::render_value(s, valveStatus_, EMS_VALUE_BOOL);
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(pumpWorkMin_)) {
|
||||
doc["pumpWorkMin"] = (float)pumpWorkMin_;
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(tankHeated_, true)) {
|
||||
doc["tankHeated"] = Helpers::render_value(s, tankHeated_, EMS_VALUE_BOOL);
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(collectorOnOff_, true)) {
|
||||
doc["collectorOnOff"] = Helpers::render_value(s, collectorOnOff_, EMS_VALUE_BOOL);
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(energyLastHour_)) {
|
||||
doc["energylasthour"] = (float)energyLastHour_ / 10;
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(energyToday_)) {
|
||||
doc["energytoday"] = energyToday_;
|
||||
}
|
||||
|
||||
if (Helpers::hasValue(energyTotal_)) {
|
||||
doc["energytotal"] = (float)energyTotal_ / 10;
|
||||
}
|
||||
@@ -186,6 +206,9 @@ void Solar::process_SM100Status(std::shared_ptr<const Telegram> telegram) {
|
||||
if (pumpmod == 0 && pumpModulation_ == 100) { // mask out boosts
|
||||
pumpModulation_ = 15; // set to minimum
|
||||
}
|
||||
|
||||
telegram->read_bitvalue(tankHeated_, 3, 1); // issue #422
|
||||
telegram->read_bitvalue(collectorOnOff_, 3, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -56,6 +56,8 @@ class Solar : public EMSdevice {
|
||||
uint32_t energyToday_ = EMS_VALUE_ULONG_NOTSET;
|
||||
uint32_t energyTotal_ = EMS_VALUE_ULONG_NOTSET;
|
||||
uint32_t pumpWorkMin_ = EMS_VALUE_ULONG_NOTSET; // Total solar pump operating time
|
||||
uint8_t tankHeated_ = EMS_VALUE_BOOL_NOTSET;
|
||||
uint8_t collectorOnOff_ = EMS_VALUE_BOOL_NOTSET;
|
||||
|
||||
uint8_t availabilityFlag_ = EMS_VALUE_BOOL_NOTSET;
|
||||
uint8_t configFlag_ = EMS_VALUE_BOOL_NOTSET;
|
||||
|
||||
@@ -107,8 +107,10 @@ void EMSESP::reset_tx(uint8_t const tx_mode) {
|
||||
txservice_.telegram_read_count(0);
|
||||
txservice_.telegram_write_count(0);
|
||||
txservice_.telegram_fail_count(0);
|
||||
EMSuart::stop();
|
||||
EMSuart::start(tx_mode); // reset the UART
|
||||
if (tx_mode) {
|
||||
EMSuart::stop();
|
||||
EMSuart::start(tx_mode); // reset the UART
|
||||
}
|
||||
}
|
||||
|
||||
// return status of bus: connected, connected but Tx is broken, disconnected
|
||||
@@ -117,8 +119,21 @@ uint8_t EMSESP::bus_status() {
|
||||
return BUS_STATUS_OFFLINE;
|
||||
}
|
||||
|
||||
// check if we have Tx issues
|
||||
if (txservice_.telegram_read_count() < 2) {
|
||||
// check if we have Tx issues.
|
||||
uint32_t total_sent = txservice_.telegram_read_count() + txservice_.telegram_write_count();
|
||||
|
||||
// nothing sent successfully, also no errors - must be ok
|
||||
if ((total_sent == 0) && (txservice_.telegram_fail_count() == 0)) {
|
||||
return BUS_STATUS_CONNECTED;
|
||||
}
|
||||
|
||||
// nothing sent successfully, but have Tx errors
|
||||
if ((total_sent == 0) && (txservice_.telegram_fail_count() != 0)) {
|
||||
return BUS_STATUS_TX_ERRORS;
|
||||
}
|
||||
|
||||
// Tx Failure rate > 5%
|
||||
if (((txservice_.telegram_fail_count() * 100) / total_sent) >= 5) {
|
||||
return BUS_STATUS_TX_ERRORS;
|
||||
}
|
||||
|
||||
|
||||
@@ -231,7 +231,9 @@ void System::start() {
|
||||
Mqtt::subscribe("cmd", std::bind(&System::mqtt_commands, this, _1));
|
||||
|
||||
#ifndef EMSESP_FORCE_SERIAL
|
||||
EMSuart::start(tx_mode_); // start UART
|
||||
if (tx_mode_) {
|
||||
EMSuart::start(tx_mode_); // start UART, if tx_mode is not 0
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user