Skip to content

Commit

Permalink
fix flodding bus with forceHeatingOff messages, dev3b
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Oct 20, 2023
1 parent 3fe9296 commit 161f782
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
14 changes: 7 additions & 7 deletions lib/framework/NetworkSettingsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,16 @@ void NetworkSettingsService::manageSTA() {
} else {
WiFi.begin(_state.ssid.c_str(), _state.password.c_str());
}

// set power after wifi is startet, fixed value for C3_V1
if (WiFi.isConnected()) {
#ifdef BOARD_C3_MINI_V1
// v1 needs this value, see https://github.com/emsesp/EMS-ESP32/pull/620#discussion_r993173979
WiFi.setTxPower(WIFI_POWER_8_5dBm); // https://www.wemos.cc/en/latest/c3/c3_mini_1_0_0.html#about-wifi
// v1 needs this value, see https://github.com/emsesp/EMS-ESP32/pull/620#discussion_r993173979
WiFi.setTxPower(WIFI_POWER_8_5dBm); // https://www.wemos.cc/en/latest/c3/c3_mini_1_0_0.html#about-wifi
#else
// esp_wifi_set_max_tx_power(_state.tx_power * 4);
WiFi.setTxPower((wifi_power_t)(_state.tx_power * 4));
// esp_wifi_set_max_tx_power(_state.tx_power * 4);
WiFi.setTxPower((wifi_power_t)(_state.tx_power * 4));
#endif
}
} else { // not connected but STA-mode active => disconnect
reconfigureWiFiConnection();
}
Expand All @@ -101,8 +102,7 @@ void NetworkSettingsService::WiFiEvent(WiFiEvent_t event) {
_stopping = false;
}
}
if (!_stopping
&& (event == ARDUINO_EVENT_WIFI_STA_LOST_IP || event == ARDUINO_EVENT_WIFI_STA_DISCONNECTED || event == ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE)) {
if (!_stopping && (event == ARDUINO_EVENT_WIFI_STA_LOST_IP || event == ARDUINO_EVENT_WIFI_STA_DISCONNECTED)) {
reconfigureWiFiConnection();
}
}
25 changes: 11 additions & 14 deletions src/devices/boiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,15 +970,22 @@ void Boiler::check_active() {
tapwaterActive_ = val;
char s[12];
Mqtt::queue_publish(F_(tapwater_active), Helpers::render_boolean(s, b));
if (flowsensor) {
EMSESP::tap_water_active(b); // let EMS-ESP know, used in the Shower class
}
// if (flowsensor) {
EMSESP::tap_water_active(b); // let EMS-ESP know, used in the Shower class
// }
}

// check forceheatingoff option
if (!Helpers::hasValue(forceHeatingOff_, EMS_VALUE_BOOL)) {
EMSESP::webSettingsService.read([&](WebSettings & settings) { forceHeatingOff_ = (settings.boiler_heatingoff || selFlowTemp_ == 0) ? 1 : 0; });
has_update(&forceHeatingOff_);
}
static uint32_t lastSendHeatingOff = 0;
if (forceHeatingOff_ == EMS_VALUE_BOOL_ON && (uuid::get_uptime_sec() - lastSendHeatingOff) >= 60) {
lastSendHeatingOff = uuid::get_uptime_sec();
uint8_t data[] = {0, 0, 0, 0};
write_command(EMS_TYPE_UBASetPoints, 0, data, sizeof(data), 0);
}

// calculate energy for boiler 0x08 from stored modulation an time in units of 0.01 Wh
if (model() != EMS_DEVICE_FLAG_HEATPUMP) {
Expand Down Expand Up @@ -1246,11 +1253,6 @@ void Boiler::process_UBAMonitorSlow(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, burn2WorkMin_, 16, 3); // force to 3 bytes
has_update(telegram, heatWorkMin_, 19, 3); // force to 3 bytes
has_update(telegram, heatStarts_, 22, 3); // force to 3 bytes

if (forceHeatingOff_ == EMS_VALUE_BOOL_ON && telegram->dest == 0) {
uint8_t data[] = {0, 0, 0, 0};
write_command(EMS_TYPE_UBASetPoints, 0, data, sizeof(data), 0);
}
}

/*
Expand Down Expand Up @@ -1281,11 +1283,6 @@ void Boiler::process_UBAMonitorSlowPlus(std::shared_ptr<const Telegram> telegram
has_update(telegram, heatWorkMin_, 19, 3); // force to 3 bytes
has_update(telegram, heatStarts_, 22, 3); // force to 3 bytes
has_update(telegram, heatingPumpMod_, 25);

if (forceHeatingOff_ == EMS_VALUE_BOOL_ON && telegram->dest == 0 && telegram->offset == 0 && telegram->message_length > 10) {
uint8_t data[] = {0, 0, 0, 0};
write_command(EMS_TYPE_UBASetPoints, 0, data, sizeof(data), 0);
}
}

/*
Expand Down Expand Up @@ -1537,7 +1534,7 @@ void Boiler::process_UBASetPoints(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, wwSetPumpPower_, 2); // ww pump speed/power?

// overwrite other settings on receive?
if (forceHeatingOff_ == EMS_VALUE_BOOL_ON && telegram->dest == 0x08) {
if (forceHeatingOff_ == EMS_VALUE_BOOL_ON && telegram->dest == 0x08 && (setFlowTemp_ + setBurnPow_ + wwSetPumpPower_) != 0) {
uint8_t data[] = {0, 0, 0, 0};
write_command(EMS_TYPE_UBASetPoints, 0, data, sizeof(data), 0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.6.3-dev.3a"
#define EMSESP_APP_VERSION "3.6.3-dev.3b"

0 comments on commit 161f782

Please sign in to comment.