From 4f21cb442a43618da3a8b9fc02e77b6f38f40e09 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Wed, 13 Mar 2024 20:17:49 +0100 Subject: [PATCH] Update wifi icon when connection changes --- esphome/nspanel_esphome_core.yaml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/esphome/nspanel_esphome_core.yaml b/esphome/nspanel_esphome_core.yaml index 47f0cc2..336e622 100644 --- a/esphome/nspanel_esphome_core.yaml +++ b/esphome/nspanel_esphome_core.yaml @@ -113,6 +113,14 @@ wifi: ap: ssid: "${name}" password: ${ap_password} + on_connect: + - lambda: |- + disp1->send_command_printf("api=%i", (wifi_component->is_connected() and api_server->is_connected()) ? 1 : 0); + refresh_wifi_icon->execute(); + on_disconnect: + - lambda: |- + disp1->send_command_printf("api=%i", (wifi_component->is_connected() and api_server->is_connected()) ? 1 : 0); + refresh_wifi_icon->execute(); ##### OTA PASSWORD ##### ota: @@ -173,6 +181,14 @@ time: api: id: api_server reboot_timeout: 60min + on_client_connected: + - lambda: |- + disp1->send_command_printf("api=%i", (wifi_component->is_connected() and api_server->is_connected()) ? 1 : 0); + refresh_wifi_icon->execute(); + on_client_disconnected: + - lambda: |- + disp1->send_command_printf("api=%i", (wifi_component->is_connected() and api_server->is_connected()) ? 1 : 0); + refresh_wifi_icon->execute(); services: # Dynamically configures button properties on a specified page, enhancing UI interactivity by allowing updates to button appearance and behavior based on given parameters. - service: button # yamllint disable-line rule:indentation @@ -2666,7 +2682,7 @@ script: then: # Wi-Fi connected - lambda: |- if (current_page->state == "boot") { - disp1->set_component_text("boot.ip_addr", network::get_ip_address().str().c_str()); + disp1->set_component_text("boot.ip_addr", network::get_ip_address().str().c_str()); // To do: get_ip_addresses()[0] set_brightness->execute(100); } - wait_until: