I’m trying to improve a template cover I have for my garage door with only one contact sensor attached. I am able to publish the door position from the contact sensor input successfully, and both the open and close actions successfully set the current_operation to opening/closing, but when opening the door, I also have a 15 second delay then it is supposed to change to open, but it is not doing that. Ultimately I want to have the actual position of the door updated based on the contact sensor after a 15 sec delay, but I can’t get the position to update outside the contact sensor publishing.
Here’s my current config:
binary_sensor:
- platform: gpio
name: "Contact"
disabled_by_default: true
device_class: garage_door
id: contact
pin:
number: GPIO18
inverted: true
filters:
- delayed_on: 50ms
- settle: 1s
on_release: #closed
then:
- lambda: "id(garagedoor).current_operation = CoverOperation::COVER_OPERATION_IDLE;"
- cover.template.publish:
id: garagedoor
state: CLOSED
- logger.log: "Contact released"
on_press: #open
then:
# if:
# condition:
# - lambda: "return !id(garagedoor).current_operation == CoverOperation::COVER_OPERATION_OPENING;"
# then:
- cover.template.publish:
id: garagedoor
state: OPEN
- logger.log: "Contact pressed"
cover:
- platform: template
device_class: garage
name: "Garage Door"
id: garagedoor
# lambda: "return id(contact).state ? COVER_OPEN : COVER_CLOSED;"
open_action:
- if:
condition:
lambda: "return !id(contact).state;"
then:
- logger.log: "Open action"
- switch.turn_on: relay
- lambda: "id(garagedoor).current_operation = CoverOperation::COVER_OPERATION_OPENING;"
- delay: 15s
- lambda: "id(garagedoor).current_operation = CoverOperation::COVER_OPERATION_IDLE;"
- lambda: "id(garagedoor).position = COVER_OPEN;"
stop_action:
- if:
condition:
- lambda: "return id(garagedoor).current_operation != CoverOperation::COVER_OPERATION_IDLE;"
then:
- logger.log: "Stop action"
- switch.turn_on: relay
close_action:
- if:
condition:
lambda: "return id(contact).state;"
then:
- logger.log: "Close action"
- switch.turn_on: relay
- lambda: "id(garagedoor).current_operation = CoverOperation::COVER_OPERATION_CLOSING;"
# - delay: 15s
# - lambda: "id(garagedoor).current_operation = CoverOperation::COVER_OPERATION_IDLE;"