Advertisement
penright

Untitled

Feb 3rd, 2022
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 4.50 KB | None | 0 0
  1. esphome:
  2.   name: esphome-shop-garage-door
  3.   platform: ESP32
  4.   board: esp32doit-devkit-v1
  5. #On reboot the cover's current_operation is lost
  6. #   we can check the reed switchs and know the door is
  7. #   is in some unknow state but we don't know if it was
  8. #   opening or closing. So we will just pick one
  9.   on_boot:
  10.     priority: 300
  11.     then:
  12.     - lambda: 'id(contact_sensor_open_postion).publish_state(true);'
  13.     - lambda: 'id(contact_sensor_closed_postion).publish_state(true);'
  14.  
  15. wifi:
  16.   ssid: !secret wifi_ssid_work
  17.   password: !secret wifi_password_work
  18. #  use_address: !secret ESPHome_IP_Shop_Garage_Door
  19.   use_address: "172.25.92.115"
  20.  
  21.  
  22.   # Enable fallback hotspot (captive portal) in case wifi connection fails
  23.   ap:
  24.     ssid: !secret wifi_esphome_fallback_ssid
  25.     password: !secret wifi_esphome_fallback_password
  26.  
  27. captive_portal:
  28. # Enable logging
  29. logger:
  30.   level: DEBUG
  31.  
  32. # Enable Home Assistant API
  33. api:
  34.   password: !secret esphome_api_password
  35.  
  36. ota:
  37.   password: !secret esphome_ota_password
  38.  
  39.  
  40.  
  41. status_led:
  42.   pin:
  43.     number: GPIO02
  44.     inverted: True
  45.  
  46.  
  47. #===================================================================================
  48. #When holding the board with USB down
  49. #   GND         RST         |       -GPIO  1   GND
  50. #   NC          GPIO 36     |       -GPIO  3  *GPIO 27
  51. #   GPIO 39    *GPIO 26     |        GPIO 22   GPIO 25
  52. #   GPIO 35     GPIO 18     |        GPIO 21  *GPIO 32
  53. #  *GPIO 33     GPIO 19     |        GPIO 17  *GPIO 12
  54. #   GPIO 34     GPIO 23     |       *GPIO 16   GPIO  4
  55. #  *GPIO 14     GPIO  5     |        GND       GPIO  0
  56. #   NC          3.3V        |        5V        GPIO  2
  57. #   GPIO  9    *GPIO 13     |       *GPIO 15  -GPIO  8
  58. #  -GPIO 11     GPIO 10     |       -GPIO  7  -GPIO  6
  59. #Notes
  60. #  * Pins are best to use
  61. #  - Pins that should never be use
  62. #  Unmark pins could be used as input only but ESPHome won't allow it
  63. #===================================================================================
  64.  
  65.  
  66.  
  67. binary_sensor:
  68.   - platform: gpio
  69.     pin:
  70.       number: GPIO27
  71.       mode: INPUT_PULLUP
  72.       inverted: true
  73.     name: "Shop North Overhead Door Closed Postion"
  74.     device_class: garage_door
  75.     id: contact_sensor_closed_postion
  76.     on_release:
  77.       - cover.template.publish:
  78.           id: template_cov
  79.           current_operation: OPENING
  80.     on_press:
  81.       - cover.template.publish:
  82.           id: template_cov
  83.           current_operation: IDLE
  84.     internal: true
  85.     filters:
  86.     - delayed_on: 100ms
  87.  
  88.   - platform: gpio
  89.     pin:
  90.       number: GPIO12
  91.       mode: INPUT_PULLUP
  92.       inverted: true
  93.     name: "Shop North Overhead Door Open Postion"
  94.     device_class: garage_door
  95.     id: contact_sensor_open_postion
  96.     on_release:
  97.       - cover.template.publish:
  98.           id: template_cov
  99.           current_operation: CLOSING
  100.     on_press:
  101.       - cover.template.publish:
  102.           id: template_cov
  103.           current_operation: IDLE
  104.     internal: true
  105.     filters:
  106.     - delayed_on: 100ms
  107.   - platform: gpio
  108.     pin:
  109.       number: GPIO32
  110.       mode: INPUT_PULLUP
  111.       inverted: False
  112.     name: "Shop Door"
  113.     device_class: door
  114.     filters:
  115.     - delayed_on: 100ms
  116.    
  117. switch:
  118.   - platform: gpio
  119.     pin:
  120.       number: GPIO13
  121.       inverted: true
  122.     name: "Shop North Overhead Door Relay"
  123.     id: relay
  124.     internal: true
  125.    
  126.    
  127.   - platform: restart
  128.     name: "Reset Shop garage Door ESPHome"
  129.  
  130.  
  131. # This creates the actual garage door in HA. The state is based
  132. # on the contact sensor. Opening/closing the garage door simply
  133. # turns the relay on/off with a 0.5s delay in between.
  134.         #return COVER_CLOSED;
  135. cover:
  136.   - platform: template
  137.     device_class: garage
  138.     name: "Shop North Overhead Door"
  139.     id: template_cov
  140.     lambda: |-
  141.       if ((id(contact_sensor_open_postion).state) == true) {
  142.         return COVER_OPEN;
  143.       } else if (id(contact_sensor_closed_postion).state == true) {
  144.         return COVER_CLOSED;
  145.       } else {
  146.         return 0.5;
  147.       }
  148.     open_action:
  149.       - switch.turn_on: relay
  150.       - delay: 0.5s
  151.       - switch.turn_off: relay
  152.     close_action:
  153.       - switch.turn_on: relay
  154.       - delay: 0.5s
  155.       - switch.turn_off: relay
  156.     stop_action:
  157.       - if:
  158.           condition:
  159.             lambda: 'return !(id(contact_sensor_closed_postion).state == true || id(contact_sensor_open_postion).state == true) ;'
  160.           then:
  161.             - switch.turn_on: relay
  162.             - delay: 0.5s
  163.             - switch.turn_off: relay
  164.    
  165.    
  166.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement