nr_of_pages is now a substitution, page_names is now a global
This commit is contained in:
@@ -6,9 +6,14 @@ packages:
|
|||||||
ref: main
|
ref: main
|
||||||
refresh: 1d
|
refresh: 1d
|
||||||
|
|
||||||
|
substitutions:
|
||||||
|
nr_of_pages: '1'
|
||||||
|
|
||||||
globals:
|
globals:
|
||||||
- id: !extend nr_of_pages
|
- id: !extend page_names
|
||||||
initial_value: '1'
|
initial_value: '{"Page 1"}'
|
||||||
|
- id: !extend active_page_name
|
||||||
|
initial_value: ""
|
||||||
|
|
||||||
font:
|
font:
|
||||||
- file: "https://github.com/web-fonts/ttf/raw/refs/heads/master/bpg-ingiri-arial-webfont.ttf"
|
- file: "https://github.com/web-fonts/ttf/raw/refs/heads/master/bpg-ingiri-arial-webfont.ttf"
|
||||||
|
|||||||
@@ -6,9 +6,14 @@ packages:
|
|||||||
ref: main
|
ref: main
|
||||||
refresh: 1d
|
refresh: 1d
|
||||||
|
|
||||||
|
substitutions:
|
||||||
|
nr_of_pages: '1'
|
||||||
|
|
||||||
globals:
|
globals:
|
||||||
- id: !extend nr_of_pages
|
- id: !extend page_names
|
||||||
initial_value: '1'
|
initial_value: '{"Page 1"}'
|
||||||
|
- id: !extend active_page_name
|
||||||
|
initial_value: ""
|
||||||
|
|
||||||
font:
|
font:
|
||||||
- file: "https://github.com/web-fonts/ttf/raw/refs/heads/master/bpg-ingiri-arial-webfont.ttf"
|
- file: "https://github.com/web-fonts/ttf/raw/refs/heads/master/bpg-ingiri-arial-webfont.ttf"
|
||||||
|
|||||||
@@ -6,9 +6,14 @@ packages:
|
|||||||
ref: main
|
ref: main
|
||||||
refresh: 1d
|
refresh: 1d
|
||||||
|
|
||||||
|
substitutions:
|
||||||
|
nr_of_pages: '1'
|
||||||
|
|
||||||
globals:
|
globals:
|
||||||
- id: !extend nr_of_pages
|
- id: !extend page_names
|
||||||
initial_value: '1'
|
initial_value: '{"Page 1"}'
|
||||||
|
- id: !extend active_page_name
|
||||||
|
initial_value: ""
|
||||||
|
|
||||||
font:
|
font:
|
||||||
- file: "https://github.com/web-fonts/ttf/raw/refs/heads/master/bpg-ingiri-arial-webfont.ttf"
|
- file: "https://github.com/web-fonts/ttf/raw/refs/heads/master/bpg-ingiri-arial-webfont.ttf"
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ wifi:
|
|||||||
password: !secret wifi_password
|
password: !secret wifi_password
|
||||||
|
|
||||||
substitutions:
|
substitutions:
|
||||||
|
nr_of_pages: '3'
|
||||||
music_card_enity_id: 'media_player.media_keuken_2'
|
music_card_enity_id: 'media_player.media_keuken_2'
|
||||||
music_card_text_color: FFFFFF
|
music_card_text_color: FFFFFF
|
||||||
music_card_icon_main_color: FF7F00
|
music_card_icon_main_color: FF7F00
|
||||||
@@ -44,13 +45,9 @@ packages:
|
|||||||
refresh: 1d
|
refresh: 1d
|
||||||
|
|
||||||
globals:
|
globals:
|
||||||
- id: !extend nr_of_pages
|
- id: !extend page_names
|
||||||
initial_value: '3'
|
|
||||||
- id: page_names
|
|
||||||
type: std::vector<std::string>
|
|
||||||
initial_value: '{"Page 1","Music","Page 3"}'
|
initial_value: '{"Page 1","Music","Page 3"}'
|
||||||
- id: active_page_name
|
- id: !extend active_page_name
|
||||||
type: std::string
|
|
||||||
initial_value: ""
|
initial_value: ""
|
||||||
|
|
||||||
font:
|
font:
|
||||||
|
|||||||
+16
-15
@@ -29,12 +29,15 @@ spi:
|
|||||||
mosi_pin: GPIO35
|
mosi_pin: GPIO35
|
||||||
|
|
||||||
globals:
|
globals:
|
||||||
- id: nr_of_pages
|
|
||||||
type: int
|
|
||||||
initial_value: '1'
|
|
||||||
- id: actual_page
|
- id: actual_page
|
||||||
type: int
|
type: int
|
||||||
initial_value: '0'
|
initial_value: '0'
|
||||||
|
- id: page_names
|
||||||
|
type: std::vector<std::string>
|
||||||
|
initial_value: '{"Page 1"}'
|
||||||
|
- id: active_page_name
|
||||||
|
type: std::string
|
||||||
|
initial_value: ""
|
||||||
|
|
||||||
output:
|
output:
|
||||||
- platform: ledc
|
- platform: ledc
|
||||||
@@ -93,24 +96,24 @@ time:
|
|||||||
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: menu_selector
|
||||||
optimistic: true
|
optimistic: true
|
||||||
min_value: 0 # keep at 0
|
min_value: 0 # keep at 0
|
||||||
max_value: 10 # TODO replace page numbers with substitution
|
max_value: ${nr_of_pages}
|
||||||
step: 1
|
step: 1
|
||||||
on_value:
|
on_value:
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
if(id(menuselector).state >= id(nr_of_pages)) {
|
if(id(menu_selector).state >= $nr_of_pages) {
|
||||||
id(actual_page) = id(nr_of_pages)-1;
|
id(actual_page) = $nr_of_pages-1;
|
||||||
} else {
|
} else {
|
||||||
id(actual_page) = id(menuselector).state;
|
id(actual_page) = id(menu_selector).state;
|
||||||
}
|
}
|
||||||
# # Refresh the screen
|
# Refresh the screen
|
||||||
# - script.execute: update_page <<< this ends in an loop...
|
# - script.execute: update_page <<< this ends in an loop...
|
||||||
|
|
||||||
script:
|
script:
|
||||||
@@ -121,7 +124,7 @@ script:
|
|||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(actual_page) = id(actual_page) + 1;
|
id(actual_page) = id(actual_page) + 1;
|
||||||
if(id(actual_page) >= id(nr_of_pages)) {
|
if(id(actual_page) >= $nr_of_pages) {
|
||||||
id(actual_page) = 0;
|
id(actual_page) = 0;
|
||||||
}
|
}
|
||||||
- script.execute: update_page
|
- script.execute: update_page
|
||||||
@@ -130,7 +133,7 @@ script:
|
|||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(actual_page) = id(actual_page) - 1;
|
id(actual_page) = id(actual_page) - 1;
|
||||||
if(id(actual_page) < 0) {
|
if(id(actual_page) < 0) {
|
||||||
id(actual_page) = id(nr_of_pages) - 1;
|
id(actual_page) = $nr_of_pages - 1;
|
||||||
}
|
}
|
||||||
- script.execute: update_page
|
- script.execute: update_page
|
||||||
- id: update_page
|
- id: update_page
|
||||||
@@ -144,7 +147,5 @@ script:
|
|||||||
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: menu_selector
|
||||||
value: !lambda 'return id(actual_page);'
|
value: !lambda 'return id(actual_page);'
|
||||||
- script.execute: update_all
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user