Skip to content

Commit bb39174

Browse files
committed
Make scenes tab more flxeible
Support up to 4 scenes Remove old stale ESPHOME config files
1 parent 7197eb3 commit bb39174

7 files changed

Lines changed: 162 additions & 446 deletions

File tree

dev-sdl.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,28 @@ substitutions:
104104
temp_current_target_label: "Target Temperature"
105105

106106
# --------------------------------------------------------------------------
107-
# Scene configuration
107+
# Scene/Script configuration
108108
# --------------------------------------------------------------------------
109109

110+
scene1_action_type: "scene.turn_on"
110111
scene1_entity_id: "scene.scene1"
111112
scene1_name: "Scene 1"
112-
scene2_entity_id: "scene.scene2"
113+
scene1_icon: "$mdi_white_balance_sunny"
114+
115+
scene2_action_type: "scene.turn_on"
116+
scene2_entity_id: "" # leave empty to hide the whole button
113117
scene2_name: "Scene 2"
118+
scene2_icon: "$mdi_bed"
119+
120+
scene3_action_type: "scene.turn_on"
121+
scene3_entity_id: "" # leave empty to hide the whole button
122+
scene3_name: "Scene 3"
123+
scene3_icon: "$mdi_floor_lamp"
124+
125+
scene4_action_type: "scene.turn_on"
126+
scene4_entity_id: "" # leave empty to hide the whole button
127+
scene4_name: "Scene 4"
128+
scene4_icon: "$mdi_ceiling_light"
114129

115130
# --------------------------------------------------------------------------
116131
# Everything below this line is not really meant to be overridden by the user, but you can if you want to

example-instance.yaml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,24 @@ packages:
6060
ha_temperature_target_sensor: "sensor.temperatura_target_attuale_p1"
6161

6262
# Scenes
63-
scene1_entity_id: "scene.tapparelle_aperte_max"
64-
scene1_name: "Tapparelle Aperte Max"
65-
scene2_entity_id: "scene.riposino"
66-
scene2_name: "Riposino"
63+
scene1_action_type: "scene.turn_on"
64+
scene1_entity_id: "scene.scene1"
65+
scene1_name: "Scene 1"
66+
scene1_icon: "$mdi_white_balance_sunny"
6767

68+
scene2_action_type: "scene.turn_on"
69+
scene2_entity_id: "" # leave empty to hide the whole button
70+
scene2_name: "Scene 2"
71+
scene2_icon: "$mdi_bed"
72+
73+
scene3_action_type: "scene.turn_on"
74+
scene3_entity_id: "" # leave empty to hide the whole button
75+
scene3_name: "Scene 3"
76+
scene3_icon: "$mdi_floor_lamp"
77+
78+
scene4_action_type: "scene.turn_on"
79+
scene4_entity_id: "" # leave empty to hide the whole button
80+
scene4_name: "Scene 4"
81+
scene4_icon: "$mdi_ceiling_light"
6882
ref: main # optional
6983
refresh: 1d # optional

include/lvgl_tab_scenes.yaml

Lines changed: 85 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# File: lvgl_tab_scenes.yaml
22
# Purpose: creates a tab for controlling scenes, displaying scene buttons.
33
# List of subtitutions:
4-
# - none
4+
# - scene1_icon
5+
# - scene1_name
6+
# - scene1_action_type
7+
# - scene1_entity_id
8+
# - .... all repeated for scene2 and scene3 ...
59

610
- obj:
711
width: 100%
@@ -14,6 +18,7 @@
1418
flex_align_cross: center
1519
widgets:
1620
- button:
21+
id: btn_scene1
1722
width: 100%
1823
height: 60
1924
bg_color: $icon_temp_color
@@ -27,13 +32,16 @@
2732
flex_align_track: center
2833
pad_column: 10
2934
on_click:
35+
- logger.log:
36+
level: INFO
37+
format: "Scene button clicked: ${scene1_name} (${scene1_entity_id})"
3038
- homeassistant.action:
31-
action: scene.turn_on
39+
action: ${scene1_action_type}
3240
data:
3341
entity_id: ${scene1_entity_id}
3442
widgets:
3543
- label:
36-
text: "$mdi_white_balance_sunny"
44+
text: "${scene1_icon}"
3745
text_align: CENTER
3846
text_color: $label_spinbtn_color
3947
text_font: $icon_font
@@ -44,6 +52,7 @@
4452
text_color: $label_spinbtn_color
4553
align: CENTER
4654
- button:
55+
id: btn_scene2
4756
width: 100%
4857
height: 60
4958
bg_color: $icon_temp_color
@@ -57,13 +66,16 @@
5766
flex_align_track: center
5867
pad_column: 10
5968
on_click:
69+
- logger.log:
70+
level: INFO
71+
format: "Scene button clicked: ${scene2_name} (${scene2_entity_id})"
6072
- homeassistant.action:
61-
action: scene.turn_on
73+
action: ${scene2_action_type}
6274
data:
6375
entity_id: ${scene2_entity_id}
6476
widgets:
6577
- label:
66-
text: "$mdi_bed"
78+
text: "${scene2_icon}"
6779
text_align: CENTER
6880
text_color: $label_spinbtn_color
6981
text_font: $icon_font
@@ -72,4 +84,72 @@
7284
text: "${scene2_name}"
7385
text_align: CENTER
7486
text_color: $label_spinbtn_color
87+
align: CENTER
88+
- button:
89+
id: btn_scene3
90+
width: 100%
91+
height: 60
92+
bg_color: $icon_temp_color
93+
pressed:
94+
bg_color: darkorange
95+
layout:
96+
type: flex
97+
flex_flow: row
98+
flex_align_main: center
99+
flex_align_cross: center
100+
flex_align_track: center
101+
pad_column: 10
102+
on_click:
103+
- logger.log:
104+
level: INFO
105+
format: "Scene button clicked: ${scene3_name} (${scene3_entity_id})"
106+
- homeassistant.action:
107+
action: ${scene3_action_type}
108+
data:
109+
entity_id: ${scene3_entity_id}
110+
widgets:
111+
- label:
112+
text: "${scene3_icon}"
113+
text_align: CENTER
114+
text_color: $label_spinbtn_color
115+
text_font: $icon_font
116+
align: CENTER
117+
- label:
118+
text: "${scene3_name}"
119+
text_align: CENTER
120+
text_color: $label_spinbtn_color
121+
align: CENTER
122+
- button:
123+
id: btn_scene4
124+
width: 100%
125+
height: 60
126+
bg_color: $icon_temp_color
127+
pressed:
128+
bg_color: darkorange
129+
layout:
130+
type: flex
131+
flex_flow: row
132+
flex_align_main: center
133+
flex_align_cross: center
134+
flex_align_track: center
135+
pad_column: 10
136+
on_click:
137+
- logger.log:
138+
level: INFO
139+
format: "Scene button clicked: ${scene4_name} (${scene4_entity_id})"
140+
- homeassistant.action:
141+
action: ${scene4_action_type}
142+
data:
143+
entity_id: ${scene4_entity_id}
144+
widgets:
145+
- label:
146+
text: "${scene4_icon}"
147+
text_align: CENTER
148+
text_color: $label_spinbtn_color
149+
text_font: $icon_font
150+
align: CENTER
151+
- label:
152+
text: "${scene4_name}"
153+
text_align: CENTER
154+
text_color: $label_spinbtn_color
75155
align: CENTER

