Advertisement
penright

Untitled

Feb 4th, 2022
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 6.07 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.     on_release:
  103.       - cover.template.publish:
  104.           id: template_cov
  105.           current_operation: OPENING
  106.     on_press:
  107.       - cover.template.publish:
  108.           id: template_cov
  109.           current_operation: IDLE
  110.     internal: true
  111.     filters:
  112.     - delayed_on: 100ms
  113.  
  114.   #This is the open sensor
  115.   - platform: gpio
  116.     pin:
  117.       number: GPIO12
  118.       mode: INPUT_PULLUP
  119.       inverted: true
  120.     name: "Open Postion"
  121.     device_class: garage_door
  122.     id: binary_contact_sensor_open_postion
  123.     internal: true
  124.   - platform: template
  125.     name: "Shop North Overhead Door Open Postion"
  126.     device_class: garage_door
  127.     id: contact_sensor_open_postion
  128.     on_release:
  129.       - cover.template.publish:
  130.           id: template_cov
  131.           current_operation: CLOSING
  132.     on_press:
  133.       - cover.template.publish:
  134.           id: template_cov
  135.           current_operation: IDLE
  136.     internal: true
  137.     filters:
  138.     - delayed_on: 100ms
  139.  
  140.   #Shop Door
  141.   - platform: gpio
  142.     pin:
  143.       number: GPIO32
  144.       mode: INPUT_PULLUP
  145.       inverted: False
  146.     name: "Shop Door"
  147.     device_class: door
  148.     filters:
  149.     - delayed_on: 100ms
  150.    
  151. switch:
  152.   - platform: gpio
  153.     pin:
  154.       number: GPIO13
  155.       inverted: true
  156.     name: "Shop North Overhead Door Relay"
  157.     id: relay
  158.     internal: true
  159.    
  160.    
  161.   - platform: restart
  162.     name: "Reset Shop garage Door ESPHome"
  163.  
  164.  
  165. # This creates the actual garage door in HA. The state is based
  166. # on the contact sensor. Opening/closing the garage door simply
  167. # turns the relay on/off with a 0.5s delay in between.
  168.         #return COVER_CLOSED;
  169. cover:
  170.   - platform: template
  171.     device_class: garage
  172.     name: "Shop North Overhead Door"
  173.     id: template_cov
  174.     lambda: |-
  175.       if ((id(contact_sensor_open_postion).state) == true) {
  176.         return COVER_OPEN;
  177.       } else if (id(contact_sensor_closed_postion).state == true) {
  178.         return COVER_CLOSED;
  179.       } else {
  180.         return 0.5;
  181.       }
  182.     open_action:
  183.       - switch.turn_on: relay
  184.       - delay: 0.5s
  185.       - switch.turn_off: relay
  186.     close_action:
  187.       - switch.turn_on: relay
  188.       - delay: 0.5s
  189.       - switch.turn_off: relay
  190.     stop_action:
  191.       - if:
  192.           condition:
  193.             lambda: 'return !(id(contact_sensor_closed_postion).state == true || id(contact_sensor_open_postion).state == true) ;'
  194.           then:
  195.             - switch.turn_on: relay
  196.             - delay: 0.5s
  197.             - switch.turn_off: relay
  198.    
  199.    
  200.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement