-
Notifications
You must be signed in to change notification settings - Fork 0
/
esp32-2424s012-lvgl-powermeter-2.yaml
431 lines (401 loc) · 12.5 KB
/
esp32-2424s012-lvgl-powermeter-2.yaml
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
esphome:
name: esp32-2424s012-lvgl
friendly_name: esp32-2424s012-lvgl
esp32:
board: esp32-c3-devkitm-1
framework:
type: arduino
logger:
level: DEBUG
#hardware_uart: USB_SERIAL_JTAG
# Enable Home Assistant API
api:
encryption:
key:
ota:
password:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32-2424S012-Lvgl"
password:
captive_portal:
external_components:
- source:
type: git
url: https://github.com/clydebarrow/esphome
ref: fd15094c0860df23d532881df36cfd16c7da1091 #previous commit - wont be needed in the future
components: [ lvgl ]
globals:
- id: time_counter
type: int
initial_value: '0'
number:
- platform: template
initial_value: 0
id: counting_number
internal: True
min_value: -10
max_value: 10
step: 1
optimistic: True
debug:
update_interval: 5s
text_sensor:
- platform: debug
device:
name: "Device Info"
reset_reason:
name: "Reset Reason"
sensor:
- platform: debug
free:
name: "Heap Free"
block:
name: "Heap Max Block"
loop_time:
name: "Loop Time"
psram:
name: "Free PSRAM"
- platform: wifi_signal
# name: "WiFi Signal Sensor"
internal: True
id: wifi_signal_sensor
update_interval: 1s
- platform: uptime
id: uptime_counter
update_interval: 1s
accuracy_decimals: 0
on_raw_value:
then:
- light.turn_on:
id: back_light
brightness: 50%
- number.increment:
id: counting_number
cycle: True
- script.execute: update_display
- platform: homeassistant
id: ha_battery_power_net
entity_id: sensor.emporia_garage_total_power
#internal: True
on_value_range:
- above: 0.0
then:
- lvgl.label.update:
id: battery_charging_discharging
text_color: 0x00FF00
text: "charging"
- lvgl.label.update:
id: label_battery_power
text_color: 0x00FF00
- below: 0.0
then:
- lvgl.label.update:
id: battery_charging_discharging
text_color: 0xFF0000
text: "discharging"
- lvgl.label.update:
id: label_battery_power
text_color: 0xFF0000
spi:
clk_pin: GPIO6
mosi_pin: GPIO7
output:
- platform: ledc
pin:
number: GPIO3
id: backlight_output
light:
- platform: monochromatic
output: backlight_output
name: LCD Backlight
id: back_light
restore_mode: ALWAYS_ON
#default_transition_length: 0s
display:
- platform: ili9xxx
id: lcd_display
model: gc9a01a
data_rate: 80MHz
cs_pin: GPIO10
dc_pin: GPIO2
dimensions:
width: 240
height: 240
update_interval: never
auto_clear_enabled: false
#time:
# - platform: homeassistant
# id: time_comp
script:
- id: update_display
then:
- lvgl.indicator.line.update:
id: indicator_battery_power
value: !lambda return id(counting_number).state * 10; #multiply by 10 because LVGL meter only supports integers
- lvgl.label.update:
id: label_battery_power
text:
format: "%.1fkW"
args: [ 'id(ha_battery_power_net).state' ]
- lvgl.label.update:
id: label_battery_soc
text:
format: "%.1f%%"
args: [ 'id(counting_number).state' ]
- lvgl.label.update:
id: label_house_power
text:
format: "%.1fkW"
args: [ 'id(ha_battery_power_net).state' ]
- lvgl.label.update:
id: label_hydro_power
text:
format: "%.1fkW"
args: [ 'id(counting_number).state' ]
- lvgl.label.update:
id: label_solar_power
text:
format: "%.1fkW"
args: [ 'id(ha_battery_power_net).state' ]
- lvgl.label.update:
id: label_dump_load
text:
format: "%.1fkW"
args: [ 'id(ha_battery_power_net).state' ]
#- lvgl.img.update:
#id: img_power
#src: power_icon
#img_recolor: 0xFFF000 #mixes this color with the base image
#img_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
#bg_color: 0xFFFFFF
i2c:
sda: 4
scl: 5
id: i2c_touch
touchscreen:
platform: cst816
id: my_touchscreen
interrupt_pin: 0
reset_pin: 1
on_touch:
then:
lvgl.page.next:
image:
- file: mdi:car-battery
id: icon_battery
resize: 35x35
- file: mdi:home-lightning-bolt-outline
id: icon_house
resize: 35x35
- file: mdi:hydro-power
id: icon_hydro
resize: 35x35
- file: mdi:sun-wireless-outline
id: icon_solar
resize: 35x35
- file: mdi:resistor
id: icon_dump_load
resize: 35x35
- file: mdi:navigation
id: icon_pointer
resize: 40x20
# mdi:sun-wireless-outline
# mdi:solar-power
# mdi:battery-charging-outline
# mdi:battery-arrow-up-outline
# mdi:battery-arrow-down-outline
# mdi:lightning-bolt
lvgl:
touchscreens: my_touchscreen
log_level: INFO
color_depth: 16
bg_color: 0
border_width: 0
outline_width: 0
#shadow_width: 0
text_font: unscii_16
align: center
style_definitions:
- id: font_style
text_font: MONTSERRAT_28
#text_font: unscii_16
align: center
text_color: 0xFFFFFF
#bg_opa: cover
bg_opa: TRANSP
bg_color: 0
radius: 4
pad_all: 2
- id: details_style
text_font: MONTSERRAT_16
align: center
text_color: 0xFFFFFF
#bg_opa: cover
bg_opa: TRANSP
bg_color: 0
radius: 4
pad_all: 2
page_wrap: true
pages:
- id: main_page
widgets:
- obj: # Meter
height: 240 # needed to be explicitily defined for my round display to not have weird border line overlapping gauge
width: 240
align: center
bg_color: 0
#bg_opa: TRANSP
border_width: 0
outline_width: 0
#shadow_width: 0
pad_all: 0
scrollbar_mode: "off"
clip_corner: true
radius: 120
widgets:
- meter: # Gradient color arc
height: 100%
width: 100%
border_width: 0
outline_width: 0
align: center
bg_color: 0
#bg_opa: TRANSP
scales:
angle_range: 180 # sets the total angle to 180 = starts mid left and ends mid right
range_from: -100
range_to: 100
ticks:
count: 0
indicators:
- line:
id: indicator_battery_power
width: 8
color: 0xFFFFFF
r_mod: 20 #increase radius to maximize screen utilization
value: 0 # initial value
#- img:
# src: icon_house #doesnt seem to be fully implemented yet
# id: indicator_battery_power
# value: 0 # initial value
- arc:
color: 0xFF3000
r_mod: 20 #increase radius to maximize screen utilization
width: 26
start_value: -100
end_value: 0
- arc:
color: 0x00FF00
r_mod: 20
width: 26
start_value: 0
end_value: 100
- obj: # to erase middle part of meter indicator line
height: 180
width: 180
radius: 90 #should be half of the height, width to make a circle
align: center
border_width: 0
pad_all: 0
bg_color: 0
- label: # gauge lower and higher range indicators
styles: font_style
text_font: MONTSERRAT_18 # override font size
y: 10 #positive = lower
x: -102
text: "-10"
- label:
styles: font_style
text_font: MONTSERRAT_18 # override font size
y: 10
x: 102
text: "+10"
- label:
styles: font_style
id: label_battery_power
y: -70 #negative = higher
- label:
styles: font_style
id: battery_charging_discharging
hidden: true #turn off for now
y: -35
- label:
styles: font_style
#text_font: MONTSERRAT_32 # override font size
id: label_battery_soc
y: -38
x: 30 #positive = to the right of center
- label:
styles: font_style
id: label_house_power
text_color: 0xffffff
y: -6 #positive = below center
x: 30 #positive = to the right of center
- label:
styles: font_style
id: label_hydro_power
text_color: 0x1e90ff
y: 26 #positive = below center
x: 30 #positive = to the right of center
- label:
styles: font_style
id: label_solar_power
text_color: 0xffff00
y: 58 #positive = below center
x: 30 #positive = to the right of center
- label:
styles: font_style
id: label_dump_load
text_color: 0xff0000
y: 90 #positive = below center
x: 30 #positive = to the right of center
- img:
src: icon_battery
align: center
img_recolor: 0xffffff
img_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
y: -38 #positive = below center
x: -40 #negative = to the left
- img:
src: icon_house
align: center
img_recolor: 0xffffff
img_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
y: -6 #positive = below center
x: -40 #negative = to the left
- img:
src: icon_hydro
#id: img_hydro
align: center
img_recolor: 0x1e90ff
img_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
y: 26 #positive = below center
x: -40 #negative = to the left
- img:
src: icon_solar
#id: img_hydro
align: center
img_recolor: 0xffff00
img_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
y: 58 #positive = below center
x: -40 #negative = to the left
- img:
src: icon_dump_load
#id: img_hydro
align: center
img_recolor: 0xff0000
img_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
y: 90 #positive = below center
x: -40 #negative = to the left
- id: advanced
widgets:
- label:
styles: font_style
text_font: MONTSERRAT_18 # override font size
y: 0 #negative = higher
x: 0
text: "Settings Page"