Skip to content

Instantly share code, notes, and snippets.

@jasonmadigan
Last active December 5, 2023 21:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonmadigan/df3473e12be3bad4a35150a319a5c990 to your computer and use it in GitHub Desktop.
Save jasonmadigan/df3473e12be3bad4a35150a319a5c990 to your computer and use it in GitHub Desktop.
platform: template
covers:
gate:
friendly_name: "Gate"
# With only one sensor, we'll have to guess.
# If the sensor reports closed, the door is closed. No guessing needed.
# If the sensor reports open, it could
# Help from: https://community.home-assistant.io/t/cover-timing/183404/4
value_template: >-
{% if is_state('binary_sensor.gate_contact_sensor', 'off') %}
closed
{% elif is_state('input_boolean.gate_moving', 'on') %}
moving
{% elif is_state('binary_sensor.gate_contact_sensor', 'on') %}
open
{% else %}
unknown
{% endif %}
open_cover:
service: script.open_gate
close_cover:
service: script.close_gate
icon_template: >-
{% if is_state('binary_sensor.gate_contact_sensor', 'off') %}
mdi:gate
{% elif is_state('input_boolean.gate_moving', 'on') %}
mdi:gate-arrow-left
{% elif is_state('binary_sensor.gate_contact_sensor', 'on') %}
mdi:gate-open
{% else %}
mdi:gate-alert
{% endif %}
# Binary virtual "moving" sensor
input_boolean:
gate_moving:
name: Gate Moving
initial: off
# Automation
- id: '1647011691136'
alias: gate cover called
trigger:
platform: event
event_type: call_service
event_data:
domain: cover
condition:
condition: template
value_template: '{{ trigger.event.as_dict()[''data''][''service_data''][''entity_id''] == ''cover.gate'' }}' # or whatever your gate cover is called
action:
- service: input_boolean.turn_on
entity_id: input_boolean.gate_moving
- delay: 00:00:30
- service: input_boolean.turn_off
entity_id: input_boolean.gate_moving
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment