How to simply test automations to open garage door?

OK so I am most probably just a bit lost from just starting out with HA. I am a previous Homey user but now running HA OS on dedicated x86 system.

I want to test to create my first really usable automation:

TRIGGER: Time 23:00 each day
…Garage doors are open
…Close both garage doors (left and right)
…Push notification that I forgot the garage doors but HA closed them for me

I have iSmartgate and I can successfully control the garage doors from buttons on the dashboard, but have no idea how to open/close them from an automation.

This is a very basic automation with a Time Trigger set to trigger at 23:00:00. The automation’s condition checks if either door is open. If at least one door is open, the automation’s action sends a command to close both doors. Finally, it sends a notification reporting what it did.

alias: example 345
- platform: time
  at: '23:00:00'
- conditions:
  condition: or
  - condition: state
    entity_id: cover.garage_door_1
    state: 'open'
  - condition: state
    entity_id: cover.garage_door_2
    state: 'open'
- service: cover.close_cover
    - cover.garage_door_1
    - cover.garage_door_2
- service: notify.your_phone
    message: 'Automatically closed the garage doors.'

Perhaps you only want to close the doors if both are open, or only close the door that’s open. Let me know and we can tailor the automation to suit your requirements.


Added a notification.

1 Like

Wow! I am really impressed about the level of support here. I find it easiest to learn from others examples which makes it very clear so I really appreciate your help! Hopefully next one I will be able to know better.

Yes would be good to be granular:

  • If left door is open at 23:00, then close that one and notify me about “You forgot to close the left door so HA did that for you”.
  • If right door is open at 23:00, then close that one and notify me …

So independent of eachother I guess you can say.

Want to keep it as basic as possible now during learning process, but intend to combine with last motion from garage motion sensor later too. But that’s for later :slight_smile:

Here’s a more advanced example that only closes open doors and reports whatever it closed via a notification.

alias: example 345
  doors: ['cover.garage_door_1', 'cover.garage_door_2']
  doors_open: "{{ expand(doors) | selectattr('state', 'eq', 'open') | map(attribute='entity_id') | list }}"
- platform: time
  at: '23:00:00'
condition: "{{ doors_open | count > 0 }}"
- service: cover.close_cover
    entity_id: "{{ doors_open }}"
- service: notify.your_phone
    message: "I closed the following: {{ expand(doors) | selectattr('state', 'eq', 'open') | map(attribute='name') | list | join(', ')  }}"
1 Like

You should also add a check to see how long the door has been open, if you just opened it 30s ago because you are moving cars or something, you do not want it to close unexpectedly.

You can also do what a MyQ hub does, which is flash a light and beep when the door is about to be closed, but that will require extra hardware

That’s good advice and part of a larger discussion of how to safely control devices that can cause harm to people or property.

We don’t normally close the garage door without an initial visual inspection but do have a means to close it remotely (via the alarm system’s keypads or via the Lovelace UI). In my case, I made it report a voice announcement, in the garage, warning of closure in 10 seconds.

In addition, if we arm the alarm system in away mode (no one is home) and the garage door is left open (we forgot to close it or it failed to close) the system attempts to close it (includes 10 second warning). After a predetermined time has passed (sufficient to let the door close under normal conditions) it reports (via notification) whether it succeeded to close the door or failed.

Other than that, no other automation logic controls the garage door (and it’s purposefully excluded from Alexa’s control). There’s an automation that warns us if any exterior door is left open late in the evening (so we can manually close it before bedtime).

Yes I have the iSmartGate system. So the wifi hub mounted in the garage roof beeps loud and clear like 5 seconds before the doors starts moving. But yes a delay would be good of course. Thanks for the tip :slight_smile:

Is there a way to have your variable grab all cover entities if they are open or opening? Instead of having to list them all out one by one?

In the spirit of automation I’d rather set this once and then never have to touch it again, even if I rename or change my cover entities in the future.

For example:

  covers: {{ **select all cover entities here** }}
  covers_open: "{{ expand(covers) | 
    selectattr('state', 'eq', 'open' **OR opening **) | 
    map(attribute='entity_id') | list }}"

Also a side note, instead of using time as the trigger, I adapted this to use my ‘sleep’ scene as the trigger. Here’s the code for anyone interested:

  - platform: event
      domain: scene
      service: turn_on
        entity_id: scene.sleep
    event_type: call_service
{{ states.cover | map(attribute='entity_id') | list }}

Awesome, thanks. Any idea how to tell it to monitor state open and opening? There is an edge-case example where the door is in the process of opening and this automation would ignore it.

Use Jinja2’s “intest.

{{ states.cover
    | selectattr('state', 'in', ['open', 'opening'])
    | map(attribute='entity_id')
    | list }}

Works great! I’m still learning Jinja2 but I’m starting to see patterns here. Looks like eq = equals/exact match and in = any from this list. Very cool, thanks.