Presence Detection to Unlock Smart Lock

Hi all,

I’m trying to have Hassio detect my phone when I enter my Home zone and only unlock my smart lock when it detects that my phone has wifi re-connected.

I know how to make triggers for each of the above, but I can’t get the logic to work. I tried using a condition to “and” both triggers, but that doesn’t work as the logic would indicate that once I enter my home zone, my phone has to also connect to wifi at the same time? How can I have the home zone triggered and then have a time limit set so that, say, within 5mins, my phone has to connect to wifi in order for the unlock to happen?

Or is there a better way to do this? Just using the wifi trigger alone works, but what happens if I restart my phone at home? I don’t want the door to unlock because of that. I’m not sure how to use BLE if that is an option.

Any suggestions would be appreciated!

Thanks!

trigger:
  platform: zone
  entity_id: device_tracker.richard
  zone: zone.home
  event: enter
action:
  - wait_for_trigger:
      platform: state
      entity_id: binary_sensor.richard_phone_on_home_wifi
      to: 'on'
    timeout: '00:05:00'
    continue_on_timeout: false
  - service: lock.unlock
    data:
      entity_id: lock.door

Obviously I’m guessing on all the entity IDs and how you determine when your phone is on home wifi but this is basically what you described.

That being said, idk if I’d give this “unlock door” capabilities personally. Maybe its just me but automation that unlocks my door makes me a bit uncomfortable. Like for example, how close is your house to the road? If your house is pretty close to the road seems like this might trigger when you drove by.

Also if someone steals your phone then they could just walk into your house, no passcode for your phone or your door required. I mean I guess since they’d have to know that it’s not a huge risk but still.

And check to make sure your phone’s geolocation is actually tracking accurately enough for this. I feel like mine it can be a bit of a crapshoot whether it recognizes I’m home before I’m on my wifi. I’m not trying to time those events to unlock my door so I don’t really care but that would mess your automation up.

Thanks! I didn’t even know there was a “wait for trigger” option.

As for someone stealing my phone…they would need to know where I live and also that I have a smart lock triggered by my phone.

I’ll let you know if this works!

Thanks, it works…I took a little stroll down the street until it indicates that I’m away and then walked home, but Home Assistant took awhile to register me as “home” again. I have my Home Assistant app on my phone set to access location every minute.

Also, it seems like the wifi gets connected way before I’m in my home zone. I’m using a radius of 20m. Maybe I need to increase the radius to 50m.

Somehow I don’t think this would work if I’m driving home. It has to know I’m in the home zone first before the wifi gets connected (wifi signal is strong and gets connected far away). Maybe I should increase the timer too.

All this work because the August auto unlock doesn’t work well with Android.