Don't send to Nextion obsolete volume settings
If the volume is the same as the last one sent to the screen, don't send again, so if changes are being made on the screen it didn't receive the update all the time, making the slider unresponsive.
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user