Advertisement
FALLINGAWAY38

Untitled

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