· 3 months ago · Jun 20, 2025, 01:25 AM
1captive_portal:
2
3
4web_server:
5 port: 80
6 version: 3
7 auth:
8 username: "Justin"
9 password: "Olive2014"
10
11################ Guest Mode Timers #############
12#
13# Use both Start and Stop timers to specify which times of the day are allowed for the guest.
14#
15# Example: Start Time 08:00:00Am - Stop Time 05:00:00Pm Will Only Allow Access between Those Times (9 Hours)
16
17datetime:
18# - platform: template
19# id: guest_mode1_start
20# type: time
21# name: "Guest Mode 1 Start"
22# optimistic: yes
23# initial_value: "08:00:00"
24# restore_value: true
25# on_time:
26# - if:
27# condition:
28# - switch.is_on: guest1_active
29# then:
30# - switch.turn_on: guest1_active
31
32 # - platform: template
33 # id: guest_mode1_stop
34 # type: time
35 # name: "Guest Mode 1 Stop"
36 # optimistic: yes
37 # initial_value: "05:00:00"
38 # restore_value: true
39 # on_time:
40 # - if:
41 # condition:
42 # and:
43 # - text_sensor.state:
44 # id: ha_cover_state
45 # state: open
46#
47# - switch.is_on: guest1_active
48# then:
49# - button.press: transmit_rf
50# else:
51# - switch.turn_off: guest1_active
52
53 - platform: template
54 id: guest1_start_date
55 type: datetime
56 name: "Guest 1 Start"
57 optimistic: yes
58# initial_value: lambda: auto id(homeassistant_time).state_as_esptime();
59 restore_value: false
60
61 - platform: template
62 id: guest1_stop_date
63 type: datetime
64 name: "Guest 1 Stop"
65 optimistic: true
66 # initial_value: lambda: |-
67 # return auto time = id(homeassistant_time).now();
68
69 restore_value: true
70
71# - platform: template
72# id: guest_mode2_start
73# type: time
74# name: "Guest 2 Start"
75# optimistic: yes
76# initial_value: "08:00:00"
77# restore_value: true
78# on_time:
79# - if:
80# condition:
81# - switch.is_on: guest2_active
82# then:
83# - switch.turn_on: guest2_active
84
85
86
87
88
89
90
91number:
92 - platform: template
93 name: "Guest 1 Code"
94 id: guest1_keypad_code
95 min_value: 0
96 max_value: 9999
97 step: 1
98 mode: box
99 restore_value: false
100 optimistic: true
101 on_value:
102 if:
103 ## Guest1 Switch MUST be ON in order to set a Pin Code.
104 condition:
105 - switch.is_on: guest1_active
106 then:
107 - globals.set:
108 id: temp_code
109 value: !lambda 'return float(x);'
110
111 - text_sensor.template.publish:
112 id: guest_1_pin
113 state: !lambda 'return id(guest1_keypad_code).state;'
114
115## Guest 2... This is only commented out because I likely wont use it and it's to de-clutter things while ## this is still a work in progress. You can make as many Guest modes as you want/need though. You just need ## to also add the related sensors and entites necessarry for each additional one.
116
117# - platform: template
118# name: "Guest 2 Code"
119# id: guest2_keypad_code
120# min_value: 0
121# max_value: 9999
122# step: 1
123# mode: box
124# restore_value: false
125# optimistic: true
126# on_value:
127# if:
128# condition:
129# - switch.is_on: guest2_active
130# then:
131# - globals.set:
132# id: temp_code
133# value: !lambda 'return float(x);'
134
135
136
137
138
139sun:
140 latitude: 40.173568
141 longitude: -86.0225536
142 on_sunset:
143
144 - light.turn_on:
145 id: barn_overhead_led
146 brightness: 50%
147 white: 100%
148 - switch.turn_on:
149 id: outside_barn_lights
150
151
152 on_sunrise:
153 - light.turn_off:
154 id: barn_overhead_led
155
156 - switch.turn_off:
157 id: outside_barn_lights
158
159## Where do you want the ESP to sync up with for keeping the Time accurate. I use HA but, there are others.
160time:
161 - platform: homeassistant
162 id: homeassistant_time
163
164## Remote Transmitter is unrelated and it's more for my specific setup. My thinking was to use it as a backup ## method to toggle overhead door because my Keypad isn't physically wired to the overhead door motor and ## this is to send an RF_Switch signal to my esp board that is wired to the motor and is incase the WiFi goes ## down and Keypad can't communicate with door motor. This is my backup 433mhz P2P option. ##
165
166remote_transmitter:
167 pin: 4
168 carrier_duty_percent: 100%
169
170#### THIS IS FROM ME TESTING/PLAYING WITH DOING SOME RF433 MHZ STUFF MENTIONED ABOVE AND IS NOT NEEDED ###
171## THIS IS HOW YOU CAN SEND INDIVIDUAL DIGITS OR A STRING OF THEM(PIN CODE) TO YOUR KEYPAD FROM A DIFFERENT ESP BOARD FYI..... IT ISN'T USED FOR THIS KEYPAD UI AND CAN BE REMOVED OR COMMENTED OUT.
172
173button:
174
175 - platform: template
176 name: "test send number"
177 id: test_keysend
178 on_press:
179 then:
180 - lambda: |-
181 id(pincode_reader).send_key('4');
182 - delay: 250ms
183
184 - lambda: |-
185 id(pincode_reader).send_key('3');
186 - delay: 250ms
187
188 - lambda: |-
189 id(pincode_reader).send_key('2');
190 - delay: 250ms
191
192 - lambda: |-
193 id(pincode_reader).send_key('1');
194 - delay: 50ms
195
196 - lambda: |-
197 id(pincode_reader).send_key('#');
198
199 - platform: template
200 id: transmit_rf
201 name: "Overhead Door RF"
202 on_press:
203 then:
204 - remote_transmitter.transmit_rc_switch_raw:
205 code: '00101001100111110101101' #### Test Code Only '00100100100001' #######
206 protocol: 1
207 repeat:
208 times: 1
209 wait_time: 0ms
210
211
212### END OF RF 433 MHZ TESTING STUFF ##################
213
214 - platform: restart
215 id: keypad_restart
216 name: "Keypad Restart"
217
218 - platform: safe_mode
219 id: keypad_safemode
220 name: "Keypad (Safe Mode)"
221
222
223
224
225
226
227switch:
228
229 - platform: template
230 id: guest1_active
231 name: "Guest Mode 1"
232 optimistic: True
233 restore_mode: DISABLED
234 on_turn_off:
235 then:
236 - number.set:
237 id: guest1_keypad_code
238 value: 0
239
240
241# - platform: template
242# id: guest2_active
243# name: "Guest Mode 2"
244# optimistic: True
245# restore_mode: DISABLED
246# on_turn_off:
247# then:
248# - number.set:
249# id: guest2_keypad_code
250# value: 0
251
252
253## THIS IMPORTS MY DOOR COVER FROM HA SINCE IT'S ON A DIFFERNT ESP BOARD.
254 - platform: template
255 id: ovrhead
256 optimistic: true
257 on_turn_on:
258 - homeassistant.service:
259 service: switch.toggle
260 data:
261 entity_id: switch.overhead_door_rf_barn_overhead_door
262
263
264## SWITCH TO TURN ON THE INTERIOR LIGHTS FOR GARAGE. ##
265 - platform: gpio
266 pin:
267 number: 25
268 inverted: False
269 name: 'Barn Door Lights'
270 id: outside_barn_lights
271 restore_mode: RESTORE_DEFAULT_OFF
272
273 - platform: gpio
274 name: "Barn Switch 1"
275 id: barn_switch1
276 pin:
277 number: 15
278 inverted: false
279 device_class: switch
280
281
282
283 - platform: gpio
284 name: "Barn Switch 2"
285 id: barn_switch2
286 pin:
287 number: 5
288 inverted: false
289 device_class: switch
290
291
292## THIS JUST COMBINES LIGHT SWITCH 1&2 INTO A SINGLE LIGHT SWITCH. SIMILAR TO A "GROUP" IN HA. ##
293 - platform: template
294 name: "Barn Lights"
295 id: barn_inside_lights
296 optimistic: true
297 restore_mode: RESTORE_DEFAULT_ON
298
299 turn_on_action:
300 - switch.turn_on: barn_switch1
301 - switch.turn_on: barn_switch2
302
303 turn_off_action:
304 - switch.turn_off: barn_switch1
305 - switch.turn_off: barn_switch2
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322binary_sensor:
323
324#### EXTRA SENSORS NOT NECESSARY FOR KEYPAD ###########
325 - platform: gpio
326 name: "Small Barn Door"
327 pin:
328 number: 12
329 mode:
330 input: true
331 pullup: true
332 inverted: true
333 id: barn_door_small
334 device_class: door
335
336
337 - platform: gpio
338 name: "Light Switch2"
339 id: barn_switch_sensor2
340 pin:
341 number: 14
342 mode:
343 input: true
344 pullup: true
345 inverted: true
346 filters:
347 - settle: 1.5s
348 - delayed_on_off: 1.5s
349 on_state:
350 then:
351 - switch.toggle: barn_inside_lights
352
353### A STATUS SENSOR IS HANDY TO HAVE BUT ISN'T NECESSARY FOR KEYPAD ######
354
355 - platform: status
356 id: keypad_status
357 name: Barn Keypad Status
358
359
360
361text_sensor:
362
363 - platform: template
364 id: newest_user
365 name: "New Keypad User"
366
367## SUNRISE/SUNSET INFO ISN'T NEEDED AND JUST SOMETHING I USE BUT, IT CAN BE REMOVED WITH 0 ISSUE.
368 - platform: sun
369 name: Next Sunrise
370 type: sunrise
371 id: next_sunrise1
372
373 - platform: sun
374 name: Next Sunset
375 type: sunset
376 id: next_sunset
377
378
379 - platform: homeassistant
380 entity_id: cover.overhead_door_rf_overhead
381 id: ha_cover_state
382 name: "Overhead Door"
383 internal: false
384
385
386 - platform: template
387 name: Uptime Wg26
388 id: uptime_human_wg26
389 icon: mdi:clock-start
390
391 - platform: wifi_info
392 ip_address:
393 name: Keypad IP Address
394 ssid:
395 name: Keypad Connected SSID
396 # mac_address:
397 # name: Keypad Mac Address
398 scan_results:
399 name: Keypad Latest Scan Results
400 dns_address:
401 name: "dns used"
402
403
404## The "door access method" displays whether someone used a Pin code or scanned an RFID tag. ###
405
406 - platform: template
407 name: "Door Access Method"
408 id: door_access_method
409
410### Guest1 pin will display what you have set as the pin code if you have turned on Guest mode 1. ###
411 - platform: template
412 name: "Guest 1 Pin #"
413 id: guest_1_pin
414 icon: mdi:account-plus
415
416## Combining an Alarm with the Keypad is just something i was messing with and isn't setup currently and ## isn't needed at all on the devices running your keypad. ##
417 - platform: template
418 name: "Alarm State"
419 id: alarm_state
420 icon: mdi:account-multiple
421
422## Last User displays the last User Name that accessed the Keypad with either a Pin or RFID tag.
423 - platform: template
424 name: "Last User"
425 id: last_user
426 icon: mdi:clock-start
427
428## Displays the name you assigned for Guest 1 ##
429 - platform: template
430 name: "Assigned Guest"
431 id: assigned_guest_1
432 icon: mdi:account-plus
433
434## This is the Text Input box for assigning a name for Guest 1 ###
435
436text:
437 - platform: template
438 id: guest_1_name
439 name: "Guest 1 Name"
440 restore_value: True
441 mode: text
442 optimistic: true
443 on_value:
444 - if:
445 condition:
446 - switch.is_on: guest1_active
447 then:
448 - text_sensor.template.publish:
449 id: assigned_guest_1
450 state: !lambda 'return x.c_str();'
451
452 - globals.set:
453 id: guest_1
454 value: !lambda 'return x.c_str();'
455
456## The "Create New User" feature isn't complete and i'm still messing with it. It's easy to add users via the ## Esphome config and then flash the board to add something new but, the intended goal of this UI was to do ## everything from the Homeassistant UI and this isn't a complete feature yet, sorry. ##
457
458 - platform: template
459 id: create_new_user
460 name: "Create New User"
461 mode: text
462 restore_value: True
463 optimistic: true
464 on_value:
465 then:
466 - text_sensor.template.publish:
467 id: newest_user
468 state: !lambda 'return x.c_str();'
469
470 - globals.set:
471 id: new_user_created
472 value: !lambda 'return x.c_str();'
473
474
475### These are the globals that store sensor states and for some reason the states are not surviving after ## rebooting the esp board and is still in progress. Globals will stay for days/weeks as long as there isn't ## a reboot, at least temporarily. ##
476globals:
477 - id: method
478 type: std::string
479 restore_value: yes
480 max_restore_data_length: 13
481 initial_value: ""
482
483
484 - id: last_user_access
485 type: std::string
486 restore_value: yes
487 max_restore_data_length: 13
488 initial_value: ""
489
490 - id: new_user_created
491 type: std::string
492 restore_value: yes
493 max_restore_data_length: 13
494 initial_value: ""
495
496 - id: temp_code
497 type: int
498 restore_value: yes
499 max_restore_data_length: 5
500 initial_value: ""
501
502 - id: guest_1
503 type: std::string
504 restore_value: yes
505 max_restore_data_length: 8
506 initial_value: ""
507
508
509
510sensor:
511
512## Timestamp for different actions that happen. ##
513 - platform: template
514 name: "Display Timestamp"
515 device_class: timestamp
516 id: keypad_timestamp
517
518## This is for a smaller/man door that has a Reed switch installed on it. This is just a dutyf_time sensor ## that shows me how long the door was open.
519
520 - platform: duty_time
521 id: small_door_open
522 name: "Door Open Time"
523 # Support logical sources (optional): 'binary_sensor'
524 sensor: barn_door_small
525 restore: true # Sensor for last turn-on time (optional)
526 last_time:
527 name: "Last Time Door Open"
528
529## This is a sensor that displays the last Pin code someone entered whether it is correct or incorrect. ##
530
531## All of these "if" statements under (id: keyCode) are what makes up the Keypad's logic and is where you ## need to create any "Master" Usernames like yourself and anyone else that lives there or you anticipate to ## have access indefinately like children or family members for example. ##
532
533 - platform: template
534 name: Keypad Code
535 id: keyCode
536 on_value:
537 - if:
538 condition:
539 and:
540 ## This condition checks the code that was entered against a number/pincode from a list of saved
541 ## pin codes that do have access and work.
542 ## if none match..... 1050, 1955, 6800, etc, etc.
543
544 - lambda: 'return id(keyCode).state != 1050;'
545 - lambda: 'return id(keyCode).state != 1955;'
546 - lambda: 'return id(keyCode).state != 6800;'
547 - lambda: 'return id(keyCode).state != 2014;'
548 - lambda: 'return id(keyCode).state != id(temp_code);'
549 - lambda: 'return id(keyCode).state != id(guest1_keypad_code).state;'
550 then:
551
552## No Match then it Publishes "Invalid Code" as "keypad_code" entity. I do plan to add a UI configurable ## limit for incorrect codes entered and then followed by a timout/cool down period where pincodes wont be ## accepted for a certain amount of time that i have set via UI. You could even incorporate a function to ## send you a notification of X number of wrong pincodes being entered so that police or someone can be ## alerted to the situation/problem..... Stay Tuned for that feature and more LOL. ##
553 - text_sensor.template.publish:
554 id: last_user
555 state: "Invalid Code Entered"
556 - if:
557 ## IF this matches a specific Pincode "1050"
558 condition:
559 - lambda: 'return id(keyCode).state == 1050;'
560 then:
561 ## This first "if statement" above and the lambda, this is how i setup each person/user.
562 - lambda: |-
563 {
564 id(ovrhead).toggle();
565 id(last_user).publish_state("Justin");
566 id(door_access_method ).publish_state("Pin Code");
567 }
568 - lambda: 'return id(keypad_timestamp).publish_state(id(homeassistant_time).now().timestamp);'
569
570 ## If True then Toggle "overhead" which is my Cover for overhead door.
571 ## Then publishes the person/user name who's pin code is 1050
572 ## publish the method as far as Pincode or RFID tag that "Justin" used to access the door via
573 ## keypad codes entered or rfid tags scanned or even Alarm issues.
574 - lambda: |-
575 {
576 id(ovrhead).toggle();
577 id(last_user).publish_state("Justin");
578 id(door_access_method ).publish_state("PinCode);
579 ## Create a TimeStamp for a code entered and opened the door.
580
581 - lambda: 'return id(keypad_timestamp).publish_state(id(homeassistant_time).now().timestamp);'
582
583
584
585
586
587
588### These are just more of the example above and you need 1 of these ( - if: ) statements for each user you ## intend to create. You do not need to repeat the list of user codes like above. That list is checked each ## time a Pincode is typed on the Keypad and only needs added in here 1 time. ##
589 - if:
590 condition:
591 - lambda: 'return id(keyCode).state == 6800;'
592 then:
593 - lambda: |-
594 {
595 id(ovrhead).toggle();
596 id(last_user).publish_state("Paula");
597 id(door_access_method ).publish_state("Pin Code");
598 }
599 - lambda: 'return id(keypad_timestamp).publish_state(id(homeassistant_time).now().timestamp);'
600
601
602 - if:
603 condition:
604 - lambda: 'return id(keyCode).state == 1955;'
605 then:
606 - lambda: |-
607 {
608 id(ovrhead).toggle();
609 id(last_user).publish_state("Mike");
610 id(door_access_method ).publish_state("Pin Code");
611 }
612
613 - lambda: 'return id(keypad_timestamp).publish_state(id(homeassistant_time).now().timestamp);'
614
615 - if:
616 condition:
617 - lambda: 'return id(keyCode).state == 2014;'
618 then:
619 - lambda: |-
620 {
621 id(ovrhead).toggle();
622 id(last_user).publish_state("Olive");
623 id(door_access_method ).publish_state("Pin Code");
624 }
625
626 - lambda: 'return id(keypad_timestamp).publish_state(id(homeassistant_time).now().timestamp);'
627
628 - if:
629 condition:
630 and:
631 ## Guest1 and Guest2 Pincodes only work if the switch is toggled ON and here is that logic that will ## allow or deny a Pincode currently in use or one that was used in the past. Guest1/2 mode must be turned ## ON. ##
632 - switch.is_on: guest1_active
633 - lambda: 'return id(keyCode).state == id(guest1_keypad_code).state;'
634 then:
635 - logger.log: "Guest 1 Code Accepted!"
636
637 - text_sensor.template.publish:
638 id: last_user
639 state: !lambda 'return id(assigned_guest_1).state;'
640
641 - lambda: |-
642 {
643 id(ovrhead).toggle();
644 id(last_user).publish_state("Olive");
645 id(door_access_method ).publish_state("Pin Code");
646 }
647
648 - lambda: 'return id(keypad_timestamp).publish_state(id(homeassistant_time).now().timestamp);'
649
650
651
652 - if:
653 condition:
654 and:
655 - switch.is_on: guest2_active
656 - lambda: 'return id(keyCode).state == id(guest2_keypad_code).state;'
657 then:
658 - logger.log: "Guest 2 Code Accepted!"
659
660 - text_sensor.template.publish:
661 id: last_user
662 state: "Guest 2 Code"
663
664
665 # - lambda: |-
666 # if (x == "6789"); {
667 # id(ovrhead).toggle();
668 # id(last_user).publish_state("Temp. Code");
669 # }
670 # id(last_user_access) = "Temp Code";
671
672
673 - if:
674 condition:
675 and:
676 # - alarm_control_panel.is_armed: acp1
677 - lambda: 'return id(keyCode).state == 6753957;'
678 then:
679 # - alarm_control_panel.disarm:
680 # id: acp1
681 # code: "2014"
682 - delay: 1s
683 - switch.toggle: ovrhead
684
685 - text_sensor.template.publish:
686 id: last_user
687 state: "Justin Tag"
688
689
690 - text_sensor.template.publish:
691 id: alarm_state
692 state: "Disarmed By Justin"
693
694
695 else:
696 # if:
697 # condition:
698 # not:
699 # - alarm_control_panel.is_armed: acp1
700 # then:
701 if:
702 condition:
703 - lambda: 'return id(keyCode).state == 6753957;'
704 then:
705 - lambda: |-
706 {
707 id(ovrhead).toggle();
708 id(last_user).publish_state("Justin");
709 id(door_access_method).publish_state("RFID Tag");
710 }
711
712
713
714
715
716 - if:
717 condition:
718 - lambda: 'return id(keyCode).state == 6422842;'
719 then:
720 - lambda: |-
721 {
722 id(ovrhead).toggle();
723 id(last_user).publish_state("Paula");
724 id(door_access_method ).publish_state("RFID Tag");
725 }
726
727 - if:
728 condition:
729 - lambda: 'return id(keyCode).state == 6491970;'
730 then:
731 - lambda: |-
732 {
733 id(ovrhead).toggle();
734 id(last_user).publish_state("Mike");
735 id(door_access_method ).publish_state("RFID Tag");
736 }
737
738
739 - if:
740 condition:
741 - lambda: 'return id(keyCode).state == 5553549;'
742 then:
743 - lambda: |-
744 {
745 id(ovrhead).toggle();
746 id(last_user).publish_state("Golf Cart Key1");
747
748 }
749
750
751 - if:
752 condition:
753 - lambda: 'return id(keyCode).state == 5627758;'
754 then:
755 - lambda: |-
756 {
757 id(ovrhead).toggle();
758 id(last_user).publish_state("Golf Cart Key2");
759 }
760
761
762
763
764
765
766
767
768 - platform: wifi_signal
769 id: wifi_signal_db
770 update_interval: 300s
771 entity_category: "diagnostic"
772 internal: true
773
774 - platform: copy
775 source_id: wifi_signal_db
776 name: "WiFi Signal Keypad"
777 filters:
778 - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
779 unit_of_measurement: "Signal %"
780 entity_category: "diagnostic"
781 id: wifiSignalWG26
782
783 - platform: uptime #Uptime in Seconds
784 name: Barn Keypad Uptime
785 id: uptime_sensor_wiegand
786 update_interval: 240s
787 internal: True
788 on_raw_value:
789 then:
790 - text_sensor.template.publish:
791 id: uptime_human_wg26
792 state: !lambda |-
793 int seconds = round(id(uptime_sensor_wiegand).raw_state);
794 int days = seconds / (24 * 3600);
795 seconds = seconds % (24 * 3600);
796 int hours = seconds / 3600;
797 seconds = seconds % 3600;
798 int minutes = seconds / 60;
799 seconds = seconds % 60;
800 return (
801 (days ? String(days) + "d " : "") +
802 (hours ? String(hours) + "h " : "") +
803 (minutes ? String(minutes) + "m " : "") +
804 (String(seconds) + "s")
805 ).c_str();
806
807wiegand:
808 - id: mykeypad
809 d0: 21 ## Grn
810 d1: 18 ## Wht
811 on_key:
812 - lambda: ESP_LOGI("KEY", "received key %d", x);
813 on_tag:
814 - lambda: ESP_LOGI("TAG", "received tag %s", x.c_str());
815 - sensor.template.publish:
816 id: keyCode
817 state: !lambda "return parse_number<float>(x).value();"
818 - if:
819 condition:
820 and:
821 - lambda: 'return id(keyCode).state != 5553549;'
822 - lambda: 'return id(keyCode).state != 6422842;'
823 - lambda: 'return id(keyCode).state != 6491970;'
824 - lambda: 'return id(keyCode).state != 6753957;'
825 # - lambda: 'return id(keyCode).state != #######;'
826 # - lambda: 'return id(keyCode).state != #######;'
827 # - lambda: 'return id(keyCode).state != #######;'
828
829 then:
830 - text_sensor.template.publish:
831 id: last_user
832 state: "Invalid Tag Scanned"
833
834
835
836
837 on_raw:
838 - lambda: ESP_LOGI("RAW", "received raw %d bits, value %llx", bits, value);
839
840key_collector:
841 - id: pincode_reader
842 source_id: mykeypad
843 min_length: 4
844 max_length: 5
845 end_keys: "#"
846 end_key_required: true
847 clear_keys: "*"
848 allowed_keys: "0123456789"
849 timeout: 5s
850 on_progress:
851 - logger.log:
852 format: "input progress: '%s', started by '%c'"
853 args: [ 'x.c_str()', "(start == 0 ? '~' : start)" ]
854 on_result:
855 then:
856 - sensor.template.publish:
857 id: keyCode
858 state: !lambda "return parse_number<float>(x).value();"
859
860
861 on_timeout:
862 - logger.log:
863 format: "input timeout: '%s', started by '%c'"
864 args: [ 'x.c_str()', "(start == 0 ? '~' : start)" ]
865
866
867
868# D1
869
870
871light:
872 - platform: neopixelbus
873 type: RGB
874 variant: WS2811
875 pin: 17
876 num_leds: 20
877 id: barn_overhead_led
878 name: "Barn Door LED Strip"
879 effects:
880 - random:
881 - random:
882 name: Random Colors
883 transition_length: 5s
884 update_interval: 15s
885
886
887select:
888 - platform: template
889 id: barn_led_effect
890 name: "Barn Light Effect"
891 options:
892 - "R/W/B"
893 - "B/R/W"
894 - ""
895 initial_option: ""
896 optimistic: True
897 on_value:
898 then:
899 if:
900 condition:
901 - lambda: 'return id(barn_led_effect).state == "R/W/B";'
902 then:
903 - light.addressable_set:
904 id: barn_overhead_led
905 range_from: 0
906 range_to: 7
907 red: 100%
908 green: 0%
909 blue: 0%
910 color_brightness: 100%
911
912 - light.addressable_set:
913 id: barn_overhead_led
914 range_from: 8
915 range_to: 14
916 red: 0%
917 green: 0%
918 blue: 0%
919 white: 100%
920 color_brightness: 100%
921
922 - light.addressable_set:
923 id: barn_overhead_led
924 range_from: 15
925 range_to: 20
926 red: 0%
927 green: 0%
928 blue: 100%
929 color_brightness: 100%
930
931
932
933interval:
934 - interval: 1min
935 then:
936 - if:
937 condition:
938 and:
939 - sun.is_below_horizon:
940 - light.is_off:
941 id: barn_overhead_led
942 then:
943 - light.turn_on:
944 id: barn_overhead_led
945 brightness: 75%
946 red: 0%
947 green: 0%
948 blue: 100%
949
950 - if:
951 condition:
952 and:
953 - sun.is_above_horizon:
954 - light.is_on:
955 id: barn_overhead_led
956 then:
957 - light.turn_off:
958 id: barn_overhead_led
959
960 - if:
961 condition:
962 and:
963 - sun.is_above_horizon:
964 - switch.is_on:
965 id: outside_barn_lights
966 then:
967 - switch.turn_off:
968 id: outside_barn_lights