From c9148b574f0441c4d3aef96082235a08fa2e681c Mon Sep 17 00:00:00 2001 From: proddy Date: Fri, 14 Jun 2024 11:40:32 +0200 Subject: [PATCH 1/6] default EMSESP_DEFAULT_ENTITY_FORMAT is 1 (SINGLE_SHORT) --- src/default_settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/default_settings.h b/src/default_settings.h index 956909b62..81514e540 100644 --- a/src/default_settings.h +++ b/src/default_settings.h @@ -218,7 +218,7 @@ #endif #ifndef EMSESP_DEFAULT_ENTITY_FORMAT -#define EMSESP_DEFAULT_ENTITY_FORMAT 3 // in MQTT discovery, single instance, shortname, v3.6 +#define EMSESP_DEFAULT_ENTITY_FORMAT 1 // in MQTT discovery, single instance, shortname (EntityFormat::SINGLE_SHORT) #endif // matches Web UI settings From 9989a03993bba232967ea1ae363c295d770c8776 Mon Sep 17 00:00:00 2001 From: proddy Date: Fri, 14 Jun 2024 11:40:49 +0200 Subject: [PATCH 2/6] remove base() as it's unused --- src/mqtt.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/mqtt.h b/src/mqtt.h index 800d69779..054a39aef 100644 --- a/src/mqtt.h +++ b/src/mqtt.h @@ -138,10 +138,6 @@ class Mqtt { return discovery_prefix_ + "/"; } - static void base(const char * base) { - mqtt_base_ = base; - } - static uint32_t publish_count() { return mqtt_message_id_; } From 3d335963b9cddcf7d126734da6b113ac3d76ef37 Mon Sep 17 00:00:00 2001 From: proddy Date: Fri, 14 Jun 2024 11:47:04 +0200 Subject: [PATCH 3/6] color restart button --- interface/src/framework/system/SystemStatus.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/framework/system/SystemStatus.tsx b/interface/src/framework/system/SystemStatus.tsx index 73f5db67d..160d96d2f 100644 --- a/interface/src/framework/system/SystemStatus.tsx +++ b/interface/src/framework/system/SystemStatus.tsx @@ -289,7 +289,7 @@ const SystemStatus: FC = () => { variant="outlined" onClick={restart} disabled={processing} - color="primary" + color="error" > {LL.RESTART()} @@ -298,7 +298,7 @@ const SystemStatus: FC = () => { variant="outlined" onClick={partition} disabled={processing} - color="primary" + color="warning" > EMS-ESP Loader From 13eee199817fb0e26ad5b66425aea1fec2bf12ee Mon Sep 17 00:00:00 2001 From: proddy Date: Fri, 14 Jun 2024 11:47:26 +0200 Subject: [PATCH 4/6] update packages --- interface/package.json | 4 ++-- interface/yarn.lock | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/interface/package.json b/interface/package.json index fe5912205..703c0443e 100644 --- a/interface/package.json +++ b/interface/package.json @@ -34,7 +34,7 @@ "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", "@types/react-router-dom": "^5.3.3", - "alova": "^2.21.2", + "alova": "^2.21.3", "async-validator": "^4.2.5", "history": "^5.3.0", "jwt-decode": "^4.0.0", @@ -64,7 +64,7 @@ "rollup-plugin-visualizer": "^5.12.0", "terser": "^5.31.1", "typescript-eslint": "^7.13.0", - "vite": "^5.3.0", + "vite": "^5.3.1", "vite-plugin-imagemin": "^0.6.1", "vite-tsconfig-paths": "^4.3.2" }, diff --git a/interface/yarn.lock b/interface/yarn.lock index f056b0276..8e3b3327c 100644 --- a/interface/yarn.lock +++ b/interface/yarn.lock @@ -2000,7 +2000,7 @@ __metadata: "@types/react": "npm:^18.3.3" "@types/react-dom": "npm:^18.3.0" "@types/react-router-dom": "npm:^5.3.3" - alova: "npm:^2.21.2" + alova: "npm:^2.21.3" async-validator: "npm:^4.2.5" concurrently: "npm:^8.2.2" eslint: "npm:^9.4.0" @@ -2022,7 +2022,7 @@ __metadata: typesafe-i18n: "npm:^5.26.2" typescript: "npm:^5.4.5" typescript-eslint: "npm:^7.13.0" - vite: "npm:^5.3.0" + vite: "npm:^5.3.1" vite-plugin-imagemin: "npm:^0.6.1" vite-tsconfig-paths: "npm:^4.3.2" languageName: unknown @@ -2084,10 +2084,10 @@ __metadata: languageName: node linkType: hard -"alova@npm:^2.21.2": - version: 2.21.2 - resolution: "alova@npm:2.21.2" - checksum: 10c0/5e0e7e8cc6ac1972798f600c26b2adbc3bef0985d07e545898457cbc3f6b925d4ef0bec4a67c75676e8725da3a3c961d35706cd2553540c87ff891391ca8d25f +"alova@npm:^2.21.3": + version: 2.21.3 + resolution: "alova@npm:2.21.3" + checksum: 10c0/ce03ced33660f15ec667e24df5c7fbeff223dace95a7d50d657dd038f21dc865d8a9290914edbc5a980c8573daa4354ac714f97ae58650ea5b8fefd8fc2d313c languageName: node linkType: hard @@ -7340,9 +7340,9 @@ __metadata: languageName: node linkType: hard -"vite@npm:^5.3.0": - version: 5.3.0 - resolution: "vite@npm:5.3.0" +"vite@npm:^5.3.1": + version: 5.3.1 + resolution: "vite@npm:5.3.1" dependencies: esbuild: "npm:^0.21.3" fsevents: "npm:~2.3.3" @@ -7376,7 +7376,7 @@ __metadata: optional: true bin: vite: bin/vite.js - checksum: 10c0/d07e1a2ce713d3f73cb83f6289c9ff320da5953f37c35edb8c1388d610e8ca1c98edd642d5c3f163f8771dae294d3d430356a09285e344f0de9fa4b058c541f0 + checksum: 10c0/9317262c02ea2dc324dfdbc20c3c450cd89cc9a16399a41a4bf820a3a1f31cf400878c015135e355ee034853cc2399b5499899d5b1bc462d57642d71083e74b6 languageName: node linkType: hard From ff49caaada0a8aa5a3a3338dd70cdfb45aa30bb4 Mon Sep 17 00:00:00 2001 From: proddy Date: Fri, 14 Jun 2024 11:48:12 +0200 Subject: [PATCH 5/6] make copy of state in creating HA's avty_json as string would go out of scope --- src/mqtt.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/mqtt.cpp b/src/mqtt.cpp index c97fa1894..211f8d0b2 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -841,18 +841,23 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev // build unique identifier also used as object_id which also becomes the Entity ID in HA char uniq_id[80]; + // list of boiler entities that need conversion for 3.6 compatibility, add ww suffix + // used when entity_format is SINGLE_OLD or MULTI_OLD to keep with 3.6.5 + // see #1714 - https://github.com/emsesp/EMS-ESP32/issues/1714 const char * dhw_old[] = {FL_(nrgWw)[0], FL_(upTimeCompWw)[0], FL_(nrgConsCompWw)[0], FL_(auxElecHeatNrgConsWw)[0], FL_(nrgSuppWw)[0], FL_(wwAltOpPrioWw)[0], FL_(hpCircPumpWw)[0]}; uint8_t num_dhw_old = sizeof(dhw_old) / sizeof(dhw_old[0]); + + // create the uniq_d based on the entity format if (Mqtt::entity_format() == entityFormat::MULTI_SHORT) { - // prefix base name to each uniq_id and use the shortname + // base name + shortname snprintf(uniq_id, sizeof(uniq_id), "%s_%s_%s", mqtt_basename_.c_str(), device_name, entity_with_tag); } else if (Mqtt::entity_format() == entityFormat::SINGLE_SHORT) { - // shortname, no mqtt base. This is the default version. + // shortname (default) snprintf(uniq_id, sizeof(uniq_id), "%s_%s", device_name, entity_with_tag); } else if (Mqtt::entity_format() == entityFormat::SINGLE_OLD) { - // shortname, remap to 3.6. + // shortname, remap to 3.6 if (has_tag && (device_type == EMSdevice::DeviceType::BOILER || device_type == EMSdevice::DeviceType::THERMOSTAT) && tag == DeviceValue::DeviceValueTAG::TAG_DHW1) { snprintf(entity_with_tag, sizeof(entity_with_tag), "ww%s", entity); @@ -872,7 +877,7 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev snprintf(uniq_id, sizeof(uniq_id), "%s_%s", device_name, entity_with_tag); } } else if (Mqtt::entity_format() == entityFormat::MULTI_OLD) { - // shortname, remap to 3.6. + // base name + shortname, remap to 3.6 if (has_tag && (device_type == EMSdevice::DeviceType::BOILER || device_type == EMSdevice::DeviceType::THERMOSTAT) && tag == DeviceValue::DeviceValueTAG::TAG_DHW1) { snprintf(entity_with_tag, sizeof(entity_with_tag), "ww%s", entity); @@ -1391,19 +1396,17 @@ void Mqtt::add_ha_sections_to_doc(const char * name, char tpl[150]; + // make local copy of state, as the pointer will get derefenced + char state[50]; + strcpy(state, state_t); + // skip conditional Jinja2 templates if not home assistant if (discovery_type() == discoveryType::HOMEASSISTANT) { - // EMS-ESP status check - // snprintf(tpl, sizeof(tpl), "%s/status", Mqtt::base().c_str()); - // avty_json["t"] = tpl; - // snprintf(tpl, sizeof(tpl), tpl_draft, "value == 'online'"); - // avty_json["val_tpl"] = tpl; - // avty.add(avty_json); // returns 0 if no mem const char * tpl_draft = "{{'online' if %s else 'offline'}}"; // condition 1 avty_json.clear(); - avty_json["t"] = state_t; + avty_json["t"] = state; snprintf(tpl, sizeof(tpl), tpl_draft, cond1 == nullptr ? "value is defined" : cond1); avty_json["val_tpl"] = tpl; avty.add(avty_json); // returns 0 if no mem @@ -1411,7 +1414,7 @@ void Mqtt::add_ha_sections_to_doc(const char * name, // condition 2 if (cond2 != nullptr) { avty_json.clear(); - avty_json["t"] = state_t; + avty_json["t"] = state; snprintf(tpl, sizeof(tpl), tpl_draft, cond2); avty_json["val_tpl"] = tpl; avty.add(avty_json); // returns 0 if no mem @@ -1420,7 +1423,7 @@ void Mqtt::add_ha_sections_to_doc(const char * name, // negative condition if (negcond != nullptr) { avty_json.clear(); - avty_json["t"] = state_t; + avty_json["t"] = state; snprintf(tpl, sizeof(tpl), "{{'offline' if %s else 'online'}}", negcond); avty_json["val_tpl"] = tpl; avty.add(avty_json); // returns 0 if no mem From 1c7c2a7f834982dec692b963cbcf9863cd8d2210 Mon Sep 17 00:00:00 2001 From: proddy Date: Fri, 14 Jun 2024 12:29:42 +0200 Subject: [PATCH 6/6] resolve lint warnings --- lib/framework/NetworkSettingsService.cpp | 7 +++---- lib_standalone/emsuart_standalone.cpp | 3 --- platformio.ini | 2 +- src/devices/boiler.cpp | 5 ----- src/devices/heatpump.cpp | 5 ----- src/devices/heatsource.cpp | 5 ----- src/devices/mixer.cpp | 5 ----- src/devices/thermostat.cpp | 7 +------ src/devices/water.cpp | 3 --- src/emsdevice.cpp | 2 +- src/uart/emsuart_esp32.cpp | 13 +++++++------ 11 files changed, 13 insertions(+), 44 deletions(-) diff --git a/lib/framework/NetworkSettingsService.cpp b/lib/framework/NetworkSettingsService.cpp index 8b9349326..9f575f926 100644 --- a/lib/framework/NetworkSettingsService.cpp +++ b/lib/framework/NetworkSettingsService.cpp @@ -147,8 +147,6 @@ void NetworkSettingsService::setWiFiPowerOnRSSI() { min_tx_pwr = max_tx_pwr; } - uint8_t set_power = min_tx_pwr / 10; // this is the recommended power setting to use - // from WiFIGeneric.h use: // WIFI_POWER_19_5dBm = 78,// 19.5dBm // WIFI_POWER_19dBm = 76,// 19dBm @@ -183,6 +181,7 @@ void NetworkSettingsService::setWiFiPowerOnRSSI() { p = WIFI_POWER_5dBm; #ifdef EMSESP_DEBUG + uint8_t set_power = min_tx_pwr / 10; // this is the recommended power setting to use emsesp::EMSESP::logger().debug("Recommended set WiFi Tx Power (set_power %d, new power %d, rssi %d, threshold %d)", set_power, p, rssi, threshold); #else char result[10]; @@ -358,13 +357,13 @@ void NetworkSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) setWiFiPowerOnRSSI(); } #if ESP_IDF_VERSION_MAJOR < 5 - WiFi.enableIpV6(); + WiFi.enableIpV6(); #endif break; case ARDUINO_EVENT_ETH_CONNECTED: #if ESP_IDF_VERSION_MAJOR < 5 - ETH.enableIpV6(); + ETH.enableIpV6(); #endif break; diff --git a/lib_standalone/emsuart_standalone.cpp b/lib_standalone/emsuart_standalone.cpp index 56ac5271e..993ecd30b 100644 --- a/lib_standalone/emsuart_standalone.cpp +++ b/lib_standalone/emsuart_standalone.cpp @@ -20,9 +20,6 @@ #include "emsuart_standalone.h" -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - namespace emsesp { /* diff --git a/platformio.ini b/platformio.ini index 5cd6ee8f8..cd5ddb0f4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,7 +13,7 @@ extra_configs = pio_local.ini [common] -core_build_flags = -std=gnu++2a -Isrc -Wno-type-limits +core_build_flags = -std=gnu++2a -Isrc -Wno-type-limits -Wall -Wextra -Wno-unused-parameter core_unbuild_flags = -std=gnu++11 ; my_build_flags is set in pio_local.ini diff --git a/src/devices/boiler.cpp b/src/devices/boiler.cpp index ed45fb263..e78bbf567 100644 --- a/src/devices/boiler.cpp +++ b/src/devices/boiler.cpp @@ -1730,15 +1730,10 @@ void Boiler::process_UBASetPoints(std::shared_ptr telegram) { } } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - // 0x35 - not yet implemented, not readable, only for settings void Boiler::process_UBAFlags(std::shared_ptr telegram) { } -#pragma GCC diagnostic pop - // 0x1C // 08 00 1C 94 0B 0A 1D 31 08 00 80 00 00 00 -> message for 29.11.2020 // 08 00 1C 94 0B 0A 1D 31 00 00 00 00 00 00 -> message reset diff --git a/src/devices/heatpump.cpp b/src/devices/heatpump.cpp index dafc7393b..e86578358 100644 --- a/src/devices/heatpump.cpp +++ b/src/devices/heatpump.cpp @@ -187,9 +187,6 @@ void Heatpump::process_HPMonitor2(std::shared_ptr telegram) { has_update(telegram, airHumidity_, 1); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - /* * Type 0x42B- HeatPump Monitor 1 * e.g. "38 10 FF 00 03 2B 00 D1 08 2A 01" @@ -198,8 +195,6 @@ void Heatpump::process_HPMonitor1(std::shared_ptr telegram) { // still to implement } -#pragma GCC diagnostic pop - // 0x09A0 // Heatpump(0x53) -> All(0x00), ?(0x09A0), data: 02 23 01 3E 01 39 00 5D 01 DE 01 38 00 40 00 5E 00 58 00 3F 01 34 00 02 void Heatpump::process_HPTemperature(std::shared_ptr telegram) { diff --git a/src/devices/heatsource.cpp b/src/devices/heatsource.cpp index 6001f2db7..061cb01b7 100644 --- a/src/devices/heatsource.cpp +++ b/src/devices/heatsource.cpp @@ -162,9 +162,6 @@ void Heatsource::process_amSettingMessage(std::shared_ptr telegr has_update(telegram, releaseWait_, 15); // pos 15: Boiler release wait time (min) } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - // 0x054F AM200 not broadcasted message, 7 bytes long // Boiler(0x60) -> Me(0x0B), amCommand(0x054F), data: 00 00 00 00 00 00 00 void Heatsource::process_amCommandMessage(std::shared_ptr telegram) { @@ -182,8 +179,6 @@ void Heatsource::process_amExtraMessage(std::shared_ptr telegram has_update(telegram, blockRemainWw_, 25); // minutes } -#pragma GCC diagnostic pop - // Settings AM200 // pos 12: off(00)/Keelbypass(01)/(hc1pump(02) only standalone) diff --git a/src/devices/mixer.cpp b/src/devices/mixer.cpp index c5c92e168..594e5573c 100644 --- a/src/devices/mixer.cpp +++ b/src/devices/mixer.cpp @@ -154,9 +154,6 @@ void Mixer::process_MMPLUSConfigMessage_HC(std::shared_ptr teleg has_update(telegram, flowTempOffset_, 2); // Mixer increase [0-20 K] } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - // Thermostat(0x10) -> Mixer(0x20), ?(0x2E1), data: 01 1C 64 00 01 // Thermostat(0x10) -> Mixing Module(0x20), (0x2E1), data: 01 00 00 00 01 // Thermostat(0x10) -> Mixing Module(0x20), (0x2EB), data: 00 @@ -180,8 +177,6 @@ void Mixer::process_IPMSetMessage(std::shared_ptr telegram) { // pos 1: pump in %? } -#pragma GCC diagnostic pop - bool Mixer::set_flowSetTemp(const char * value, const int8_t id) { int v; if (!Helpers::value2number(value, v)) { diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 612bb0a9c..8607fd2a9 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -614,9 +614,6 @@ void Thermostat::process_RC10Set(std::shared_ptr telegram) { has_update(telegram, heatingpid_, 6); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - // type 0xB2, mode setting Data: 04 00 // not used, we read mode from monitor 0xB1 void Thermostat::process_RC10Set_2(std::shared_ptr telegram) { @@ -629,8 +626,6 @@ void Thermostat::process_RC10Set_2(std::shared_ptr telegram) { // has_update(hc->mode, mode >> 1); // store as enum 0, 1, 2 } -#pragma GCC diagnostic pop - // 0xA8 - for reading the mode from the RC20 thermostat (0x17) // RC20Set(0xA8), data: 01 00 FF F6 01 06 00 01 0D 01 00 FF FF 01 02 02 02 00 00 05 1E 05 1E 02 1C 00 FF 00 00 26 02 void Thermostat::process_RC20Set(std::shared_ptr telegram) { @@ -1613,7 +1608,7 @@ void Thermostat::process_RCTime(std::shared_ptr telegram) { tm_->tm_isdst = -1; // determine dst ttime = mktime(tm_); // thermostat time } - struct timeval newnow = {.tv_sec = ttime}; + struct timeval newnow = {.tv_sec = ttime, .tv_usec = 0}; settimeofday(&newnow, nullptr); LOG_INFO("ems-esp time set from thermostat"); } diff --git a/src/devices/water.cpp b/src/devices/water.cpp index 5fcd943bb..772748062 100644 --- a/src/devices/water.cpp +++ b/src/devices/water.cpp @@ -168,14 +168,11 @@ void Water::process_SM100wwStatus2(std::shared_ptr telegram) { has_update(telegram, wwPumpMod_, 9); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" // SM100wwCommand - 0x07AB // Thermostat(0x10) -> Solar Module(0x2A), (0x7AB), data: 01 00 01 void Water::process_SM100wwCommand(std::shared_ptr telegram) { // not implemented yet } -#pragma GCC diagnostic pop /* * MM100 messages diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index 2b63fd65a..0170051f6 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -1701,7 +1701,7 @@ bool EMSdevice::generate_values(JsonObject output, const int8_t tag_filter, cons char time_s[60]; snprintf(time_s, sizeof(time_s), - "%d %s %d %s %d %s", + "%lu %s %lu %s %lu %s", (time_value / 1440), Helpers::translated_word(FL_(days)), ((time_value % 1440) / 60), diff --git a/src/uart/emsuart_esp32.cpp b/src/uart/emsuart_esp32.cpp index 54cffde9a..26736ba6f 100644 --- a/src/uart/emsuart_esp32.cpp +++ b/src/uart/emsuart_esp32.cpp @@ -73,12 +73,13 @@ void EMSuart::uart_event_task(void * pvParameters) { void EMSuart::start(const uint8_t tx_mode, const uint8_t rx_gpio, const uint8_t tx_gpio) { if (tx_mode_ == 0xFF) { uart_config_t uart_config = { - .baud_rate = EMSUART_BAUD, - .data_bits = UART_DATA_8_BITS, - .parity = UART_PARITY_DISABLE, - .stop_bits = UART_STOP_BITS_1, - .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, - .source_clk = UART_SCLK_APB, + .baud_rate = EMSUART_BAUD, + .data_bits = UART_DATA_8_BITS, + .parity = UART_PARITY_DISABLE, + .stop_bits = UART_STOP_BITS_1, + .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, + .rx_flow_ctrl_thresh = 0, // not used - https://docs.espressif.com/projects/esp-idf/en/v3.3.6/api-reference/peripherals/uart.html + .source_clk = UART_SCLK_APB, }; #if defined(EMSUART_RX_INVERT) inverse_mask |= UART_SIGNAL_RXD_INV;