Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- esphome:
- name: garagedoor
- platform: ESP8266
- board: esp01_1m
- wifi:
- ssid: mywifi
- password: "mywifipw"
- # Enable logging
- logger:
- esp8266_store_log_strings_in_flash: False
- # Enable Home Assistant API
- api:
- ota:
- globals:
- - id: door_state
- type: int
- initial_value: '0'
- restore_value: no
- # possible values are:
- # open = '5'
- # opening = '4'
- # closed = '3'
- # closing = '2'
- # halfway = '1'
- # unknown = '0'
- binary_sensor:
- - platform: gpio
- pin:
- number: GPIO04
- mode: INPUT_PULLUP
- # when switch is closed the door is closed
- inverted: True
- name: "Garage Door Closed Reed Switch"
- device_class: garage_door
- id: closed_sensor
- switch:
- - platform: gpio
- pin: GPIO12
- id: door_switch
- - platform: template
- icon: "mdi:arrow-up-down-bold-outline"
- name: "Blum Garage Control Relay"
- cover:
- - platform: template
- name: "Garage Door"
- id: garage_door
- device_class: garage
- assumed_state: true
- close_action:
- - lambda: !lambda |-
- ESP_LOGD("custom", "Global value is: %d", id(door_state));
- if (!id(closed_sensor).state) {
- id(door_state) = 2; // 2 = closing
- //turn switch on
- ESP_LOGD("custom", "Global value is: %d", id(door_state));
- }
- while (id(door_state) == 2) {
- delay(1000);
- ESP_LOGD("custom", "Inside the while loop %d", 1);
- ESP_LOGD("custom", "Global value is: %d", id(door_state));
- if (id(closed_sensor).state) {
- id(door_state) = 3; // 3 = closed
- //turn switch off
- ESP_LOGD("custom", "Global value is: %d", id(door_state));
- }
- }
Add Comment
Please, Sign In to add comment