Open garage door automatically with multiple checks to ensure it's me

I have a Wemos D1 Mini Pro v2 on my motorcycle, and following this guide (https://github.com/aderusha/MQTTCarPresence), I’m able to get it to show when the bike is present by when it’s connected to my network. I’m also using the Android Companion App (tell HA if I’m home or away) and Frigate (to detect a motorcycle object in the driveway).

CLOSING the garage door when I leave:

This is my process when I’m getting ready to leave the house on the motorcycle: I pull the motorcycle out of the garage and park it in the driveway before I start it. Frigate confirms there’s a motorcycle in my driveway. I then start the bike (which turns on the Wemos and has it connect to my home network), and have the garage door close while the motorcycle is still in the driveway. I don’t want it closing after I leave. I want to be sure it’s going to close. I also don’t want it to close before I start the bike. This automation works well in my testing thus far.

Here’s the YAML for closing the garage door when I leave:

alias: Garage Door - Close - Leaving on the bike
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.vehiclepresence_cb1000r
    to: "on"
    from: "off"
condition:
  - condition: and
    conditions:
      - condition: state
        entity_id: cover.garage_door
        state: open
      - condition: state
        entity_id: binary_sensor.cam_driveway_2_motorcycle_occupancy
        state: "on"
      - condition: state
        entity_id: person.husband
        state: home
action:
  - device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    domain: cover
    entity_id: cover.garage_door
    type: close
    enabled: true
  - device_id: yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
    domain: mobile_app
    type: notify
    message: Leaving home on the bike.  CLOSING garage door.
mode: single

OPENING the garage door when I get home:

This is where I’m having trouble…

alias: Garage Door - Open - Arriving on the bike
description: ""
trigger:
  - platform: state
    entity_id:
      - person.husband
    from: not_home
    to: home
condition:
  - condition: and
    conditions:
      - condition: state
        entity_id: cover.garage_door
        state: closed
      - condition: state
        entity_id: binary_sensor.cam_driveway_2_motorcycle_occupancy
        state: "on"
      - condition: and
        conditions:
          - condition: state
            entity_id: binary_sensor.vehiclepresence_cb1000r
            state: "on"
          - condition: numeric_state
            entity_id: sensor.vehiclepresence_cb1000r_uptime
            above: 180000
        alias: CB1000R is on for at least 3 minutes
      - condition: zone
        entity_id: person.husband
        zone: zone.home
action:
  - device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    domain: cover
    entity_id: cover.garage_door
    type: open
  - device_id: yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
    domain: mobile_app
    type: notify
    message: Arriving home on the bike.  OPENING garage door.
mode: single

Maybe my order is wrong, or my checks. I’m wondering if HA is seeing me as Home before the Wemos connects to my network and shows up in HA. However, this is not working.

What I’m wanting, is to ensure that it is ME pulling up to the house on the bike. I want it to detect me from the app, and detect the bike’s Wemos. However, I sat outside for far too long and ended up opening the garage manually when the automation wouldn’t work. Any thoughts here?

Also, I would like to set a state or something to tell HA that I am away from the house and am on the motorcycle. How can I go about doing that? That way, I could maybe call that variable when I’m home to then open the door. Thinking out loud here. How would you setup this automation to open the garage door? So many examples only check that the wemos connects to the network, and I need more piece of mind than that.

I think you need more triggers. When you arrive home on the bike it’s going to check all those conditions listed. If any of them is false then the garage won’t open. End of story. No amount of waiting will change anything. The only trigger is you arriving home, if the condition evaluate to false at that moment in time it will not trigger again until you leave home and come back.

Generally the recommendation is add a duplicate trigger for every condition you have listed. That way it will try to fire the automation anytime anything its condition depends on changes but only get through the condition when every entity is in the right state.

In your case it seems like the problematic one is the wemo. Because you and it arrive home close together and can’t guarantee the order ha sees them in. So probably add another trigger for that:

trigger:
  - platform: state
    entity_id:
      - person.husband
    from: not_home
    to: home
  - platform: state
    entity_id: binary_sensor.cam_driveway_2_motorcycle_occupancy
    to: 'on'

Can continue with the others if they are causing issues as well. Or alternatively drop the condition entirely and just use a giant template trigger:

trigger:
  platform: template
  value_template: >-
    {{ is_state('person.husband', 'home') and
      is_state('cover.garage_door', 'closed') and
      is_state('binary_sensor.cam_driveway_2_motorcycle_occupancy', 'on') and
      is_state('binary_sensor.vehiclepresence_cb1000r', 'on') and
      states('sensor.vehiclepresence_cb1000r_uptime') | int(0) > 18000 }}

Then it only triggers when the condition made into a template evaluates to true.

1 Like

Thanks! I’m pretty new to HA and this is my first real automation in it.

Your proposed fix worked great for opening the garage door… But unfortunately, it triggered it not 15 seconds or so after the ‘departure’ automation closed the door. Any ideas there? I did disable the vehicle presence uptime condition, as I don’t know why my logic was there, but I think that may be needed to ensure the garage door doesn’t open immediately after closing. What’s odd is that the presence of my entity is set to trigger from not_home to home, and that didn’t occur, as I didn’t even leave my driveway.

I also didn’t utilize the templates (I need to look into that some more), but just added my conditions to triggers as you suggested.

you likely added the door closing condition as a trigger.

remove it.

SMH, that makes sense. Thanks! I’ll test it out some more today.

Thinking about it though, how would I go about being able to make a state or variable for the “leaving” automation to store a value, and for the “arriving” automation to call and update it? I’m thinking of when I leave, a variable of awayOnBike, setting it to true, would give me something to recall from another automation, as well as display on the dashboard for my wife.

Create an input text entity that is set to the desired value by the automation.

1 Like

Hi, I was thinking about using an old phone to trigger opening my garage door, but this seems much easier, how do you have the Wemos connected to the bike?