Open garage when coming home by car

In the past I only used the device_tracker of my router to check, wheather I am home or not. I just recently enabled the device_tracker on the Android Companion App with the default settings:

  • Background Location: Enabled (High accuracy mode: Disabled - Minimum Accuracy: 200)
  • Location Zone: Enabled (Minimum Accuracy: 200)
  • Single Accurate Location: Enabled (Include in sensor update: Disabled - Minimum Accuracy: 200 - Minimum time between updates: 60000)

I noticed that this device_tracker not only provides a home/not_home state alongside the lat/long as attributes, but also a speed. The garage is separated from my house. Therefore I only need to open it, when comming home by bike, or car. When I took a walk, I do not need the garage to open and walk directly into the front door.

I figured, that the device_trackers speed attribute may be of benefit to differentiate if I am walking, riding a bike, or driving. I was thinking of a simulation just like this:

- alias: Garage - Open garage when coming home
  id: 'garage_open_when_coming_home'
  - platform: zone
    entity_id: person.john_doe
    zone: zone.home
    event: enter
  #This automation should only be triggered, if coming home via bicycle, or car. 
  #For this the device trackers speed is evaluated.
  - condition: template
    value_template: "{{ (state_attr('device_tracker.john_doe', 'speed') | float) > 2.8 }}" #m/s ~ 10km/h
  - condition: state
    entity_id: cover.garage
    state: 'closed'

  #Open the garage
  - service: cover.open_cover
    entity_id: cover.garage

So far I noticed, that the speed is not very reliant and often drops underneath the threshold, just as I enter my home zone.

Did you guys make similar expieriences? I’m curious if there are other solutions to this issue, without using the battery consuming high accuracy mode.

The way I have mine set up is a bit involved but could give you ideas to implement your solution.

First, I created a person from my relevant device trackers:

  - name: me
    id: me_id
    user_id: xxxxxxxxxxxxxxxxxxxxx
      - device_tracker.phone_me
      - device_tracker.phone_me_ip
      - device_tracker.life360_me
      - device_tracker.me_mobile_app

then I created a proximity sensor for my home zone:

      - device_tracker.life360_me
    tolerance: 50
    unit_of_measurement: ft

then for the automation I did the following:

  - id: gd_auto_open_north_garage_door
    alias: GD Auto Open North Garage Door
      - platform: numeric_state
        entity_id: proximity.home_me_ft
        below: 1000
      - "{{ state_attr('proximity.home_me_ft', 'dir_of_travel') == 'towards' }}"
      - "{{ '84:DD:20:62:FA:FE' in state_attr('sensor.me_mobile_app_bluetooth_connection', 'connected_paired_devices') }}"
      - condition: state
        entity_id: cover.north_garage_door
        state: 'closed'
      - service: script.open_gdn

The automation triggers at below 1000 ft from my home zone then checks that I’m going towards home and that my phone is connected to my vehicle radio bluetooth since if I’m not in my vehicle I don’t need the door to open. If you don’t have this data you could modify this condition to check that your speed is greater than your desired value if necessary.

and the script is simple (my garage door uses a single toggle to both open and close it so I just make sure it’s closed before it tries to open it, otherwise it will close it if it’s already open):

    alias: Open the North Garage Door
      - condition: state
        entity_id: binary_sensor.garage_door_north_position_sensor
        state: 'off'
      - service: switch.turn_on
        entity_id: switch.garage_door_north_operator_switch

I did this way with a D1 plug into the cigarette lighter (us oldies know what that is)

Auto garage door open when getting home:

The companion app activity sensor tells the system whether you are in the car, or biking or walking.

Also the companion app bluetooth sensor will tell whether the phone is connected to to your car bluetooth.

1 Like

in the past i only used the device_tracker of my router to check, whether I am home or not.
PupilPath Login

In my automation I added sensor that checks car presence in the garage. So to open the garage I use the trigger of entering the home zone and the condition that car is not in the garage.

@nickrout The activity sensor seems to be very promising. The only issue I currently have is that both, the speed and the activity are mostly updated close to the event when entering the home zone.
I read somewhere that some have a second extended home zone to discover entering/leaving the home zone.
The current home zone itself has the default radius.

Edit: Maybe I can use the Proximity Integration for it

@mirekmal That sounds quite interesting and at least considering the specific use case seems to be quite a reliable way to detect if the garage needs opening.

@finity I must have overread your post and just saw that you are doing exactly what I was thinking about. Using a proximity integration combined with the paired bluetooth device to figure out wheather or not the garage needs opening.

