I have a template sensor to represent the state of my garage door. It relies on a reed switch wired into my Shelly device and a z-wave tilt sensor to determine the different states. However for the life of me, I can’t figure out how to get the “Closing” state to work. It’s always “Opening”, “Open”, or “Closed”. I feel like there’s a simple logic problem with my template that I just can’t see.
- sensor:
- name: Garage State
state: >
{% set open_on = is_state('binary_sensor.garage_door_input','on') %}
{% set close_on = is_state('binary_sensor.garage_tilt_sensor', 'off') %}
{% if open_on and not close_on %}
open
{% elif not open_on and close_on %}
closed
{% elif open_on and close_on %}
sensor error
{% else %}
{% if is_state('sensor.garage_state', 'open') %}
closing
{% else %}
opening
{% endif %}
{% endif %}