I have a simple garage door (well two, but if I can get one working then…) I have a magnetic switch on the door to indiacte when it is either closed or open. The control motor needs a momentary contact ( I have a relay for this) to either open or close the door. I have this code that the switch on it will activate the relay (either on or off not momentary at the moment) And the status of the door isn’t working. I am at a loss as how to make this work.
cover:
- platform: template
covers:
garage_door:
device_class: garage
friendly_name: “Honda Door”
unique_id: “Honda Door”
value_template: ‘{{ states(“binary_sensor.honda_door_contact_2”) }}’
open_cover:
- service: switch.turn_on
target:
entity_id: switch.honda_door_relay
close_cover:
- service: switch.turn_on
target:
entity_id: switch.honda_door_relay
stop_cover:
- service: switch.turn_on
target:
entity_id: switch.honda_door_relay
icon_template: >-
{% if is_state(‘binary_sensor.honda_door_contact_2’, ‘closed’) %}
mdi:garage
{% elif is_state(‘binary_sensor.honda_door_contact_2’, ‘closing’) %}
mdi:garage-alert
{% elif is_state(‘binary_sensor.honda_door_contact_2’, ‘opening’) %}
mdi:garage-alert
{% elif is_state(‘binary_sensor.honda_door_contact_2’, ‘error’) %}
mdi:magnet-on
{% else %}
mdi:garage-open
{% endif %}
template:
- trigger:
- platform: state
entity_id:- binary_sensor.garage_door_open
- binary_sensor.garage_door_closed
- input_text.garage_rotary_state
- platform: homeassistant
event: start
sensor: - name: “Garage Door Status”
unique_id: “binary_sensor.honda_door_contact_2”
state: >
{% if is_state(‘binary_sensor.garage_door_closed’, ‘on’) and is_state(‘binary_sensor.garage_door_open’, ‘on’) %}
error
{% elif is_state(‘binary_sensor.garage_door_closed’, ‘on’) %}
closed
{% elif is_state(‘binary_sensor.garage_door_open’, ‘on’) %}
open
{% elif trigger.platform != ‘homeassistant’ %}
{% if (trigger.to_state.state == ‘off’ and trigger.from_state.state == ‘on’ and trigger.entity_id == ‘binary_sensor.garage_door_open’) %}
closing
{% elif (trigger.to_state.state == ‘off’ and trigger.from_state.state == ‘on’ and trigger.entity_id == ‘binary_sensor.garage_door_closed’) %}
opening
{% elif is_state(‘input_text.garage_rotary_state’, ‘opening’) %}
opening
{% elif is_state(‘input_text.garage_rotary_state’, ‘closing’) %}
closing
{% endif %}
{% else %}
open
{% endif %}
- platform: state
My door contact is : binary_sensor.honda_door_contact_2
My switch / relay is: switch.honda_door_relay
Any quidance is much appreciated