diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md index 3f9d14590..7427a8c89 100644 --- a/CHANGELOG_LATEST.md +++ b/CHANGELOG_LATEST.md @@ -20,6 +20,7 @@ For more details go to [emsesp.org](https://emsesp.org/). - SRC climate creation [#2936](https://github.com/emsesp/EMS-ESP32/issues/2936) and [#2960](https://github.com/emsesp/EMS-ESP32/issues/2960) - missing translations [#3015](https://github.com/emsesp/EMS-ESP32/issues/3015) +- custom entities check fetch length ## Changed diff --git a/src/ESP32React/ArduinoJsonJWT.cpp b/src/ESP32React/ArduinoJsonJWT.cpp index 7e7676af5..bbc2b11ac 100644 --- a/src/ESP32React/ArduinoJsonJWT.cpp +++ b/src/ESP32React/ArduinoJsonJWT.cpp @@ -70,16 +70,12 @@ void ArduinoJsonJWT::parseJWT(String jwt, JsonDocument & jsonDocument) { */ String ArduinoJsonJWT::sign(String & payload) { std::array hmacResult{}; - { - mbedtls_md_context_t ctx; - mbedtls_md_type_t md_type = MBEDTLS_MD_SHA256; - mbedtls_md_init(&ctx); - mbedtls_md_setup(&ctx, mbedtls_md_info_from_type(md_type), 1); - mbedtls_md_hmac_starts(&ctx, reinterpret_cast(_secret.c_str()), _secret.length()); - mbedtls_md_hmac_update(&ctx, reinterpret_cast(payload.c_str()), payload.length()); - mbedtls_md_hmac_finish(&ctx, hmacResult.data()); - mbedtls_md_free(&ctx); - } + mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), + reinterpret_cast(_secret.c_str()), + _secret.length(), + reinterpret_cast(payload.c_str()), + payload.length(), + hmacResult.data()); return encode(reinterpret_cast(hmacResult.data()), hmacResult.size()); } diff --git a/src/core/emsdevice.cpp b/src/core/emsdevice.cpp index d5c18839d..570cb4470 100644 --- a/src/core/emsdevice.cpp +++ b/src/core/emsdevice.cpp @@ -387,10 +387,10 @@ void EMSdevice::toggle_fetch(uint16_t telegram_id, bool toggle) { } // get status of automatic fetch for a telegramID -bool EMSdevice::is_fetch(uint16_t telegram_id) const { +bool EMSdevice::is_fetch(uint16_t telegram_id, uint8_t len) const { for (const auto & tf : telegram_functions_) { if (tf.telegram_type_id_ == telegram_id) { - return tf.fetch_; + return tf.fetch_ && tf.length_ >= len; } } return false; diff --git a/src/core/emsdevice.h b/src/core/emsdevice.h index 366f76a2e..01c870a1d 100644 --- a/src/core/emsdevice.h +++ b/src/core/emsdevice.h @@ -362,7 +362,7 @@ class EMSdevice { const char * telegram_type_name(std::shared_ptr telegram); void fetch_values(); void toggle_fetch(uint16_t telegram_id, bool toggle); - bool is_fetch(uint16_t telegram_id) const; + bool is_fetch(uint16_t telegram_id, uint8_t len = 0) const; bool is_received(uint16_t telegram_id) const; bool has_telegram_id(uint16_t id) const; void ha_config_clear(); diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index e27b08e5c..977f041bc 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -202,7 +202,7 @@ Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_i if (model == EMSdevice::EMS_DEVICE_FLAG_RC100) { register_telegram_type(0x43F, "CRHolidays", true, MAKE_PF_CB(process_RC300Holiday), 6); } else { - register_telegram_type(0x269, "RC300Holiday", true, MAKE_PF_CB(process_RC300Holiday), 6); + register_telegram_type(0x269, "RC300Holiday", true, MAKE_PF_CB(process_RC300Holiday), 18); } register_telegram_type(0x16E, "Absent", true, MAKE_PF_CB(process_Absent), 1); register_telegram_type(0xBF, "ErrorMessage", false, MAKE_PF_CB(process_ErrorMessageBF)); diff --git a/src/web/WebCustomEntityService.cpp b/src/web/WebCustomEntityService.cpp index 9de8f3da8..faf9f54eb 100644 --- a/src/web/WebCustomEntityService.cpp +++ b/src/web/WebCustomEntityService.cpp @@ -686,7 +686,7 @@ void WebCustomEntityService::fetch() { uint8_t stop = (entity.offset + len[entity.value_type]) % fetchblock; bool is_fetched = start < fetchblock && stop < fetchblock; // make sure the complete value is a a fetched block for (const auto & emsdevice : EMSESP::emsdevices) { - if (emsdevice->is_device_id(entity.device_id) && emsdevice->is_fetch(entity.type_id) + if (emsdevice->is_device_id(entity.device_id) && emsdevice->is_fetch(entity.type_id, entity.offset + len[entity.value_type]) && (is_fetched || entity.value_type == DeviceValueType::STRING)) { needFetch = false; break; diff --git a/src/web/WebStatusService.cpp b/src/web/WebStatusService.cpp index aa66292b1..d97c4d4e8 100644 --- a/src/web/WebStatusService.cpp +++ b/src/web/WebStatusService.cpp @@ -296,10 +296,6 @@ uint8_t WebStatusService::upgradeImportantMessages(std::string & version) { version::EMSESP_Version current_version(current_version_s); // get current version - if (latest_version > current_version && current_version.minor() < latest_version.minor()) { - return 0; // if it's just a minor version upgrade return 0 - } - if ((current_version.major() <= 3 && current_version.minor() <= 8) && (latest_version.major() == 3 && latest_version.minor() == 9)) { return 1; // if moving from below 3.8.x to 3.9.x return 1 } @@ -308,6 +304,10 @@ uint8_t WebStatusService::upgradeImportantMessages(std::string & version) { return 2; // if it's a major version upgrade return 2 } + if (latest_version > current_version && current_version.minor() < latest_version.minor()) { + return 0; // if it's just a minor version upgrade return 0 + } + return 0; // if it's not a valid version upgrade return 0 }