-
-
Save Vaarlion/362314ccfa4f898e26043d72d1745b54 to your computer and use it in GitHub Desktop.
A Home assistant example packages to add extra logic from a gate with a single button to both open and close
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gate: | |
cover: | |
- platform: template | |
covers: | |
gate_positioned: | |
unique_id: 2ef2c7b038dba437f3b246d136652f37 | |
device_class: gate | |
friendly_name: "Gate" | |
open_cover: | |
service: script.open_gate | |
close_cover: | |
service: script.close_gate | |
stop_cover: | |
device_id: b56e9f01be0b67b5cae6a34b7988c758 | |
domain: cover | |
entity_id: cover.gate | |
type: stop | |
position_template: >- | |
{% if is_state('binary_sensor.gate_state', 'on') and is_state('binary_sensor.gate_closing', 'on') %} | |
50 | |
{% elif is_state('binary_sensor.gate_state', 'on') and is_state('binary_sensor.gate_closing', 'off') %} | |
99 | |
{% else %} | |
0 | |
{% endif %} | |
availability_template: "{{ not is_state('cover.gate','unavailable') }}" | |
script: | |
open_gate: | |
alias: 'Open gate' | |
sequence: | |
- device_id: b56e9f01be0b67b5cae6a34b7988c758 | |
domain: cover | |
entity_id: cover.gate | |
type: open | |
- wait_for_trigger: | |
- platform: state | |
entity_id: | |
- binary_sensor.gate_closing | |
to: 'on' | |
- platform: state | |
entity_id: | |
- binary_sensor.gate_state | |
to: 'off' | |
timeout: 00:00:03 | |
continue_on_timeout: false | |
- device_id: b56e9f01be0b67b5cae6a34b7988c758 | |
domain: cover | |
entity_id: cover.gate | |
type: stop | |
- delay: | |
hours: 0 | |
minutes: 0 | |
seconds: 1 | |
milliseconds: 0 | |
- device_id: b56e9f01be0b67b5cae6a34b7988c758 | |
domain: cover | |
entity_id: cover.gate | |
type: open | |
mode: single | |
icon: mdi:gate-open | |
close_gate: | |
alias: 'Close gate' | |
sequence: | |
- repeat: | |
while: | |
- condition: template | |
value_template: '{{ repeat.index <= 3 }}' | |
- condition: and | |
conditions: | |
- condition: state | |
entity_id: binary_sensor.gate_closing | |
state: 'off' | |
- condition: state | |
entity_id: binary_sensor.gate_state | |
state: 'on' | |
sequence: | |
- device_id: b56e9f01be0b67b5cae6a34b7988c758 | |
domain: cover | |
entity_id: cover.gate | |
type: close | |
- wait_for_trigger: | |
- platform: state | |
entity_id: | |
- binary_sensor.gate_closing | |
to: 'on' | |
- platform: state | |
entity_id: | |
- binary_sensor.gate_state | |
to: 'off' | |
timeout: 00:00:04 | |
- condition: template | |
value_template: '{{ wait.remaining == 0 }}' | |
mode: single | |
icon: mdi:gate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment