Giving a little back in the way of a cover template used to integrate a Richmond siding gate motor GTR156 with a Shelly Uni.
The Uni is wired to the gate motor control board for 12VDC power (max 500mA according to helpful manufacturer support), open/close pins, and opened/closed travel limit switch pins.
I’ve wired:
Terminal 1 - Close → Shelly Uni - Output 2 (load pin)
Terminal 2 - Open → Shelly Uni - Output 1 (load pin)
Terminal 4 - Common → Shelly Uni - Output 1/2 (non-load pin)
Terminal 7 - 12VDC → Shelly Uni - L (positive)
Terminal 9 - GND → Shelly Uni - N (negative)
Terminal 11 - Travel Limit Switch → Shelly Uni - Input 1
Terminal 13 - Travel Limit Switch → Shelly Uni - Input 2
Used with this cover template.
cover:
- platform: template
covers:
driveway_gate:
device_class: "gate"
friendly_name: "Driveway Gate"
unique_id: "driveway_gate"
open_cover:
service: switch.turn_on
data:
entity_id: switch.driveway_gate_channel_1
close_cover:
service: switch.turn_on
data:
entity_id: switch.driveway_gate_channel_2
availability_template: >-
{% if not is_state('binary_sensor.driveway_gate_channel_1_input', 'unknown') %}
true
{% else %}
false
{% endif %}
value_template: >-
{% if is_state('binary_sensor.driveway_gate_channel_1_input', 'on') %}
open
{% elif is_state('binary_sensor.driveway_gate_channel_2_input', 'on') %}
closed
{% elif as_timestamp(states.binary_sensor.driveway_gate_channel_2_input.last_changed) > as_timestamp(states.binary_sensor.driveway_gate_channel_1_input.last_changed) %}
opening
{% elif as_timestamp(states.binary_sensor.driveway_gate_channel_1_input.last_changed) > as_timestamp(states.binary_sensor.driveway_gate_channel_2_input.last_changed) %}
closing
{% else %}
unknown
{% endif %}
icon_template: >-
{% if is_state('binary_sensor.driveway_gate_channel_1_input', 'on') %}
mdi:gate-open
{% elif is_state('binary_sensor.driveway_gate_channel_2_input', 'on') %}
mdi:gate
{% elif as_timestamp(states.binary_sensor.driveway_gate_channel_2_input.last_changed) > as_timestamp(states.binary_sensor.driveway_gate_channel_1_input.last_changed) %}
mdi:gate-arrow-right
{% elif as_timestamp(states.binary_sensor.driveway_gate_channel_1_input.last_changed) > as_timestamp(states.binary_sensor.driveway_gate_channel_2_input.last_changed) %}
mdi:gate-arrow-left
{% else %}
mdi:gate-alert
{% endif %}
entity_picture_template: >-
{% if is_state('binary_sensor.driveway_gate_channel_1_input', 'on') %}
/local/gate-open.svg
{% elif is_state('binary_sensor.driveway_gate_channel_2_input', 'on') %}
/local/gate.svg
{% elif as_timestamp(states.binary_sensor.driveway_gate_channel_2_input.last_changed) > as_timestamp(states.binary_sensor.driveway_gate_channel_1_input.last_changed) %}
/local/gate-arrow-right.svg
{% elif as_timestamp(states.binary_sensor.driveway_gate_channel_1_input.last_changed) > as_timestamp(states.binary_sensor.driveway_gate_channel_2_input.last_changed) %}
/local/gate-arrow-left.svg
{% else %}
/local/gate-alert.svg
{% endif %}
Comparing the travel limit switch input last_changed to the other switch to know if the gate is in the “opening” or “closing” states I thought was an elegant hack.
The Uni inputs button type is configured as “detached” switches. Also set timer “Auto Off” to 0.5 seconds (yeah… it seems to allow fractions )