Merge pull request #8 from balk77/main
Made global with active page title, integrated with "next_page"/previous_page
This commit is contained in:
@@ -46,6 +46,9 @@ packages:
|
|||||||
globals:
|
globals:
|
||||||
- id: !extend nr_of_pages
|
- id: !extend nr_of_pages
|
||||||
initial_value: '3'
|
initial_value: '3'
|
||||||
|
- id: page_names
|
||||||
|
type: std::vector<std::string>
|
||||||
|
initial_value: '{"Page 1","Music","Page 3"}'
|
||||||
- id: active_page_name
|
- id: active_page_name
|
||||||
type: std::string
|
type: std::string
|
||||||
initial_value: ""
|
initial_value: ""
|
||||||
@@ -493,18 +496,12 @@ display:
|
|||||||
switch (id(actual_page)){
|
switch (id(actual_page)){
|
||||||
case 0:
|
case 0:
|
||||||
id(containers).execute();
|
id(containers).execute();
|
||||||
// Page name to be shown on page 1
|
|
||||||
id(active_page_name) = "Page 1";
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
id(music_card).execute(20, 125);
|
id(music_card).execute(20, 125);
|
||||||
// Page name to be shown on page 2
|
|
||||||
id(active_page_name) = "Music page";
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
it.print(100, 160, id(font_arial20), "This is page 3!");
|
it.print(100, 160, id(font_arial20), "This is page 3!");
|
||||||
// Page name to be shown on page 3
|
|
||||||
id(active_page_name) = "Page 3";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,9 +154,15 @@ script:
|
|||||||
- id: update_all
|
- id: update_all
|
||||||
then:
|
then:
|
||||||
- component.update: main_display
|
- component.update: main_display
|
||||||
|
- delay: 0.1s
|
||||||
- script.execute: update_bar1_left
|
- script.execute: update_bar1_left
|
||||||
|
- delay: 0.1s
|
||||||
- script.execute: update_bar1_right
|
- script.execute: update_bar1_right
|
||||||
|
- delay: 0.1s
|
||||||
- script.execute: update_bar2_left
|
- script.execute: update_bar2_left
|
||||||
|
- delay: 0.1s
|
||||||
- script.execute: update_bar2_right
|
- script.execute: update_bar2_right
|
||||||
|
- delay: 0.1s
|
||||||
- script.execute: update_bar3_left
|
- script.execute: update_bar3_left
|
||||||
|
- delay: 0.1s
|
||||||
- script.execute: update_bar3_right
|
- script.execute: update_bar3_right
|
||||||
|
|||||||
+48
-2
@@ -57,7 +57,17 @@ sensor:
|
|||||||
name: "Temperature"
|
name: "Temperature"
|
||||||
address: 0x4A
|
address: 0x4A
|
||||||
update_interval: 10s
|
update_interval: 10s
|
||||||
|
- platform: template
|
||||||
|
name: "Active Page ID"
|
||||||
|
id: active_page_id_ha
|
||||||
|
update_interval: never
|
||||||
|
|
||||||
|
text_sensor:
|
||||||
|
- platform: template
|
||||||
|
name: "Active Page Name"
|
||||||
|
id: active_page_name_ha
|
||||||
|
update_interval: never
|
||||||
|
|
||||||
light:
|
light:
|
||||||
- platform: neopixelbus
|
- platform: neopixelbus
|
||||||
id: neopixels
|
id: neopixels
|
||||||
@@ -82,6 +92,27 @@ time:
|
|||||||
- platform: homeassistant
|
- platform: homeassistant
|
||||||
id: datetime
|
id: datetime
|
||||||
|
|
||||||
|
number:
|
||||||
|
## Creates a number entity in Home Assistant
|
||||||
|
# It sets the menu of the Button Plus
|
||||||
|
- platform: template
|
||||||
|
name: "Menu Selector"
|
||||||
|
id: menuselector
|
||||||
|
optimistic: true
|
||||||
|
min_value: 0 # keep at 0
|
||||||
|
max_value: 10 # Maximum number of menu items. You can change this
|
||||||
|
step: 1
|
||||||
|
on_value:
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
if(id(menuselector).state >= id(nr_of_pages)) {
|
||||||
|
id(actual_page) = id(nr_of_pages)-1;
|
||||||
|
} else {
|
||||||
|
id(actual_page) = id(menuselector).state;
|
||||||
|
}
|
||||||
|
# Refresh the screen
|
||||||
|
- script.execute: update_page
|
||||||
|
|
||||||
script:
|
script:
|
||||||
######################
|
######################
|
||||||
### paging scripts ###
|
### paging scripts ###
|
||||||
@@ -93,7 +124,7 @@ script:
|
|||||||
if(id(actual_page) >= id(nr_of_pages)) {
|
if(id(actual_page) >= id(nr_of_pages)) {
|
||||||
id(actual_page) = 0;
|
id(actual_page) = 0;
|
||||||
}
|
}
|
||||||
- script.execute: update_all
|
- script.execute: update_page
|
||||||
- id: prev_page
|
- id: prev_page
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
@@ -101,4 +132,19 @@ script:
|
|||||||
if(id(actual_page) < 0) {
|
if(id(actual_page) < 0) {
|
||||||
id(actual_page) = id(nr_of_pages) - 1;
|
id(actual_page) = id(nr_of_pages) - 1;
|
||||||
}
|
}
|
||||||
|
- script.execute: update_page
|
||||||
|
- id: update_page
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
id(active_page_name) = id(page_names)[id(actual_page)];
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: active_page_id_ha
|
||||||
|
state: !lambda 'return id(actual_page);'
|
||||||
|
- text_sensor.template.publish:
|
||||||
|
id: active_page_name_ha
|
||||||
|
state: !lambda 'return id(active_page_name);'
|
||||||
|
- number.set:
|
||||||
|
id: menuselector
|
||||||
|
value: !lambda 'return id(actual_page);'
|
||||||
- script.execute: update_all
|
- script.execute: update_all
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user