diff --git a/nspanel_esphome.yaml b/nspanel_esphome.yaml index 00b870e..b1692d9 100644 --- a/nspanel_esphome.yaml +++ b/nspanel_esphome.yaml @@ -824,8 +824,12 @@ api: // VOLUME_SET if (supported_features & 4) { - id(disp1).set_component_text_printf("vol_text", "%i%%", volume_level); - id(disp1).set_component_value("vol_slider", volume_level); + if (volume_level != id(last_volume_level)) + { + id(last_volume_level) = volume_level; + id(disp1).set_component_text_printf("vol_text", "%i%%", volume_level); + id(disp1).set_component_value("vol_slider", volume_level); + } id(disp1).show_component("vol_slider"); id(disp1).show_component("bt_vol_down"); id(disp1).show_component("bt_vol_up"); @@ -860,6 +864,12 @@ api: ##### START - GLOBALS CONFIGURATION ##### globals: + ###### Last volume level from Home Assistant ###### + - id: last_volume_level + type: int + restore_value: false + initial_value: '-1' + ###### Relay fallback even when buttons have other entities? ###### - id: relay_1_fallback type: bool @@ -1245,7 +1255,8 @@ text_sensor: on_value: then: - lambda: |- - if (x != "climate" and x != "cover" and x != "fan" and x != "light" and x != "media_player" and x != "confirm" and x != "keyb_num" ) id(entity_id) = ""; + if (x != "climate" and x != "cover" and x != "fan" and x != "light" and x != "media_player" and x != "confirm" and x != "keyb_num") id(entity_id) = ""; + if (x != "media_player") id(last_volume_level) = -1; ESP_LOGD("text_sensor.current_page", "New page: %s", x.c_str()); if (!id(entity_id).empty()) ESP_LOGD("text_sensor.current_page", "Entity shown: %s", id(entity_id).c_str()); id(timer_reset_all).execute(x.c_str());