-
Notifications
You must be signed in to change notification settings - Fork 8
/
kauf-rgbs.yaml
852 lines (734 loc) · 27.8 KB
/
kauf-rgbs.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
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
# https://esphome.io/guides/configuration-types.html#substitutions
substitutions:
# substitutions can be changed here if you are using this file directly in the ESPHome dashboard. The better approach is
# to incorporate this file as a package using the following packages: configuration, and then overwrite these substitutions
# in your local yaml file by redefining them.
#
# packages:
# kauf.rgbsw: github://KaufHA/kauf-rgb-switch/kauf-rgbs.yaml
#
name: kauf-rgbsw # **** CHANGE DEVICE NAME TO SOMETHING UNIQUE PER DEVICE. RENAME YAML FILE TO SAME NAME. ****
# **** USE DASHES (-) INSTEAD OF SPACES OR UNDERSCORE (_). USE ONLY LOWER CASE LETTERS. ****
friendly_name: Kauf RGB Sw # **** CHANGE FRIENDLY NAME TO SOMETHING UNIQUE PER DEVICE ****
# https://esphome.io/components/esphome.html#esphome-creators-project
project_name: Kauf.RGBSw
project_ver_num: "1.361"
project_ver_let: y
sub_4m: "false"
sub_import_url: github://KaufHA/kauf-rgb-switch/kauf-rgbs.yaml
disable_entities: "true" # set to "false" to have all entities show up in Home Assistant automatically
disable_webserver: "false" # set to "true" to disable webserver listening on port 80.
wifi_ap_timeout: 2min # default to 2 minute timeout for yaml file as package.
# substitutions for scripts to execute based on button actions.
# the built-in automations for the button will still do everything they normally do even
# when these substitutions are redefined. Redefining these will not stop the ui switch from toggling.
# The button configuration select entity must be set to disabled to stop the button from toggling the ui switch.
# The button press duration sensor will also still update even with these redefined.
sub_on_press: script_do_nothing # executes right when button is pressed
sub_on_release: script_do_nothing # executes right when button is released
sub_on_double_press: script_do_nothing # executes when the button is double pressed
sub_on_single_press: script_do_nothing # executes when the button is single pressed only, not held or double pressed
sub_on_hold: script_do_nothing # executes when the button is held for a threshold amount of time
sub_on_release_without_hold: script_do_nothing # executes when the button is released after a press that is under the hold threshold.
sub_wifi_reset_script: script_wifi_reset # reset wifi credentials, overwrite to disable
# an extra script that, if running, will stop the switch from toggling on button release.
sub_toggle_check: script_do_nothing
# these will execute when ui_switch turns on and off, respectively. like on_press and on_release above, built-in
# automations still all run. Lights changing can be disabled through the config light entity effects. Relay
# can be disabled by selecting always on or always off in the configuration select entity. You can control the
# relay independently by toggling the select entity between always on and always off.
sub_on_turn_on: script_do_nothing
sub_on_turn_off: script_do_nothing
# allows status led to be blocked. Currently only used on factory image to eliminate blinking during factory test.
sub_blink_check: script_do_nothing
# modify transition length of lights
sub_transition_length: 333ms
# button press substitutions
sub_double_press_max_gap: 333ms
sub_hold_time: 750ms
sub_button_sensor_duration: 500ms
# substitutions to control hass entities with press combos
hass_entity_single_press_toggle: no.ne
hass_entity_double_press_toggle: no.ne
hass_entity_hold_toggle: no.ne
hass_entity_release_without_hold_toggle: no.ne
# substitutions to sync lights with hass entities instead of UI switch
hass_entity_control_small_light: no.ne
hass_entity_control_small_light_on_state: 'on'
hass_entity_control_small_light_off_state: 'off'
hass_entity_control_big_light: no.ne
hass_entity_control_big_light_on_state: 'on'
hass_entity_control_big_light_off_state: 'off'
# https://esphome.io/components/esp8266.html
esp8266:
board: esp01_1m
restore_from_flash: true
early_pin_init: false
start_free: 108
global_addr: global_forced_addr
# https://esphome.io/guides/automations.html#global-variables
globals:
- id: global_forced_addr
type: int
restore_value: no
initial_value: '12345'
- id: global_press_time
type: int
restore_value: no
initial_value: '0'
# https://esphome.io/components/esphome.html
esphome:
name: $name
project:
name: $project_name
version: $project_ver_num($project_ver_let)
on_boot:
then:
# set default values for template sensors, otherwise they are unknown.
- binary_sensor.template.publish:
id: button_single_press
state: OFF
- binary_sensor.template.publish:
id: button_double_press
state: OFF
- binary_sensor.template.publish:
id: button_hold
state: OFF
- binary_sensor.template.publish:
id: button_release_without_hold
state: OFF
- binary_sensor.template.publish:
id: sensor_4m
state: $sub_4m
min_version: 2024.10.0
# https://esphome.io/components/external_components.html
external_components:
- source:
type: git
url: https://github.com/KaufHA/common
ref: v2024.10.15
refresh: never
# https://esphome.io/components/wifi.html
wifi:
# **** ENTER WI-FI CREDENTIALS HERE, USING SECRETS.YAML RECOMMENDED ****
ssid: initial_ap # !secret wifi_ssid
password: asdfasdfasdfasdf # !secret wifi_password
# default is 20, 17 is recommended.
output_power: 17
forced_addr: 82
global_addr: global_forced_addr
ap:
ap_timeout: $wifi_ap_timeout
# https://esphome.io/components/captive_portal.html
captive_portal:
# https://esphome.io/components/logger.html
logger:
# https://esphome.io/components/api.html
api:
id: kauf_api
# https://esphome.io/components/ota.html
ota:
- platform: esphome
on_error:
then:
- button.press: restart_button
safe_mode:
# https://esphome.io/components/web_server.html
web_server:
disable: $disable_webserver
sensor_4m: $sub_4m
js_url: https://kaufha.com/v2/www.js
# https://esphome.io/components/binary_sensor/index.html
binary_sensor:
# https://esphome.io/components/binary_sensor/gpio.html
- platform: gpio
id: main_button
name: $friendly_name Button
pin:
number: GPIO13
mode:
input: true
pullup: true
inverted: true
on_press:
then:
# store press time in ms
- lambda: |-
// store time of press and clear duration sensor
id(global_press_time) = millis();
id(sensor_press_duration).publish_state(0);
// toggle if button is configured to toggle on press
if (id(select_button).state == "Toggle on Press") {
id(ui_switch).toggle(); }
- script.execute: $sub_on_press
on_release:
then:
- lambda: |-
// set press duration sensor
id(sensor_press_duration).publish_state(millis() - id(global_press_time));
// toggle if configured to toggle on release and toggle check script is no longer running
if ( (id(select_button).state == "Toggle on Release") && !id($sub_toggle_check).is_running() ) {
id(ui_switch).toggle(); }
- script.execute: $sub_on_release
on_multi_click:
# definition for single press
- timing:
- ON for at most $sub_hold_time
- OFF for at least $sub_double_press_max_gap
invalid_cooldown: 1500ms
then:
- lambda: |-
id(button_single_press).publish_state(true);
// toggle if button is configured to toggle on single press
if (id(select_button).state == "Toggle on Single Press") {
id(ui_switch).toggle(); }
id(script_hass_toggle_single_press).execute();
id($sub_on_single_press).execute();
# definition for double press
- timing:
- ON for at most $sub_hold_time
- OFF for at most $sub_double_press_max_gap
- ON for at least 1ms
then:
- lambda: |-
id(button_double_press).publish_state(true);
// toggle if button is configured to toggle on double press
if (id(select_button).state == "Toggle on Double Press") {
id(ui_switch).toggle(); }
id(script_hass_toggle_double_press).execute();
id($sub_on_double_press).execute();
# definition for holding
- timing:
- ON for at least $sub_hold_time
then:
- lambda: |-
id(button_hold).publish_state(true);
// toggle if button is configured to toggle on hold
if (id(select_button).state == "Toggle on Hold") {
id(ui_switch).toggle(); }
id(script_hass_toggle_hold).execute();
id($sub_on_hold).execute();
# definition for release without hold
- timing:
- ON for at most $sub_hold_time
then:
- lambda: |-
id(button_release_without_hold).publish_state(true);
// toggle if button is configured to toggle on release without hold
if (id(select_button).state == "Toggle on Release Without Hold") {
id(ui_switch).toggle(); }
id(script_hass_toggle_release_without_hold).execute();
id($sub_on_release_without_hold).execute();
# definition for 30s hold to clear credentials
- timing:
- ON for at least 30s
then:
- script.execute: $sub_wifi_reset_script
- platform: template
name: $friendly_name Single Press
id: button_single_press
on_press:
- delay: $sub_button_sensor_duration
- binary_sensor.template.publish:
id: button_single_press
state: OFF
- platform: template
name: $friendly_name Double Press
id: button_double_press
on_press:
- delay: $sub_button_sensor_duration
- binary_sensor.template.publish:
id: button_double_press
state: OFF
- platform: template
name: $friendly_name Hold
id: button_hold
on_press:
- wait_until:
binary_sensor.is_off: main_button
- binary_sensor.template.publish:
id: button_hold
state: OFF
- platform: template
name: $friendly_name Release Without Hold
id: button_release_without_hold
on_press:
- delay: $sub_button_sensor_duration
- binary_sensor.template.publish:
id: button_release_without_hold
state: OFF
- platform: template
name: $friendly_name 4MiB
id: sensor_4m
disabled_by_default: $disable_entities
# https://esphome.io/components/switch/index.html
switch:
- platform: gpio
id: relay
pin: GPIO15
forced_hash: 3551080420
forced_addr: 0
global_addr: global_forced_addr
restore_mode: RESTORE_DEFAULT_OFF
# https://esphome.io/components/switch/template.html
- platform: template
name: $friendly_name
id: ui_switch
optimistic: true
forced_hash: 4098969537
forced_addr: 2
global_addr: global_forced_addr
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
then:
- lambda: |-
// Waiting for select entity to have a state keeps the relay from toggling during boot.
// Probably not needed after template switch priority was lowered, but keeping the check
// in case they do the same for template selects later.
if ( id(select_relay).has_state() && ( id(select_relay).state != "Always Off" ) ) {
id(relay).turn_on(); }
- script.execute: copy_vals
- script.execute: script_save_changes
- script.execute: $sub_on_turn_on
on_turn_off:
then:
- lambda: |-
// Waiting for select entity to have a state keeps the relay from toggling during boot.
// Probably not needed after template switch priority was lowered, but keeping the check
// in case they do the same for template selects later.
if ( id(select_relay).has_state() && ( id(select_relay).state != "Always On" ) ) {
id(relay).turn_off(); }
- script.execute: copy_vals
- script.execute: script_save_changes
- script.execute: $sub_on_turn_off
- platform: template
id: switch_no_hass
name: $friendly_name No HASS
optimistic: true
entity_category: config
disabled_by_default: $disable_entities
icon: mdi:toggle-switch-off-outline
forced_hash: 1672474889
forced_addr: 4
global_addr: global_forced_addr
restore_mode: RESTORE_DEFAULT_ON
on_turn_on:
- lambda: |-
id(kauf_api)->set_reboot_timeout(0); // 0 disables auto rebooting and also new status led blinking. doesn't stop current status led blinking
id(kauf_api)->status_clear_warning(); // stops current status led blinking, timeout 0 keeps it from restarting
- script.execute: script_save_changes
on_turn_off:
- lambda: id(kauf_api)->set_reboot_timeout(900000);
- script.execute: script_save_changes
# PWM outputs for each LED channel
# https://esphome.io/components/output/esp8266_pwm.html
output:
# small light pwm
- platform: esp8266_pwm
pin: GPIO0
frequency: 250 Hz
id: pwm1_red
inverted: true
- platform: esp8266_pwm
pin: GPIO12
frequency: 250 Hz
id: pwm1_green
inverted: true
- platform: esp8266_pwm
pin: GPIO2
frequency: 250 Hz
id: pwm1_blue
inverted: true
# big light pwm
- platform: esp8266_pwm
pin: GPIO14
frequency: 250 Hz
id: pwm2_red
- platform: esp8266_pwm
pin: GPIO5
frequency: 250 Hz
id: pwm2_green
max_power: .4
- platform: esp8266_pwm
pin: GPIO4
frequency: 250 Hz
id: pwm2_blue
max_power: .35
# Bit bucket output to connect configuration lights to.
# https://esphome.io/components/output/template.html
- platform: template
id: bit_bucket
type: float
write_action:
- script.execute: script_do_nothing
# https://esphome.io/components/light/index.html
# https://esphome.io/components/light/rgb.html
light:
- platform: rgb
name: $friendly_name Small Light
id: small_light
red: pwm1_red
green: pwm1_green
blue: pwm1_blue
default_transition_length: $sub_transition_length
forced_hash: 3940173824
forced_addr: 10
global_addr: global_forced_addr
restore_mode: RESTORE_DEFAULT_ON
- platform: rgb
name: $friendly_name Small Off Value
id: small_light_off
red: bit_bucket
green: bit_bucket
blue: bit_bucket
entity_category: config
default_transition_length: 0s
forced_hash: 1452166609
forced_addr: 22
global_addr: global_forced_addr
restore_mode: RESTORE_DEFAULT_ON
effects:
- lambda:
name: Disabled
update_interval: never
lambda: return;
on_state:
then:
- script.execute: copy_vals
- platform: rgb
name: $friendly_name Small On Value
id: small_light_on
red: bit_bucket
green: bit_bucket
blue: bit_bucket
entity_category: config
default_transition_length: 0s
forced_hash: 1530533365
forced_addr: 34
global_addr: global_forced_addr
restore_mode: RESTORE_DEFAULT_ON
effects:
- lambda:
name: Disabled
update_interval: never
lambda: return;
on_state:
then:
- script.execute: copy_vals
- platform: rgb
name: $friendly_name Big Light
id: big_light
red: pwm2_red
green: pwm2_green
blue: pwm2_blue
default_transition_length: $sub_transition_length
forced_hash: 3403140939
forced_addr: 46
global_addr: global_forced_addr
restore_mode: RESTORE_DEFAULT_ON
- platform: rgb
name: $friendly_name Big Off Value
id: big_light_off
red: bit_bucket
green: bit_bucket
blue: bit_bucket
entity_category: config
default_transition_length: 0s
forced_hash: 730390778
forced_addr: 58
global_addr: global_forced_addr
restore_mode: RESTORE_DEFAULT_ON
effects:
- lambda:
name: Disabled
update_interval: never
lambda: return;
on_state:
then:
- script.execute: copy_vals
- platform: rgb
name: $friendly_name Big On Value
id: big_light_on
red: bit_bucket
green: bit_bucket
blue: bit_bucket
entity_category: config
default_transition_length: 0s
forced_hash: 1638474020
forced_addr: 70
global_addr: global_forced_addr
restore_mode: RESTORE_DEFAULT_ON
effects:
- lambda:
name: Disabled
update_interval: never
lambda: return;
on_state:
then:
- script.execute: copy_vals
# https://esphome.io/components/select/index.html
# https://esphome.io/components/select/template.html
select:
- platform: template
name: $friendly_name Relay Config
id: select_relay
optimistic: true
options:
- Switched
- Always On
- Always Off
initial_option: Switched
restore_value: true
entity_category: config
icon: mdi:progress-question
forced_hash: 3803457832
forced_addr: 8
global_addr: global_forced_addr
on_value:
then:
- lambda: |-
if ( x == "Always On" ) { id(relay).turn_on(); }
else if ( x == "Always Off" ) { id(relay).turn_off(); }
else if ( id(ui_switch).state ) { id(relay).turn_on(); }
else /* ui_switch off */ { id(relay).turn_off(); }
- script.execute: script_save_changes
- platform: template
name: $friendly_name Button Config
id: select_button
optimistic: true
options:
- Toggle on Press
- Disabled
- Toggle on Release
- Toggle on Single Press
- Toggle on Double Press
- Toggle on Hold
- Toggle on Release Without Hold
initial_option: Toggle on Press
restore_value: true
entity_category: config
icon: mdi:toggle-switch-off-outline
forced_hash: 1841528035
forced_addr: 6
global_addr: global_forced_addr
on_value:
- script.execute: script_save_changes
# https://esphome.io/guides/automations.html#script-component
script:
- id: blink_status_led
mode: queued
then:
# allows the blinking to be blocked if desired by overwriting script substitution
- script.execute: $sub_blink_check
# set LED red for ? ms then off for ? ms, then repeat
- lambda: |-
auto call = id(small_light).turn_on();
call.set_brightness(1.0f);
call.set_transition_length(0);
call.set_rgb(1.0f, 0.0f, 0.0f);
call.perform();
- delay: 350ms
- lambda: |-
auto call = id(small_light).turn_off();
call.set_transition_length(0);
call.perform();
- delay: 1150ms
- if:
condition:
- lambda: return ( ( (App.get_app_state() & STATUS_LED_ERROR) != 0u) || ((App.get_app_state() & STATUS_LED_WARNING) != 0u) );
then:
- script.execute: blink_status_led # repeat as long as api not connected
else:
- script.execute: copy_vals # restore set colors if api is connected
# blink LED forever. Used when button is held to re-enable AP. Stops blinking because plug restarts.
- id: blink_led
mode: queued
then:
- light.toggle: small_light
- delay: 333ms
- script.execute: blink_led
- id: script_do_nothing
then:
- lambda: return;
- id: script_save_changes
mode: restart
then:
- delay: 3s
- lambda: global_preferences->sync();
- id: script_wifi_reset
mode: single
then:
- logger.log: "------------------->>>>>>>>>>>>>>>>> HELD BUTTON 30 SECONDS, FORCING AP"
# overwrite software defined credentials to force ap to turn on.
- lambda: wifi::global_wifi_component->save_wifi_sta("initial_ap","asdfasdfasdfasdf");
# blink LED for 10s then restart to get captive portal to turn on.
- script.execute: blink_led
- delay: 10s
- button.press: restart_button
# script to copy values from config lights to real lights per switch state
- id: copy_vals
mode: restart
then:
- lambda: |-
// (small) switch is on, copy on values
if ( ( id(ui_switch).state && (strcmp("$hass_entity_control_small_light","no.ne") == 0 ) && (small_light_on->get_effect_name() != "Disabled")) ||
((id(hass_small_light_state).state == "$hass_entity_control_small_light_on_state") && (strcmp("$hass_entity_control_small_light","no.ne") != 0 ) && (small_light_on->get_effect_name() != "Disabled")) ) {
auto call = id(small_light).make_call();
call.set_state(small_light_on->current_values.is_on());
call.set_brightness(small_light_on->current_values.get_brightness());
call.set_rgb(small_light_on->current_values.get_red(),
small_light_on->current_values.get_green(),
small_light_on->current_values.get_blue());
call.perform();
}
// (small) switch is off, copy off values
else if ( (!id(ui_switch).state && (strcmp("$hass_entity_control_small_light","no.ne") == 0 ) && (small_light_on->get_effect_name() != "Disabled")) ||
((id(hass_small_light_state).state == "$hass_entity_control_small_light_off_state") && (strcmp("$hass_entity_control_small_light","no.ne") != 0 ) && (small_light_on->get_effect_name() != "Disabled")) ) {
auto call = id(small_light).make_call();
call.set_state(small_light_off->current_values.is_on());
call.set_brightness(small_light_off->current_values.get_brightness());
call.set_rgb(small_light_off->current_values.get_red(),
small_light_off->current_values.get_green(),
small_light_off->current_values.get_blue());
call.perform();
}
// (big) switch is on, copy on values
if ( ( id(ui_switch).state && (strcmp("$hass_entity_control_big_light","no.ne") == 0 ) && (big_light_on->get_effect_name() != "Disabled")) ||
((id(hass_big_light_state).state == "$hass_entity_control_big_light_on_state") && (strcmp("$hass_entity_control_big_light","no.ne") != 0 ) && (big_light_on->get_effect_name() != "Disabled")) ) {
auto call = id(big_light).make_call();
call.set_state(big_light_on->current_values.is_on());
call.set_brightness(big_light_on->current_values.get_brightness());
call.set_rgb(big_light_on->current_values.get_red(),
big_light_on->current_values.get_green(),
big_light_on->current_values.get_blue());
call.perform();
}
else if ( (!id(ui_switch).state && (strcmp("$hass_entity_control_big_light","no.ne") == 0 ) && (big_light_on->get_effect_name() != "Disabled")) ||
((id(hass_big_light_state).state == "$hass_entity_control_big_light_on_state") && (strcmp("$hass_entity_control_big_light","no.ne") != 0 ) && (big_light_on->get_effect_name() != "Disabled")) ) {
auto call = id(big_light).make_call();
call.set_state(big_light_off->current_values.is_on());
call.set_brightness(big_light_off->current_values.get_brightness());
call.set_rgb(big_light_off->current_values.get_red(),
big_light_off->current_values.get_green(),
big_light_off->current_values.get_blue());
call.perform();
}
- id: script_hass_toggle_single_press
then:
if:
condition: # toggle if single press hass entity is set
lambda: return (strcmp("$hass_entity_single_press_toggle","no.ne") != 0 );
then:
homeassistant.service:
service: homeassistant.toggle
data:
entity_id: $hass_entity_single_press_toggle
- id: script_hass_toggle_double_press
then:
if:
condition: # toggle if double press hass entity is set
lambda: return (strcmp("$hass_entity_double_press_toggle","no.ne") != 0 );
then:
homeassistant.service:
service: homeassistant.toggle
data:
entity_id: $hass_entity_double_press_toggle
- id: script_hass_toggle_hold
then:
if:
condition: # toggle if hold hass entity is set
lambda: return (strcmp("$hass_entity_hold_toggle","no.ne") != 0 );
then:
homeassistant.service:
service: homeassistant.toggle
data:
entity_id: $hass_entity_hold_toggle
- id: script_hass_toggle_release_without_hold
then:
if:
condition: # toggle if release without hold hass entity is set
lambda: return (strcmp("$hass_entity_release_without_hold_toggle","no.ne") != 0 );
then:
homeassistant.service:
service: homeassistant.toggle
data:
entity_id: $hass_entity_release_without_hold_toggle
# https://esphome.io/components/button/index.html
button:
# https://esphome.io/components/button/restart.html
- platform: restart
id: restart_button
name: $friendly_name Restart Firmware
entity_category: diagnostic
disabled_by_default: $disable_entities
# https://esphome.io/components/button/template.html
- platform: template
name: $friendly_name Restore Lights
entity_category: diagnostic
disabled_by_default: $disable_entities
on_press:
- script.execute: copy_vals
# Send IP Address to HA
# https://esphome.io/components/text_sensor/wifi_info.html
text_sensor:
- platform: wifi_info
ip_address:
name: $friendly_name IP Address
entity_category: diagnostic
disabled_by_default: $disable_entities
- platform: homeassistant
id: hass_small_light_state
entity_id: $hass_entity_control_small_light
on_value:
- delay: 1ms
- script.execute: copy_vals
- platform: homeassistant
id: hass_big_light_state
entity_id: $hass_entity_control_big_light
on_value:
- delay: 1ms
- script.execute: copy_vals
# https://esphome.io/components/sensor/index.html
sensor:
# https://esphome.io/components/sensor/template.html
- platform: template
name: $friendly_name Button Press Duration
id: sensor_press_duration
entity_category: diagnostic
disabled_by_default: $disable_entities
unit_of_measurement: ms
icon: mdi:timer-outline
# https://esphome.io/components/sensor/uptime.html
- platform: uptime
name: $friendly_name Uptime
update_interval: 60s
entity_category: diagnostic
disabled_by_default: $disable_entities
# emulate status_led
# https://esphome.io/guides/automations.html#interval-component
interval:
- interval: 5s
then:
if:
condition:
- lambda: return ( ( (App.get_app_state() & STATUS_LED_ERROR) != 0u) || ((App.get_app_state() & STATUS_LED_WARNING) != 0u) );
then:
- if:
condition:
not:
- script.is_running: blink_status_led
then:
- script.execute: blink_status_led
# Current reserved flash memory:
# 00- 01: Relay Switch
# 02- 03: UI Switch
# 04- 05: No HASS Switch
# 06- 07: Button Config Select
# 08- 09: Relay Config Select
# 10- 21: Small Light
# 22- 33: Small Off Value Light
# 34- 45: Small On Value Light
# 46- 57: Big Light
# 58- 69: Big Off Value Light
# 70- 81: Big On Value Light
# 82-107: Wi-Fi Credentials