-
Notifications
You must be signed in to change notification settings - Fork 0
/
desk-homething.yaml
456 lines (431 loc) · 11.5 KB
/
desk-homething.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
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
esphome:
name: "mega-homething"
friendly_name: mega-homething
includes:
- megadesk.h
on_boot:
- priority: -100
then:
- delay: 1s
- uart.write: "<C0.0."
- delay: 1s
- uart.write: "<R0.11."
- delay: 1s
- uart.write: "<R0.12."
esp32:
board: featheresp32
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
id: wifi_id
power_save_mode: HIGH
substitutions:
friendly_name: "mega homething"
log_level: "WARN"
# rotary_left_pin: "11"
# rotary_right_pin: "13"
# rotary_up_pin: "10"
# rotary_down_pin: "12"
rotary_select_pin: "17"
rotary_pin_a: "21"
rotary_pin_b: "22"
# screen_left_pin: "GPIO0"
# screen_right_pin: "GPIO14"
# battery_pin: "4"
external_components:
- source: github://landonr/homeThing
refresh: 0s
# - source:
# type: local
# path: ../homeThing/components
components: [homeThing, homeThingDisplayState, homeThingApp, homeThingAppNowPlaying ]
- source:
# type: local
# path: ../local_components/components
type: git
url: https://github.com/landonr/esphome-components
ref: main
refresh: 0s
components: [
homeassistant_component,
homeassistant_media_player,
media_player_source,
media_player_source_sonos,
media_player_source_spotify,
media_player_source_custom
]
# - source: github://pr#5214 # used to load images on compile
# components: [ image ]
- source: github://pr#5254 # used to load fonts on compile
components: [ font ]
packages:
# home_media_player: !include homeConfig/media_player.yaml
# home_switch: !include homeConfig/switch.yaml
# device_base: !include ../homeThing/common/device_base.yaml
# settings: !include ../homeThing/common/settings.yaml
# ipod_control_backlight: !include ../homeThing/common/ipod/lilygo_tdisplay_ipod_backlight.yaml
# ipod_control_battery: !include ../homeThing/common/ipod/lilygo_tdisplay_ip od_battery.yaml
# ipod_control_binary_sensor: !include ../homeThing/common/ipod/lilygo_tdisplay_ipod_binary_sensor.yaml
# ipod_control_rotary: !include ../homeThing/common/ipod/lilygo_tdisplay_ipod_rotary.yaml
# ipod_control_sleep: !include ../homeThing/common/ipod/lilygo_tdisplay_ipod_sleep.yaml
# home_media_player: !include homeConfig/media_player.yaml
# home_switch: !include homeConfig/switch.yaml
# fonts: !include ../homeThing/common/fonts-light.yaml
# icon_fonts: !include ../homeThing/common/icon_fonts.yaml
# debug: !include ../homeThing/common/debugging.yaml
remote_package:
url: https://github.com/landonr/homeThing
ref: main
files: [
common/device_base.yaml, # defines api, ota, free memory and uptime sensor
common/ipod/lilygo_tdisplay_ipod_backlight.yaml, # used for toggling backlight
common/ipod/lilygo_tdisplay_ipod_sleep.yaml, # required for device to sleep
common/fonts.yaml, # default font
common/icon_fonts.yaml, # material icons
# common/ipod/lilygo_tdisplay_ipod_battery.yaml, # used for battery percent
# common/ipod/lilygo_tdisplay_ipod_binary_sensor.yaml, # used for button controls
common/ipod/lilygo_tdisplay_ipod_rotary.yaml, # used for rotary controls
# common/settings.yaml, # settings screen
# common/images.yaml # boot screen image
]
refresh: 0s
image:
id: launch_image
file: "https://freight.cargo.site/t/original/i/35740c5dcf360e685ed3f8a27095b923c658ea3435692ecfa6b2036725a90776/desklogo.png"
resize: 168x60
type: TRANSPARENT_BINARY
switch:
- platform: restart
id: restart_switch
name: "${friendly_name} Restart"
media_player_source_sonos:
id: sonos
media_player:
- platform: homeassistant_media_player
name: Beam
entity_id: "media_player.beam"
id: media_player_beam
type: speaker
sources:
- id: sonos
type: sonos
commands:
name: "group all"
command:
- homeassistant.service:
service: script.sonos_group_all
color:
- id: my_primary_accent
red_int: 230
green_int: 90
blue_int: 2
light:
- platform: homeassistant_component
id: light_desk_lamp
entity_id: light.desk_lamp
name: Desk Lamp
homeassistant_media_player:
id: media_group_component
media_players:
- id: media_player_beam
type: speaker
homeThingAppNowPlaying:
id: now_playing
media_player_group: media_group_component
display: my_display
display_state: display_state_id
draw_bottom_menu: true
homeThingDisplayState:
id: display_state_id
colors:
accent_primary: my_primary_accent
font_small: small_font
font_medium: medium_font
font_large: large_font
font_large_heavy: large_font
font_material_large: material_font_large
font_material_small: material_font_small
homeThing:
id: homeThingMenu
apps:
- now_playing
boot:
launch_image: launch_image
settings:
sleep_after: 14400
display_timeout_while_charging: 30
mode: rotary
menu_rollback: true
backlight: backlight
display: my_display
display_state: display_state_id
header:
time_id: esptime
on_redraw:
then:
component.update: my_display
home_screen:
name: root
entities:
- type: number
id: megadesk_height
- type: button
id: desk_position_up
- type: button
id: desk_position_down
- type: command
name: "feed lil freak"
command:
- homeassistant.service:
service: button.press
data:
entity_id: "button.catfeeder_node_feed_single"
- id: restart_switch
type: switch
screens:
- name: Desk Screen
entities:
- type: cover
id: cover_megadesk
- type: number
id: megadesk_height
- type: button
id: desk_position_up
- type: button
id: desk_position_down
- id: light_desk_lamp
type: light
- type: command
name: "color lights"
command:
- homeassistant.service:
service: script.colors
- type: command
name: "hell lights"
command:
- homeassistant.service:
service: scene.turn_on
data:
entity_id: "scene.hell"
- type: command
name: "lights off"
command:
- homeassistant.service:
service: script.off_script
- type: button
id: desk_toggle_height_min
- type: button
id: desk_toggle_height_max
- type: button
id: desk_reboot
- type: button
id: desk_toggle_audio
spi:
clk_pin: GPIO18
mosi_pin: GPIO19
display:
- platform: st7789v
model: TTGO_TDisplay_135x240
id: my_display
cs_pin: GPIO5
dc_pin: GPIO16
reset_pin: GPIO23
backlight_pin: no
rotation: 90
update_interval: 10s
lambda: |-
id(homeThingMenu)->draw_menu_screen();
return;
cover:
- platform: homeassistant_component
entity_id: "cover.megadesk_cover"
name: "Megadesk"
id: cover_megadesk
uart:
id: uart_desk
baud_rate: 115200
rx_pin: GPIO15
tx_pin: GPIO2
debug:
direction: RX
dummy_receiver: false
after:
delimiter: "\n"
sequence:
- lambda: UARTDebug::log_string(direction, bytes);
binary_sensor:
- platform: gpio
pin:
number: GPIO0
inverted: true
mode:
input: true
pullup: true
name: "T-Display Button Input 0"
id: tdisplay_button_input_0
internal: true
on_press:
then:
media_player_group.select_next_player: media_group_component
- platform: gpio
pin:
number: GPIO35
inverted: true
name: "T-Display Button Input 1"
id: tdisplay_button_input_1
internal: true
on_click:
min_length: 5ms
max_length: 350ms
then:
homething_menu.option: homeThingMenu
on_multi_click:
- timing:
- ON for at least 0.5s
then:
homething_menu.home: homeThingMenu
- timing:
- ON for at least 3s
then:
- lambda: |-
id(sleep_toggle)->toggle();
- platform: gpio
internal: true
pin:
number: 3
inverted: true
mode:
input: true
pullup: true
id: sw1
on_click:
min_length: 5ms
max_length: 350ms
then:
homething_menu.select: homeThingMenu
on_multi_click:
- timing:
- ON for at least 0.5s
then:
homething_menu.option: homeThingMenu
sensor:
- platform: custom
lambda: |-
auto megadesk = new Megadesk(id(uart_desk));
App.register_component(megadesk);
return { megadesk->raw_height, megadesk->min_height, megadesk->max_height };
sensors:
- id: megadesk_raw
internal: true
on_value:
then:
- component.update: megadesk_height
- component.update: megadesk_height_raw
- name: "Megadesk Minimum Height"
- name: "Megadesk Maximum Height"
number:
- platform: template
internal: False
name: "Desk Height (cm)"
id: megadesk_height
min_value: 58.42
max_value: 118.745
step: 0.53
mode: slider
update_interval: never
unit_of_measurement: 'cm'
#NewValue = (((OldValue - OldMin) * (NewMax - NewMin)) / (OldMax - OldMin)) + NewMin
lambda: |-
return ((((id(megadesk_raw).state - 299) * (119.38 - 58.42)) / (6914 - 299)) + 58.42);
set_action:
- number.set:
id: megadesk_height_raw
value: !lambda "return int((((x - 58.42) * (6640 - 299)) / (119.38 - 58.42)) + 299);"
- platform: template
name: "Megadesk Height (raw)"
id: megadesk_height_raw
internal: true
min_value: 299
max_value: 6640
step: 1
mode: slider
update_interval: never
lambda: |-
return id(megadesk_raw).state;
set_action:
- uart.write: !lambda |-
char buf[20];
sprintf(buf, "<=%i,.", int(x));
std::string s = buf;
return std::vector<unsigned char>( s.begin(), s.end() );
button:
- platform: template
id: desk_position_up
internal: False
name: "Desk position up"
on_press:
then:
- uart.write: '<L0,3.'
- platform: template
id: desk_position_down
name: "Desk position down"
on_press:
then:
- uart.write: '<L0,2.'
- platform: template
name: "Desk get position"
on_press:
then:
- uart.write: '<C0,0.'
- platform: template
internal: False
name: "Desk position nudge up"
on_press:
then:
- uart.write: '<+200..'
- platform: template
name: "Desk position nudge down"
on_press:
then:
- uart.write: '<-200..'
- platform: template
name: "Toggle Minimum Desk Height"
id: desk_toggle_height_min
on_press:
then:
- uart.write: "<L0,11."
- uart.write: "<R0,11."
- platform: template
name: "Toggle Maximum Desk Height"
id: desk_toggle_height_max
on_press:
then:
- uart.write: "<L0,12."
- uart.write: "<R0,12."
- platform: template
name: "Recalibrate Desk"
on_press:
then:
- uart.write: "<L0,14."
- platform: template
name: "Reboot Megadesk"
id: desk_reboot
on_press:
then:
- uart.write: "<L0,15."
- platform: template
name: "Toggle Audio feedback"
id: desk_toggle_audio
on_press:
then:
- uart.write: "<L0,17."
- platform: template
name: "Toggle both-button mode"
on_press:
then:
- uart.write: "<L0,18."
interval:
- interval: 300s
then:
- uart.write: "<C0.0."