menuselector now has a dynamic max and removed loop

This commit is contained in:
Martijn
2024-12-25 15:38:36 +01:00
parent 3d8ad96fbb
commit 41d833774c
+21 -22
View File
@@ -92,26 +92,25 @@ time:
- platform: homeassistant - platform: homeassistant
id: datetime id: datetime
# number: number:
# ## Creates a number entity in Home Assistant ## Creates a number entity in Home Assistant
# # It sets the menu of the Button Plus # It sets the menu of the Button Plus
# - platform: template - platform: template
# name: "Menu Selector" name: "Menu Selector"
# id: menuselector id: menuselector
# optimistic: true optimistic: true
# min_value: 0 # keep at 0 min_value: 0 # keep at 0
# max_value: 10 # Maximum number of menu items. You can change this max_value: !lambda 'return id(nr_of_pages) - 1;'
# step: 1 on_value:
# on_value: then:
# then: - lambda: |-
# - lambda: |- if(id(menuselector).state >= id(nr_of_pages)) {
# if(id(menuselector).state >= id(nr_of_pages)) { id(actual_page) = id(nr_of_pages)-1;
# id(actual_page) = id(nr_of_pages)-1; } else {
# } else { id(actual_page) = id(menuselector).state;
# id(actual_page) = id(menuselector).state; }
# }
# # Refresh the screen # # Refresh the screen
# - script.execute: update_page # - script.execute: update_page <<< this ends in an loop...
script: script:
###################### ######################
@@ -143,8 +142,8 @@ script:
- text_sensor.template.publish: - text_sensor.template.publish:
id: active_page_name_ha id: active_page_name_ha
state: !lambda 'return id(active_page_name);' state: !lambda 'return id(active_page_name);'
# - number.set: - number.set:
# id: menuselector id: menuselector
# value: !lambda 'return id(actual_page);' value: !lambda 'return id(actual_page);'
- script.execute: update_all - script.execute: update_all