include/scripts.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ script:
1111
- delay: 2s
1212
- script.execute: hide_unwanted_rooms
1313
- script.execute: hide_unwanted_tabs
14+
- script.execute: hide_unwanted_scenes
1415
- script.execute: sync_all_window_contact_ui
1516

1617
- id: time_update
@@ -104,6 +105,30 @@ script:
104105
lv_obj_add_flag(button_tab_info, LV_OBJ_FLAG_HIDDEN);
105106
}
106107
108+
- id: hide_unwanted_scenes
109+
then:
110+
- lambda: |-
111+
std::string scene1_entity_id = "${scene1_entity_id}";
112+
if (scene1_entity_id.empty()) {
113+
ESP_LOGI("script", "Hiding scene1 button because scene1_entity_id is empty");
114+
lv_obj_add_flag(id(btn_scene1), LV_OBJ_FLAG_HIDDEN);
115+
}
116+
std::string scene2_entity_id = "${scene2_entity_id}";
117+
if (scene2_entity_id.empty()) {
118+
ESP_LOGI("script", "Hiding scene2 button because scene2_entity_id is empty");
119+
lv_obj_add_flag(id(btn_scene2), LV_OBJ_FLAG_HIDDEN);
120+
}
121+
std::string scene3_entity_id = "${scene3_entity_id}";
122+
if (scene3_entity_id.empty()) {
123+
ESP_LOGI("script", "Hiding scene3 button because scene3_entity_id is empty");
124+
lv_obj_add_flag(id(btn_scene3), LV_OBJ_FLAG_HIDDEN);
125+
}
126+
std::string scene4_entity_id = "${scene4_entity_id}";
127+
if (scene4_entity_id.empty()) {
128+
ESP_LOGI("script", "Hiding scene4 button because scene4_entity_id is empty");
129+
lv_obj_add_flag(id(btn_scene4), LV_OBJ_FLAG_HIDDEN);
130+
}
131+
107132
- id: sync_all_window_contact_ui
108133
then:
109134
- script.execute: sync_window_contact_ui_${room1_id}

main.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,28 @@ substitutions:
108108
temp_current_target_label: "Target Temperature"
109109

110110
# --------------------------------------------------------------------------
111-
# Scene configuration
111+
# Scene/Script configuration
112112
# --------------------------------------------------------------------------
113113

114+
scene1_action_type: "scene.turn_on"
114115
scene1_entity_id: "scene.scene1"
115116
scene1_name: "Scene 1"
116-
scene2_entity_id: "scene.scene2"
117+
scene1_icon: "$mdi_white_balance_sunny"
118+
119+
scene2_action_type: "scene.turn_on"
120+
scene2_entity_id: "" # leave empty to hide the whole button
117121
scene2_name: "Scene 2"
122+
scene2_icon: "$mdi_bed"
123+
124+
scene3_action_type: "scene.turn_on"
125+
scene3_entity_id: "" # leave empty to hide the whole button
126+
scene3_name: "Scene 3"
127+
scene3_icon: "$mdi_floor_lamp"
128+
129+
scene4_action_type: "scene.turn_on"
130+
scene4_entity_id: "" # leave empty to hide the whole button
131+
scene4_name: "Scene 4"
132+
scene4_icon: "$mdi_ceiling_light"
118133

119134
# --------------------------------------------------------------------------
120135
# Everything below this line is not really meant to be overridden by the user, but you can if you want to

0 commit comments

Comments
 (0)