How do I make HA to recognise that I have left home?

Hi all,
I have tried to set up an a simple automation to send a message to my phone once it recognises that I have left home. This is just a very basic automation to teach HA for myself.
I have searched other threads have tried to use others methods.
It is not working and I am hoping that someone can point me in the right direction.
The log files does not show anything to suggest that I have left home. Nor does the automation trace.

Here is the code for the automation:

  alias: Leaving home
  description: ''
  trigger:
  - platform: zone
    entity_id: device_tracker.sm_s906e
    zone: zone.home
    event: leave
  condition: []
  action:
  - service: notify.mobile_app_sm_s906e
    data:
      message: Leif has left home
  mode: single

This is in my configuration.yaml:

zone:
  - name: Home
    latitude: -33.92915052269982
    longitude: 150.85428050653093
    radius: 100
    icon: mdi:castle

Please help if you can.

Do you have access to Home Assistant from outside your home?
DNS/Nabu casa account?

Hi,
Yes to both and that bit is working fine.

Have you followed the guide how to fix tracking issues?

I have followed another thread ( Leaving or Entering Home Zone will not trigger any automation - Configuration - Home Assistant Community (home-assistant.io) and found that my zone.home was not set up properly. I fixed that problem hoping it was the solution but no luck.

Is there an official or other guide I can refer to? I have been doing lots of searching and the above thread seemed the closest to my problem.

BTW, thanks for responding, much appreciated.

Update: I have used this guide - Zone - Home Assistant
That was what fixed my zone.home issue.
For some reason the trigger is not working.

The way I do this is pretty reliable.


platform: device
device_id: c3c350836d270a6ab7f59a03403e1d18
domain: device_tracker
entity_id: device_tracker.richs_phone
type: leaves
zone: zone.home_2
'''

 Use the device as a trigger, not the zone.
Literally works 100% of the time.
1 Like

Thanks
I will try and see if I can make it work and report back.

Your automation works fine for me. I use similar code without any issues. You can test it by amending the longitude/latitude of your device tracker in developer tools. Maybe check that your device tracker is reporting correctly…

alias: leave home
description: ''
trigger:
  - platform: zone
    entity_id: device_tracker.le2123
    zone: zone.home
    event: leave
condition: []
action:
  - service: notify.notify
    data:
      message: you have left home
mode: single

Thank you very much for the feedback, much appreciated.
I will check my coordinates again.
Feedback like this makes me feel like I’m not totally hopeless.

Follow the steps here

Hi all,
I double checked my GPS coordinates and now it works both with zone and device as platforms.

All good, thanks for your help. Much appreciated.

1 Like