-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript
218 lines (183 loc) · 6.74 KB
/
script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
- id: time_update
then:
- lvgl.label.update:
id: display_time
text: !lambda |-
static char time_buf[16];
auto now = id(esptime).now();
snprintf(time_buf, sizeof(time_buf), "%02d:%02d", now.hour, now.minute);
return time_buf;
#- lvgl.label.update:
#id: display_time_blank
#text: !lambda |-
#static char time_buf[16];
#auto now = id(esptime).now();
#snprintf(time_buf, sizeof(time_buf), "%02d:%02d", now.hour, now.minute);
#return time_buf;
- lvgl.label.update:
id: display_time_blank1
text: !lambda |-
static char time_buf[16];
auto now = id(esptime).now();
snprintf(time_buf, sizeof(time_buf), "%02d:%02d", now.hour, now.minute);
return time_buf;
- lvgl.label.update:
id: display_date
text: !lambda |-
static const char * const mon_names[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
static char date_buf[14];
auto now = id(esptime).now();
snprintf(date_buf, sizeof(date_buf), "%02d %s", now.day_of_month, mon_names[now.month - 1]);
return date_buf;
- lvgl.label.update:
id: display_day
text: !lambda |-
static const char * const day_names[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
return day_names[id(esptime).now().day_of_week-1];
- id: tvoc_state
then:
- lvgl.label.update:
id: tvoc_sensor
text: !lambda |-
std::string classification = id(sensor_tvoc).state.c_str();
if (id(language_select)) {
if (classification == "Excellent") {
return "Exellent";
} else if (classification == "Good") {
return "Bon";
} else if (classification == "Lightly polluted") {
return "Pollution peu";
} else if (classification == "Moderately polluted") {
return "";
} else if (classification == "Heavily polluted") {
return "Fortement pollué";
} else if (classification == "Severely polluted") {
return "Fortement pollué";
} else if (classification == "Extremely polluted") {
return "Extrêmement pollué";
} else if (classification == "unknown") {
return "Unconnue";
}
}
return classification.c_str();
- id: saver_enabled
then:
- if:
condition:
switch.is_on: s_saver
then:
- lambda: id(display_backlight).turn_on().set_brightness(id(s_default_brightness).state /100).perform();
- delay: !lambda return id(s_saver_delay).state * 1000;
- lambda: id(display_backlight).turn_on().set_brightness(id(s_saver_brightness).state /100).perform();
- lvgl.page.show: page_screensaver
- component.update: my_display
- if:
condition:
switch.is_on: s_saver_mode
then:
- delay: !lambda return id(s_saver_blank_delay).state * 1000;
- light.turn_off: display_backlight
- id: saver_enabled_manual
then:
- if:
condition:
- switch.is_on: s_saver
then:
- lambda: id(display_backlight).turn_on().set_brightness(id(s_saver_brightness).state /100).perform();
- lvgl.page.show: page_screensaver
- component.update: my_display
- if:
condition:
- switch.is_on: s_saver_mode
then:
- delay: !lambda return id(s_saver_blank_delay).state * 1000;
- light.turn_off: display_backlight
- component.update: my_display
mode: restart
- id: timer_started
then:
while:
condition:
switch.is_on: timer_ringing
then:
- media_player.play_media:
media_url: 'http://homeassistant.local:8123/local/sounds/timer_finished.mp3'
- delay: 1s
- id : timer_started_external
then:
while:
condition:
switch.is_on: timer_ringing
then:
- homeassistant.service:
service: media_player.play_media
data:
entity_id: media_player.${external_media_player}
media_content_id: 'http://homeassistant.local:8123/local/sounds/timer_finished.mp3'
media_content_type: music
- delay: 1700ms
- id: timer_ending
then:
- wait_until:
- lambda: return (id(time_remaining_0).state == "0:00:10");
- lvgl.page.show: page_time_remaining
- component.update: my_display
- id: move_time_label
then:
- lambda: |-
static int16_t x_pos = 10;
static int16_t y_pos = 10;
static int16_t x_velocity = 2;
static int16_t y_velocity = 2;
// Get screen dimensions
int16_t screen_width = 320;
int16_t screen_height = 240;
// Get label dimensions
int16_t label_width = lv_obj_get_width(id(display_time_blank1));
int16_t label_height = lv_obj_get_height(id(display_time_blank1));
// Update X position
x_pos += x_velocity;
if (x_pos <= 0 || x_pos + label_width >= screen_width) {
x_velocity = -x_velocity; // Reverse direction if hitting the edges
}
// Update Y position
y_pos += y_velocity;
if (y_pos <= 0 || y_pos + label_height >= screen_height) {
y_velocity = -y_velocity; // Reverse direction if hitting the edges
}
// Set new position
lv_obj_set_x(id(display_time_blank1), x_pos);
lv_obj_set_y(id(display_time_blank1), y_pos);
- id: set_volume
then:
# Set the media player volume using a lambda
- media_player.volume_set:
id: adf_media_player # Ensure the correct media player ID is used
volume: !lambda |-
return 0.5 + id(speaker_volume) * 0.05;
- id: show_page_boot
then:
- delay: 1s
- lvgl.widget.hide: boot_screen
- lvgl.page.show: page_spin
- delay: 3s
- lvgl.page.show: page_home
- lvgl.roller.update:
id: display_timeout_roller1
- lvgl.roller.update:
id: display_timeout_roller2
- if:
condition:
switch.is_on: output_audio
then:
media_player.volume_set:
id: adf_media_player
volume: 0
#- id: play_radio_4
# mode: single
#then:
#- media_player.play_media:
#id: s3_player
#media_content_id: "media-source://radio_browser/d470fda1-753b-4037-973f-6f1bd27eb42f"
#media_content_type: "audio/aac"
#- logger.log: "Joue BBC Radio 4"