Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- esphome:
- name: esphome-shop-garage-door
- platform: ESP32
- board: esp32doit-devkit-v1
- #On reboot the cover's current_operation is lost
- # we can check the reed switches and know the door is
- # is in some unknown state but we don't know if it was
- # opening or closing. So we will just pick one
- on_boot:
- priority: 300
- then:
- lambda: |-
- ESP_LOGD("On Boot","Start ");
- ESP_LOGD("On Boot"," Binary Contact Sensor Open %s",id(binary_contact_sensor_open_postion).state ? "true" : "false");
- ESP_LOGD("On Boot"," Binary Contact Sensor Closed %s",id(binary_contact_sensor_closed_postion).state ? "true" : "false");
- ESP_LOGD("On Boot"," Contact Sensor Open %s",id(contact_sensor_open_postion).state ? "true" : "false");
- ESP_LOGD("On Boot"," Contact Sensor Closed %s",id(contact_sensor_closed_postion).state ? "true" : "false");
- if ((id(binary_contact_sensor_open_postion).state) == true) {
- id(template_cov).position = COVER_OPEN;
- id(template_cov).current_operation = COVER_OPERATION_IDLE;
- id(template_cov).publish_state();
- ESP_LOGD("On Boot","Open");
- } else if (id(binary_contact_sensor_closed_postion).state == true) {
- id(template_cov).position = COVER_CLOSED;
- id(template_cov).current_operation = COVER_OPERATION_IDLE;
- id(template_cov).publish_state();
- ESP_LOGD("On Boot","Closed");
- } else {
- id(template_cov).position = 0.5;
- id(template_cov).current_operation = COVER_OPERATION_OPENING;
- id(template_cov).publish_state();
- ESP_LOGD("On Boot","Not Known");
- }
- ESP_LOGD("On Boot","End");
- wifi:
- ssid: !secret wifi_ssid_work
- password: !secret wifi_password_work
- # use_address: !secret ESPHome_IP_Shop_Garage_Door
- use_address: "172.25.92.115"
- # Enable fallback hotspot (captive portal) in case wifi connection fails
- ap:
- ssid: !secret wifi_esphome_fallback_ssid
- password: !secret wifi_esphome_fallback_password
- captive_portal:
- # Enable logging
- logger:
- level: DEBUG
- # Enable Home Assistant API
- api:
- password: !secret esphome_api_password
- ota:
- password: !secret esphome_ota_password
- status_led:
- pin:
- number: GPIO02
- inverted: True
- #===================================================================================
- #When holding the board with USB down
- # GND RST | -GPIO 1 GND
- # NC GPIO 36 | -GPIO 3 *GPIO 27
- # GPIO 39 *GPIO 26 | GPIO 22 GPIO 25
- # GPIO 35 GPIO 18 | GPIO 21 *GPIO 32
- # *GPIO 33 GPIO 19 | GPIO 17 *GPIO 12
- # GPIO 34 GPIO 23 | *GPIO 16 GPIO 4
- # *GPIO 14 GPIO 5 | GND GPIO 0
- # NC 3.3V | 5V GPIO 2
- # GPIO 9 *GPIO 13 | *GPIO 15 -GPIO 8
- # -GPIO 11 GPIO 10 | -GPIO 7 -GPIO 6
- #Notes
- # * Pins are best to use
- # - Pins that should never be use
- # Unmark pins could be used as input only but ESPHome won't allow it
- #===================================================================================
- binary_sensor:
- #This is the close sensor
- - platform: gpio
- pin:
- number: GPIO27
- mode: INPUT_PULLUP
- inverted: true
- name: "Closed Postion"
- device_class: garage_door
- id: binary_contact_sensor_closed_postion
- - platform: template
- name: "Shop North Overhead Door Closed Postion"
- device_class: garage_door
- id: contact_sensor_closed_postion
- on_release:
- - cover.template.publish:
- id: template_cov
- current_operation: OPENING
- on_press:
- - cover.template.publish:
- id: template_cov
- current_operation: IDLE
- internal: true
- filters:
- - delayed_on: 100ms
- #This is the open sensor
- - platform: gpio
- pin:
- number: GPIO12
- mode: INPUT_PULLUP
- inverted: true
- name: "Open Postion"
- device_class: garage_door
- id: binary_contact_sensor_open_postion
- internal: true
- - platform: template
- name: "Shop North Overhead Door Open Postion"
- device_class: garage_door
- id: contact_sensor_open_postion
- on_release:
- - cover.template.publish:
- id: template_cov
- current_operation: CLOSING
- on_press:
- - cover.template.publish:
- id: template_cov
- current_operation: IDLE
- internal: true
- filters:
- - delayed_on: 100ms
- #Shop Door
- - platform: gpio
- pin:
- number: GPIO32
- mode: INPUT_PULLUP
- inverted: False
- name: "Shop Door"
- device_class: door
- filters:
- - delayed_on: 100ms
- switch:
- - platform: gpio
- pin:
- number: GPIO13
- inverted: true
- name: "Shop North Overhead Door Relay"
- id: relay
- internal: true
- - platform: restart
- name: "Reset Shop garage Door ESPHome"
- # This creates the actual garage door in HA. The state is based
- # on the contact sensor. Opening/closing the garage door simply
- # turns the relay on/off with a 0.5s delay in between.
- #return COVER_CLOSED;
- cover:
- - platform: template
- device_class: garage
- name: "Shop North Overhead Door"
- id: template_cov
- lambda: |-
- if ((id(contact_sensor_open_postion).state) == true) {
- return COVER_OPEN;
- } else if (id(contact_sensor_closed_postion).state == true) {
- return COVER_CLOSED;
- } else {
- return 0.5;
- }
- open_action:
- - switch.turn_on: relay
- - delay: 0.5s
- - switch.turn_off: relay
- close_action:
- - switch.turn_on: relay
- - delay: 0.5s
- - switch.turn_off: relay
- stop_action:
- - if:
- condition:
- lambda: 'return !(id(contact_sensor_closed_postion).state == true || id(contact_sensor_open_postion).state == true) ;'
- then:
- - switch.turn_on: relay
- - delay: 0.5s
- - switch.turn_off: relay
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement