From cf489f763244010b8311d7bd08ab32e0687c659e Mon Sep 17 00:00:00 2001 From: proddy Date: Sun, 24 Mar 2024 09:45:12 +0100 Subject: [PATCH] fix minor lint warnings --- CHANGELOG_LATEST.md | 2 ++ src/mqtt.cpp | 16 ++++++++-------- src/web/WebCustomEntityService.cpp | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md index 7cbcdaab8..87f03e3fe 100644 --- a/CHANGELOG_LATEST.md +++ b/CHANGELOG_LATEST.md @@ -9,3 +9,5 @@ ## Fixed ## Changed + +- Refresh UI - moving settings to one location [#1665](https://github.com/emsesp/EMS-ESP32/issues/1665) diff --git a/src/mqtt.cpp b/src/mqtt.cpp index b3f538434..6aa356a5d 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -1310,18 +1310,18 @@ void Mqtt::add_ha_sections_to_doc(const char * name, JsonArray avty = config["avty"].to(); JsonDocument avty_json; - const char * tpl_draft = "{{'online' if %s else 'offline'}}"; - char tpl[150]; - // 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 // 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; diff --git a/src/web/WebCustomEntityService.cpp b/src/web/WebCustomEntityService.cpp index c9ed66281..0c5c7e206 100644 --- a/src/web/WebCustomEntityService.cpp +++ b/src/web/WebCustomEntityService.cpp @@ -73,7 +73,7 @@ StateUpdateResult WebCustomEntity::update(JsonObject root, WebCustomEntity & web if (root["entities"].is()) { for (const JsonObject ei : root["entities"].as()) { auto entityItem = CustomEntityItem(); - entityItem.ram = ei["ram"] | 0; + entityItem.ram = ei["ram"]; entityItem.device_id = ei["device_id"]; // send as numeric, will be converted to string in web entityItem.type_id = ei["type_id"]; entityItem.offset = ei["offset"];