From d59361f937c1d2a42c3f93d756a251e44adf34af Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 12 Apr 2024 09:58:50 +0200 Subject: [PATCH] Report ESPHome version on event call This will allow version based blueprint --- esphome/nspanel_esphome_core.yaml | 36 +++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/esphome/nspanel_esphome_core.yaml b/esphome/nspanel_esphome_core.yaml index 5e3e2b3..c045aa5 100644 --- a/esphome/nspanel_esphome_core.yaml +++ b/esphome/nspanel_esphome_core.yaml @@ -62,6 +62,7 @@ esphome: - lambda: |- set_timezone->execute(id(mui_timezone).c_str()); if (isnan(blueprint_status->raw_state)) blueprint_status->publish_state(0); + version_esphome->publish_state("${version}"); device_name->publish_state("${name}"); notification_label->publish_state(""); notification_text->publish_state(""); @@ -342,7 +343,6 @@ api: screensaver_time_font: int # Specifies the font id for the screensaver time display. screensaver_time_color: int[] # RGB color for the screensaver time display, e.g., [165, 42, 42] for reddish-brown. decimal_separator: string # The char to be used as decimal separator. - # bytes_per_char: init then: - if: condition: @@ -358,7 +358,6 @@ api: screensaver_time_font: !lambda return screensaver_time_font; screensaver_time_color: !lambda return screensaver_time_color; decimal_separator: !lambda return decimal_separator; - # bytes_per_char: !lambda return bytes_per_char; - script.wait: global_settings - lambda: blueprint_status->publish_state(int(blueprint_status->raw_state) | (1 << 5)); @@ -807,6 +806,14 @@ api: - lambda: |- if (component == "is_climate") id(is_climate) = val; + - service: set_int + variables: + component: string + val: int + then: + - lambda: |- + if (component == "bytes_per_char") id(mui_bytes_per_char) = val; + - service: set_string variables: component: string @@ -1659,6 +1666,7 @@ switch: esphome::api::CustomAPIDevice ha_event; ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"device_name", device_name->state.c_str()}, + {"esphome_version", "${version}"}, {"type", "notification_changed"}, {"component", "notification_unread"}, {"action", "turn_on"} @@ -1668,6 +1676,7 @@ switch: esphome::api::CustomAPIDevice ha_event; ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"device_name", device_name->state.c_str()}, + {"esphome_version", "${version}"}, {"type", "notification_changed"}, {"component", "notification_unread"}, {"action", "turn_off"} @@ -1818,6 +1827,7 @@ text_sensor: esphome::api::CustomAPIDevice ha_event; ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"device_name", device_name->state.c_str()}, + {"esphome_version", "${version}"}, {"type", "notification_changed"}, {"component", "notification_label"}, {"action", "new_value"} @@ -1831,6 +1841,7 @@ text_sensor: esphome::api::CustomAPIDevice ha_event; ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"device_name", device_name->state.c_str()}, + {"esphome_version", "${version}"}, {"type", "notification_changed"}, {"component", "notification_text"}, {"action", "new_value"} @@ -1865,6 +1876,7 @@ text_sensor: } else if (page == "light" or page == "climate") { // Generic event ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"device_name", device_name->state.c_str()}, + {"esphome_version", "${version}"}, {"type", "generic"}, {"page", page.c_str()}, {"component", component.c_str()}, @@ -1914,6 +1926,7 @@ text_sensor: ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"device_name", device_name->state.c_str()}, + {"esphome_version", "${version}"}, {"type", "service_call"}, {"service", "light.turn_on"}, {"key", "rgb_color"}, @@ -1948,6 +1961,16 @@ text_sensor: - lambda: |- check_versions->execute(); + - id: version_esphome + name: Version ESPHome + platform: template + entity_category: diagnostic + icon: mdi:tag-text-outline + internal: false + update_interval: never + lambda: |- + return {"${version}"}; + - id: version_tft name: Version TFT platform: nextion @@ -1973,6 +1996,7 @@ script: ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"device_name", device_name->state.c_str()}, + {"esphome_version", "${version}"}, {"type", "boot"}, {"step", "start"} }); @@ -1988,6 +2012,7 @@ script: ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"device_name", device_name->state.c_str()}, + {"esphome_version", "${version}"}, {"type", "boot"}, {"step", "timeout"} }); @@ -2051,6 +2076,7 @@ script: ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"device_name", device_name->state.c_str()}, + {"esphome_version", "${version}"}, {"type", "version"}, {"tft", version_tft->state.c_str()}, {"esphome", "${version}"}, @@ -2121,7 +2147,6 @@ script: screensaver_time_font: int screensaver_time_color: int32_t[] decimal_separator: string - # bytes_per_char: int then: - lambda: |- if (!id(is_uploading_tft)) { @@ -2133,7 +2158,6 @@ script: // MUI strings id(mui_please_confirm_global) = mui_please_confirm; id(mui_unavailable_global) = mui_unavailable; - // id(mui_bytes_per_char) = bytes_per_char; // Screen saver page (sleep) id(screensaver_display_time) = screensaver_time; @@ -2177,6 +2201,7 @@ script: ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"device_name", device_name->state.c_str()}, + {"esphome_version", "${version}"}, {"type", "button_click"}, {"page", page}, {"component", component}, @@ -2197,6 +2222,7 @@ script: ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"device_name", device_name->state.c_str()}, + {"esphome_version", "${version}"}, {"type", "service_call"}, {"service", service}, {"key", key}, @@ -2305,6 +2331,7 @@ script: ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"device_name", device_name->state.c_str()}, + {"esphome_version", "${version}"}, {"type", "boot"}, {"step", "nextion_init"} }); @@ -2412,6 +2439,7 @@ script: ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"device_name", device_name->state.c_str()}, + {"esphome_version", "${version}"}, {"type", "page_changed"}, {"page", current_page->state.c_str()}, {"entity", detailed_entity->state.c_str()}