My automation now looks like this:

- alias: Garage - Open garage/gate when coming home
  id: 'garage_open_when_coming_home'
  - platform: numeric_state
    entity_id: proximity.home
    below: '1'  # km
  condition: "{{ state_attr('proximity.home', 'dir_of_travel') == 'towards'}}"

  #Open the garage
  - choose:
    - conditions:
      - condition: state
        entity_id: cover.garage_door
        state: 'closed'
      #Open the garage only, if person approaching home is
      # driving the garage car (activity is 'in_vehicle' and bluetooth is connected to the garage car), or
      # cycling
      - condition: >
          {{ states('sensor.oneplus_6t_detected_activity') == 'on_bicycle' or 
              states('sensor.oneplus_6t_detected_activity') == 'in_vehicle' and 
              state_attr('sensor.oneplus_6t_bluetooth_connection', 'connected_paired_devices') == 'B4:EC:02:97:C9:D5'
      - service: cover.open_cover
        entity_id: cover.garage_door
    default: []
  #Open the gate
  - choose:
    - conditions:
      - condition: state
        entity_id: cover.gate
        state: 'closed'
      #Open the gate only, if person approaching home is
      # driving a car (activity is 'in_vehicle'), or cycling
      - condition: "{{ states('sensor.oneplus_6t_detected_activity') in ['in_vehicle', 'on_bicycle'] }}"
      - service: cover.open_cover
        entity_id: cover.gate
    default: []
Configuration of Proximity Integration
      - person.john_doe
    tolerance: 50

Now I only need to play around and figure out, which value for the proximity integration is suited best. However today I took a little tour with the bike and the proximity integration did not look too promising…

I was gone between 02:05:06pm and 04:28:37pm if I trust in my Fritz!Box Device Tracker. The Android Companion App logged me as away at 02:20:22pm and 04:26:19pm at back home.
The proximity integration in the meantime only received 3 measurements:
One at 02:22:04 logging me as 4km away
One at 02:24:03 logging me as 5km away
A last one at 04:26:19 (same as the apps device tracker) logging me at 0km away.

With these data I can forget about the automation above.

That picture doesn’t look like it only got three measurements. it looks fairly continuous.

Where are you only seeing those three measurements and how is that different than the picture?

At least the mouse over only shows datapoints at the given times. So I assume the graph only draws a straight line between measurements.

I will continue to monitor the behavior, potentially I could use high accuracy mode on the companion apps position tracking , which will use more battery… or try Google maps integration instead. But maybe someone has got some tips on the Android Companion App in general.

Use the high accuracy mode when you are connected to a bluetooth in the car.
If you don’t have a bluetooth in the car then there are very cheap ones that is great.

Google maps is nothing but pain.
And when you get it set up it’s slow to respond, at least for me last year

Okay, I monitored again today the situation on my commute to/from work. It seems that with the current settings, the device tracker of the companion app is only updated very sparsly. I have seen updates come in after more than 13minutes. This update rate is too slow to trigger a geo fence around my home zone.

How do you enable high accuracy mode only under certain conditions? Is this possible from the home assistant side, or does this need to be performed using Tasker or the like?
How come the Google maps integration is a pain? The location of the family members are very frequently updated ~2-3minutes looking at Google maps itself. I don’t know anything about the home assistant integration of it.

Open the app settings and enable high accuracy mode in some of the location settings.
You can enable it with Bluetooth or on proximity if i recall correctly.

Google is a pain to set up. It’s very hard and many spend many hours trying to get it set up.
Even if you manage to get updates every 2 minutes as you say, high accuracy mode can be set to seconds between updates.

Ah, perfect. I found the description for the additional options in the documentation

As such it becomes clear, where I have read about the extended zone. There is another option that enables high accuracy, only when near to a certain zone. This may also help, but on today’s experiences, my background location was only updated once or twice between work and home zone, so I assume the extended home zone would not have been triggered…

Bluetooth is better and more accurate.
This one is great if you don’t have Bluetooth in the car Bluetooth Decoder Modified Bluetooth 4.1 Circuit Board Xy-Bt-Mini Durable U M4S7 193571334114 | eBay

Thanks the car is not the issue, they both have Bluetooth. It’s just on my bicycle, I am not always wearing my Bluetooth headsets and additionally I thought, high accuracy does not require to be on for the full ride. I usually leave the phone in my pocket and don’t connect it to the charger in the car. But you are probably right, that it will give me more reliable feedback.