I’m trying to set up what I think should be a cover to control BOTH a garage door and a driveway gate simultaneously. The logic is that when I click a button (think the digital equivalent of a garage remote control… just a binary switch/button) it will open both the garage door and the driveway gate. And when I click to close it will close BOTH the garage door and the driveway gate.
I think the way to do this is set up a cover with a garage door class and then use a template to determine the logical state based on the actual state of the garage and gate. So if anything is open it is considered open, and if everything is closed it is considered closed.
My problem is that I now need to set up the cover as a garage door and try to integrate all of my logic. The reason I want a cover is because I would like for this to show up on my Apple Car Play screen in my car just like the garage door does today. So I need it to be a garage cover so that it will show up in the CarPlay screen.
And specifically the problem is that I cannot figure out how to trigger an action in the cover. So the question is, how can I trigger an automation or a script (or simply change the state of an entity so that I can set up an automation to monitor that and then take action).
Here is what I have working so far:
I’ve set up four unique automations that get initiated when the state of a helper button changes (when I click the button on the card). When I click the button, each of 4 automations will run, performing the following (in parallel I guess):
- If both the garage door and the gate are closed, then open them.
- If both the garage door and the gate are open, then close them.
- If the garage is open and the gate is closed, then close the garage.
- If the gate is open and the garage is closed, then close the gate.
Only one of those can be true at a time, so each of the four can be triggered on the same state change and not be a problem. I tested this using LEDs to represent the garage and gate. I can set them up as open (on) or closed (off) in various states and by pressing the one button the automations do in fact do what I want.
I have also set up a cover that shows the status of the “logical garage door” (combined state of the garage and gate… in other words “closed” if both are closed, “Open” if both are open and for now “Unknown” if either is open but not both).
At this point all I need is a mechanism from within the cover to trigger my automations. I can’t figure out how to do this (or IF it’s feasible). Does anyone have a way for me to achieve what I’m trying to do?
Thanks in advance.
-Pete
FYI I was able to resolve this issue. The way I did that was to call a script as the action from the Cover like this:
- platform: template
covers:
garage_door:
device_class: garage
unique_id: "driveway_door"
friendly_name: "Driveway Door"
value_template: >-
{% if states('binary_sensor.esp32gate_gate') == "on" %}
{% if states('scene.garage_door') == "on" %}
open
{% else %}
gate
{% endif %}
{% else %}
{% if states('scene.garage_door') == "on" %}
garage
{% else %}
closed
{% endif %}
{% endif %}
open_cover:
- service: script.driveway
close_cover:
- service: script.driveway
icon_template: >-
{% if is_state('cover.driveway_door','on') %}
mdi:garage-open
{% else %}
mdi:garage
{% endif %}
I then wrote a script that when executed selected one of four choices:
- Close the garage door if that’s the only thing open
- Close the gate if that’s the only thing open
- If all are closed, then open BOTH the garage and the gate
- If all are open, then close BOTH the garage and the gate
The script looks like this:
alias: Driveway
sequence:
- choose:
- conditions:
- condition: template
value_template: |-
{% if states('binary_sensor.esp32gate_gate') == "on" %}
{% if states('scene.garage_door') == "on" %}
false
{% else %}
false
{% endif %}
{% else %}
{% if states('scene.garage_door') == "on" %}
false
{% else %}
true
{% endif %}
{% endif %}
sequence:
- type: turn_on
device_id: 3e6044f5445c67deb0ae3d505ce476ca
entity_id: bac63e38c9485ede2aa5655e1b7043a1
domain: light
- type: turn_on
device_id: 3e6044f5445c67deb0ae3d505ce476ca
entity_id: 42a2d2f0b7e178cfb6c59b374f5c04e3
domain: light
- conditions:
- condition: template
value_template: |-
{% if states('binary_sensor.esp32gate_gate') == "on" %}
{% if states('scene.garage_door') == "on" %}
true
{% else %}
false
{% endif %}
{% else %}
{% if states('scene.garage_door') == "on" %}
false
{% else %}
false
{% endif %}
{% endif %}
sequence:
- type: turn_off
device_id: 3e6044f5445c67deb0ae3d505ce476ca
entity_id: 42a2d2f0b7e178cfb6c59b374f5c04e3
domain: light
- type: turn_off
device_id: 3e6044f5445c67deb0ae3d505ce476ca
entity_id: bac63e38c9485ede2aa5655e1b7043a1
domain: light
- conditions:
- condition: template
value_template: |-
{% if states('binary_sensor.esp32gate_gate') == "on" %}
{% if states('scene.garage_door') == "on" %}
false
{% else %}
true
{% endif %}
{% else %}
{% if states('scene.garage_door') == "on" %}
false
{% else %}
false
{% endif %}
{% endif %}
sequence:
- type: turn_off
device_id: 3e6044f5445c67deb0ae3d505ce476ca
entity_id: 42a2d2f0b7e178cfb6c59b374f5c04e3
domain: light
- conditions:
- condition: template
value_template: |-
{% if states('binary_sensor.esp32gate_gate') == "on" %}
{% if states('scene.garage_door') == "on" %}
false
{% else %}
false
{% endif %}
{% else %}
{% if states('scene.garage_door') == "on" %}
true
{% else %}
false
{% endif %}
{% endif %}
sequence:
- type: turn_off
device_id: 3e6044f5445c67deb0ae3d505ce476ca
entity_id: bac63e38c9485ede2aa5655e1b7043a1
domain: light
mode: single
icon: mdi:garage