Advertisement
penright

Untitled

Feb 4th, 2022
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 6.21 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 switches and know the door is
  7. #   is in some unknown 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: |-
  13.         ESP_LOGD("On Boot","Start ");
  14.         ESP_LOGD("On Boot","  Binary Contact Sensor Open   %s",id(binary_contact_sensor_open_postion).state ? "true" : "false");
  15.         ESP_LOGD("On Boot","  Binary Contact Sensor Closed %s",id(binary_contact_sensor_closed_postion).state ? "true" : "false");
  16.         ESP_LOGD("On Boot","         Contact Sensor Open   %s",id(contact_sensor_open_postion).state ? "true" : "false");
  17.         ESP_LOGD("On Boot","         Contact Sensor Closed %s",id(contact_sensor_closed_postion).state ? "true" : "false");
  18.         if ((id(binary_contact_sensor_open_postion).state) == true) {
  19.           id(template_cov).position = COVER_OPEN;
  20.           id(template_cov).current_operation = COVER_OPERATION_IDLE;
  21.           id(template_cov).publish_state();
  22.           ESP_LOGD("On Boot","Open");
  23.         } else if (id(binary_contact_sensor_closed_postion).state == true) {
  24.           id(template_cov).position = COVER_CLOSED;
  25.           id(template_cov).current_operation = COVER_OPERATION_IDLE;
  26.           id(template_cov).publish_state();
  27.           ESP_LOGD("On Boot","Closed");
  28.         } else {
  29.           id(template_cov).position = 0.5;
  30.           id(template_cov).current_operation = COVER_OPERATION_OPENING;
  31.           id(template_cov).publish_state();
  32.           ESP_LOGD("On Boot","Not Known");
  33.         }
  34.         ESP_LOGD("On Boot","End");
  35.  
  36. wifi:
  37.   ssid: !secret wifi_ssid_work
  38.   password: !secret wifi_password_work
  39. #  use_address: !secret ESPHome_IP_Shop_Garage_Door
  40.   use_address: "172.25.92.115"
  41.  
  42.  
  43.   # Enable fallback hotspot (captive portal) in case wifi connection fails
  44.   ap:
  45.     ssid: !secret wifi_esphome_fallback_ssid
  46.     password: !secret wifi_esphome_fallback_password
  47.  
  48. captive_portal:
  49. # Enable logging
  50. logger:
  51.   level: DEBUG
  52.  
  53. # Enable Home Assistant API
  54. api:
  55.   password: !secret esphome_api_password
  56.  
  57. ota:
  58.   password: !secret esphome_ota_password
  59.  
  60.  
  61.  
  62. status_led:
  63.   pin:
  64.     number: GPIO02
  65.     inverted: True
  66.  
  67.  
  68. #===================================================================================
  69. #When holding the board with USB down
  70. #   GND         RST         |       -GPIO  1   GND
  71. #   NC          GPIO 36     |       -GPIO  3  *GPIO 27
  72. #   GPIO 39    *GPIO 26     |        GPIO 22   GPIO 25
  73. #   GPIO 35     GPIO 18     |        GPIO 21  *GPIO 32
  74. #  *GPIO 33     GPIO 19     |        GPIO 17  *GPIO 12
  75. #   GPIO 34     GPIO 23     |       *GPIO 16   GPIO  4
  76. #  *GPIO 14     GPIO  5     |        GND       GPIO  0
  77. #   NC          3.3V        |        5V        GPIO  2
  78. #   GPIO  9    *GPIO 13     |       *GPIO 15  -GPIO  8
  79. #  -GPIO 11     GPIO 10     |       -GPIO  7  -GPIO  6
  80. #Notes
  81. #  * Pins are best to use
  82. #  - Pins that should never be use
  83. #  Unmark pins could be used as input only but ESPHome won't allow it
  84. #===================================================================================
  85.  
  86.  
  87.  
  88. binary_sensor:
  89.  #This is the close sensor
  90.   - platform: gpio
  91.     pin:
  92.       number: GPIO27
  93.       mode: INPUT_PULLUP
  94.       inverted: true
  95.     name: "Closed Postion"
  96.     device_class: garage_door
  97.     id: binary_contact_sensor_closed_postion
  98.   - platform: template
  99.     name: "Shop North Overhead Door Closed Postion"
  100.     device_class: garage_door
  101.     id: contact_sensor_closed_postion
  102.     lambda: 'return id(binary_contact_sensor_closed_postion).state;'
  103.     on_release:
  104.       - cover.template.publish:
  105.           id: template_cov
  106.           current_operation: OPENING
  107.     on_press:
  108.       - cover.template.publish:
  109.           id: template_cov
  110.           current_operation: IDLE
  111.     internal: true
  112.     filters:
  113.     - delayed_on: 100ms
  114.  
  115.   #This is the open sensor
  116.   - platform: gpio
  117.     pin:
  118.       number: GPIO12
  119.       mode: INPUT_PULLUP
  120.       inverted: true
  121.     name: "Open Postion"
  122.     device_class: garage_door
  123.     id: binary_contact_sensor_open_postion
  124.     internal: true
  125.   - platform: template
  126.     name: "Shop North Overhead Door Open Postion"
  127.     device_class: garage_door
  128.     id: contact_sensor_open_postion
  129.     lambda: 'return id(binary_contact_sensor_open_postion).state;'
  130.     on_release:
  131.       - cover.template.publish:
  132.           id: template_cov
  133.           current_operation: CLOSING
  134.     on_press:
  135.       - cover.template.publish:
  136.           id: template_cov
  137.           current_operation: IDLE
  138.     internal: true
  139.     filters:
  140.     - delayed_on: 100ms
  141.  
  142.   #Shop Door
  143.   - platform: gpio
  144.     pin:
  145.       number: GPIO32
  146.       mode: INPUT_PULLUP
  147.       inverted: False
  148.     name: "Shop Door"
  149.     device_class: door
  150.     filters:
  151.     - delayed_on: 100ms
  152.    
  153. switch:
  154.   - platform: gpio
  155.     pin:
  156.       number: GPIO13
  157.       inverted: true
  158.     name: "Shop North Overhead Door Relay"
  159.     id: relay
  160.     internal: true
  161.    
  162.    
  163.   - platform: restart
  164.     name: "Reset Shop garage Door ESPHome"
  165.  
  166.  
  167. # This creates the actual garage door in HA. The state is based
  168. # on the contact sensor. Opening/closing the garage door simply
  169. # turns the relay on/off with a 0.5s delay in between.
  170.         #return COVER_CLOSED;
  171. cover:
  172.   - platform: template
  173.     device_class: garage
  174.     name: "Shop North Overhead Door"
  175.     id: template_cov
  176.     lambda: |-
  177.       if ((id(contact_sensor_open_postion).state) == true) {
  178.         return COVER_OPEN;
  179.       } else if (id(contact_sensor_closed_postion).state == true) {
  180.         return COVER_CLOSED;
  181.       } else {
  182.         return 0.5;
  183.       }
  184.     open_action:
  185.       - switch.turn_on: relay
  186.       - delay: 0.5s
  187.       - switch.turn_off: relay
  188.     close_action:
  189.       - switch.turn_on: relay
  190.       - delay: 0.5s
  191.       - switch.turn_off: relay
  192.     stop_action:
  193.       - if:
  194.           condition:
  195.             lambda: 'return !(id(contact_sensor_closed_postion).state == true || id(contact_sensor_open_postion).state == true) ;'
  196.           then:
  197.             - switch.turn_on: relay
  198.             - delay: 0.5s
  199.             - switch.turn_off: relay
  200.    
  201.    
  202.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement