Dinoaus
(John Dean)
June 5, 2019, 10:29am
1
I have the following YAML file for my garage door. The problem I am having is that the state of the cover in home assistant is being reported as “OPENING” and “CLOSING” instead of “OPEN” and “CLOSE”. Can anyone see a problem with this?
I had it working with MQTT, then decided to use the ESPHOME API instead, now having the issue.
switch:
- platform: gpio
pin: D1
name: "Garage Door Switch"
id: garage_switch
binary_sensor:
- platform: gpio
pin:
number: D5
mode: INPUT_PULLUP
name: "Garage Reed Switch"
id: garage_status
filters:
- delayed_on: 1000ms
- delayed_off: 1000ms
cover:
- platform: template
name: "Garage Door"
id: garage_door
device_class: garage
lambda: |-
if (id(garage_status).state) {
return COVER_OPEN;
} else {
return COVER_CLOSED;
}
open_action:
- switch.turn_on:
id: garage_switch
- delay: 1s
- switch.turn_off:
id: garage_switch
close_action:
- switch.turn_on:
id: garage_switch
- delay: 1s
- switch.turn_off:
id: garage_switch
stop_action:
- switch.turn_on:
id: garage_switch
- delay: 1s
- switch.turn_off:
id: garage_switch
1 Like
Dinoaus
(John Dean)
June 7, 2019, 3:55am
2
Fixed. Had to set the current operation to IDLE.
therm0
(Justin)
June 8, 2019, 2:02am
3
How did you do that? Can you post the updated version of your YAML for folks (like me) who can’t for some reason wrap their head around the documentation?
Dinoaus
(John Dean)
June 8, 2019, 4:55am
4
This is my current YAML.
esphomeyaml:
name: garage
platform: ESP8266
board: d1_mini
wifi:
ssid:
password:
api:
password:
# Enable logging
logger:
level: NONE
ota:
password:
switch:
- platform: gpio
pin: D1
name: "Garage Door Switch"
id: garage_switch
binary_sensor:
- platform: gpio
pin:
number: D5
mode: INPUT_PULLUP
name: "Garage Reed Switch"
id: garage_status
filters:
- delayed_on: 1000ms
- delayed_off: 1000ms
cover:
- platform: template
name: "Garage Door"
id: garage_door
device_class: garage
lambda: !lambda |-
if (id(garage_status).state) {
id(garage_door).current_operation = esphome::cover::COVER_OPERATION_IDLE;
return COVER_OPEN;
} else {
id(garage_door).current_operation = esphome::cover::COVER_OPERATION_IDLE;
return COVER_CLOSED;
}
open_action:
- lambda: !lambda |-
if (!id(garage_status).state) {
id(garage_switch).turn_on();
delay(500);
id(garage_switch).turn_off();
}
close_action:
- lambda: !lambda |-
if (id(garage_status).state) {
id(garage_switch).turn_on();
delay(500);
id(garage_switch).turn_off();
}
stop_action:
- switch.turn_off:
id: garage_switch
- switch.turn_on:
id: garage_switch
- delay: 1s
- switch.turn_off:
id: garage_switch
2 Likes
Crewski
(David Naylor)
June 10, 2019, 6:26pm
5
Thanks for this. I’m about to implement a garage door opener (previously wrote my own code) and I like your lambdas in the open/close actions. Checking to see if it is open first or not is great!