Adding here for referance how I integrated a Fibaro Smart Implant to control garage door opening and status with 4 states: Open , Closed, Opening and Closing.
This is the device I used: https://manuals.fibaro.com/smart-implant/
The reason I chose this is it is super tiny and powered by 24VDC from my existing garage door opener terminal block and has relay output and 2 digital inputs for determining state.
One thing to take note of though is that when using common NO magnetic reed switches parameters 20 and 21 should be set to 'Normally closed alarm input"
When pairing the device it should be paired as not secure so that local protection state can be set to NOOperationPossible. This is necessary to de-couple the digital inputs from the relay outputs
The following code to be inserted into your configuration.yaml
template:
- trigger:
- platform: state
entity_id:
- binary_sensor.garage_door_open
- binary_sensor.garage_door_closed
sensor:
- name: 'Garage Door Status'
unique_id: 'garage_door_status'
state: >
{% if (trigger.to_state.state == 'off' and trigger.entity_id == 'binary_sensor.garage_door_open') %}
Open
{% elif (trigger.to_state.state == 'off' and trigger.entity_id == 'binary_sensor.garage_door_closed') %}
Closed
{% elif (trigger.to_state.state == 'on' and trigger.from_state.state == 'off' and trigger.entity_id == 'binary_sensor.garage_door_open') %}
Closing
{% elif (trigger.to_state.state == 'on' and trigger.from_state.state == 'off' and trigger.entity_id == 'binary_sensor.garage_door_closed') %}
Opening
{% endif %}
cover:
- platform: template
covers:
garage_door:
device_class: garage
friendly_name: "Garage Door"
unique_id: 'garage_door'
value_template: "{{ states('sensor.garage_door_status') }}"
icon_template: >-
{% if states('sensor.garage_door_status') == 'Closed' %}
mdi:garage-variant
{% else %}
mdi:garage-open-variant
{% endif %}
open_cover:
- condition: state
entity_id: sensor.garage_door_status
state: "Closed"
- service: switch.turn_on
target:
entity_id: switch.garage_door_button
close_cover:
- condition: state
entity_id: sensor.garage_door_status
state: "Open"
- service: switch.turn_on
target:
entity_id: switch.garage_door_button
stop_cover:
service: switch.turn_on
target:
entity_id: switch.garage_door_button