From 5ff5d35833be1a1cf9ca0f570662456058980024 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Tue, 27 Jun 2023 17:42:23 +0200 Subject: [PATCH] Wifi icon to indicate when API offline This changes the behavior of Wifi icon: How it was before: - Wifi icon was visible only when the wifi was connected, nothing was shown when wifi was not connected. How it is now: - Wifi icon will have 3 states: - Wifi & API connected: Gray wifi icon - Wifi disconnected: Red wifi-off icon - Wifi connected, but API disconnected (HA is out?): Red api-off icon --- nspanel_esphome.yaml | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/nspanel_esphome.yaml b/nspanel_esphome.yaml index 824ca56..7907c3e 100644 --- a/nspanel_esphome.yaml +++ b/nspanel_esphome.yaml @@ -598,6 +598,25 @@ binary_sensor: ##### API connection status - platform: status name: ${device_name} Status + on_state: + then: + - &update_wifi_icon + if: + condition: + wifi.connected: + then: + - if: + condition: + api.connected: + then: + - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\U0000E5A8"); + - lambda: id(disp1).set_component_font_color("home.wifi_icon", 33808); + else: + - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\U0000F256"); + - lambda: id(disp1).set_component_font_color("home.wifi_icon", 63488); + else: + - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\U0000E5A9"); + - lambda: id(disp1).set_component_font_color("home.wifi_icon", 63488); ##### START - SENSOR CONFIGURATION ##### sensor: @@ -612,13 +631,7 @@ sensor: platform: wifi_signal update_interval: 60s on_value: - - if: - condition: - wifi.connected: - then: - - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\U0000E5A8"); - else: - - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\U0000FFFF"); + - *update_wifi_icon ##### INTERNAL TEMPERATURE SENSOR, ADC VALUE ##### - id: ntc_source