iPhone Entering Home Zone does not trigger any automation

Desired Scenario:

  • I want a spoken announcement on my house-wide SONOS system whenever I arrive home (or to be more precise, whenever my iPhone arrives home). If music is playing, it is temporarily suspended when the mp3 announcement is being played and then should resume afterwards. (This works fine on my Motion Detected announcements, which incidentally still works fine if I approach the front door.)
  • I’m running the mobile HA app on my iPhone 14, with app background refresh enabled, and the app can ALWAYS use my location (and precise location enabled). Latest version of IOS.
  • I have an almost identical automation code to announce front door motion detected by my Ring doorbell, which as I said works just fine. (For reasons of brevity, I have not included it, but could if requested.)
  • I’m only interested in the audible notification when somebody (for test purposes, me) arrives home. Couldn’t care less if they’re leaving.

Observed Scenario:

  • When arriving home, absolutely nothing happens. The iPhone Automation is not triggered. (If I trigger it manually, everything works fine and I get the correct announcement house-wide.)
  • Also, looking at the Diagnostics for the iPhone, it seems to show it is at Home the whole time. I would at least expect it to be Unavailable as it drops off the WiFi network and then indicate Home again once I get within range of the WiFi. Maybe I’m misunderstanding how this should work.
  • I’m using the default Home zone created by HA, which shows the house correctly centered on the map.

The automation code for the iPhone-arriving-home segment is given below:

- id: '1687818094635'
  alias: Darrell Arriving Home
  description: Test for Spoken announcement of me arriving home
  trigger:
  - platform: device
    device_id: 0a49f61e8e7dd8c9ece900962d2ee17e
    domain: device_tracker
    entity_id: device_tracker.darrells_iphone
    type: enters
    zone: zone.home
  condition: []
  action:
  - service: sonos.snapshot
    data:
      with_group: true
      entity_id: media_player.kitchen_sonos_1
  - service: media_player.play_media
    data:
      media_content_id: /local/sounds/darrell_arriving_home.mp3
      media_content_type: music
  - delay:
      hours: 0
      minutes: 0
      seconds: 3
      milliseconds: 0
  - service: sonos.restore
    data:
      with_group: false
  mode: single

It likely happens, but you’re not home to hear it.

If you want it to be more PRECISE when you actually ARRIVE, use a different trigger such as when your iPhone connects to your home wifi network.

Edit:
Actually - I re-read your post, and if you never show away, that’s not going to work, since you never “enter” home. Sounds like your location is messed up. In order to “enter” a zone, you must be coming from another zone, not from “unavailable”.

Ah. Now there’s an interesting piece of information. Thanks.

I know it’s not triggering, because the diagnostics (and my wife, which sometimes is the same thing) tell me so.

Are you suggesting set up a dummy zone outside of Home and that once my phone enters that, or transits though it, it should work once it enters the ‘home zone’? (Hmmm, wonder if it’s possible to set up a virtual zone that is everywhere, but home?)

You say you’re using the mobile HA app (which I assume to be the companion app). Can this access your HA instance when not connected to your wifi? If it cannot, then it can’t update your location to anything other than home. Does the device tracker entity actually ever change to “not_home”?

Have you confirmed that your Home Zone is where it’s supposed to be and has an appropriate size?
Settings - Areas and Zones - Zones.

I know when I spin up a new instance of HA it always shows my Home Zone is in Amsterdam.

Re-read your post and realized you’ve already checked this.

Edit:
You can test the automation in Developer Tools - States.

For the entity select person. and confirm it shows the state as ‘home’. Change it to not_home and click the Set State button. That should at least trigger the automation.

I believe you do need to have external access to HA from the phone for this to work since it’s using GPS to determine your location and updating HA as it changes. Do you use Nabu Casa or port forwarding to access HA remotely?

" In order to “enter” a zone, you must be coming from another zone, not from “unavailable”."

Are you sure about that? I though that you could have only one zone (Home) and be shown as either home or not_home based on GPS data.

That’s correct, you can have only a home zone - but he’s never “not home”. He’s only “home” and “unavailable”.

To be honest - I’m not completely positive, but when I had an issue with my wife’s phone, that seemed to be the culprit. It was quite a while ago though, so the details are kind of fuzzy in memory… Perhaps a dev can add some additional insight?

Firstly, thanks to everyone for taking the time to look at my problem and make suggestions.

To your question about cell-access. Nope. I can only access Home Assistant when I’m connected to my local WiFi - no cellular access to my home HA when I’m away from the house.

So, I think I am starting to see the problem:

  • When I’m home and on the WiFi, the companion HA app knows I’m home (GPS coordinates inside the Home zone) and can inform the HA server, but

  • When I leave home, the HA companion app will know I’ve left the zone, as the GPS coordinates will be outside the Home zone, but now it has no way of telling the HA server as I’m no longer on the WiFi

  • When I get back home, the HA app knows I’m back in the Home zone AND WiFi has been reestablished, so it can let the HA server know that. However, all the HA server actually knows is that I was home, and now I’m back (or still at) home - it doesn’t see a location change.

Damn. And I thought this will straightforward. So, it seems the only solution would be for my HA server to be visible over cellular to my (and my wife’s) phone(s), so it can communicate the location changes. Seem logical?

Is there a cheap and easy way of getting cellular access to my home HA server? (My WiFi is Google Mesh, so there’s not much scope for configuring the router for weird ports or access.)

To access HA externally then you can either:

  1. HA-> Settings → Home Assistant Cloud and set up Nabu Casa paid service

or go for the more complex route of

  1. DuckDNS/ Lets Encrypt / NGNIX reverse proxy

I run HA app on my phone using 2) remote method above, and have set up the Proximity Sensor on HA which will trigger an automation when I am (my phone) within a certain distance AND traveling in the direction of my house. I have another automation when I am a certain distance away AND traveling in the direction away from my house.

Do not ask about method 2) as it took me a while to set up but there are loads of posts on setting up remote access. Good luck!

I’m not sure there’s much point in using the companion app if it doesn’t have access outside the house. If you use the NGINX Proxy Manager addon it’s relatively simple, although it has the pre-requisite of also needing the MariaDB addon. The only requirement for your google mesh is to forward ports 443 and 80 to your HA instance, which I understand from here can be done.

Having said that, the companion app will set you as home when you enter the home zone, which defaults to a 100m radius. If you’re making an announcement for others that are home, that won’t be a problem, but don’t expect to hear the announcement yourself from down the street.

Alternatively, don’t use that device tracker. Somebody has built a google nest integration (installed via HACS) that you could try. However, I believe modern phones have can disconnect from wifi when idle to conserve battery power. Therefore it might think you’re not home when you are, and then when you next use your phone it would see you as coming home.

Hey Michael.

Thanks. Yes, the announcement is only for people who are home. ultimately, what I’ll be going for is:

  • If I’m arriving home (and my wife is already home), then make the appropriate announcement

  • If my wife is arriving home (and I’m already home), then again, make the appropriate announcement

  • If neither of us is home, make no announcement

I’ll look in to that Google nest integration. A quick scan of the article shows promise. I’d rather avoid port forwarding if at all possible (20 years in cybersecurity makes me a little nervous of that), but if it’s the only option, then so be it.

Once again. Many thanks.

There is no need for nginx, you can simply put a cert on HA and port forward to it, then use local dns to resolve the host name internally so no cert errors.

Or, as others have mentioned, nabu casa.

I must admit to some curiosity though - with 20 years in IT, how were you thinking that home assistant would know your location when you weren’t connected to the network, and home assistant wasn’t available externally, meaning no communication between the two? Seems an odd oversight to me given your background. Just curious is all, I mean no disrespect.

I think I might have a more elegant solution to this problem. However, it would only work in an Apple ecosystem.

  1. Create a HA Helper, which is nothing more than a boolean toggle (actually, two - one for my wife and one for myself). I called these Me_Home and Wife_home. Their state is on when we’re at home, and off when we’re not at home.
  2. Use the transition of these from Off to On to trigger the appropriate automatons within HA
  3. Ensure these boolean toggles are exported/visible to Apple’s Home app (using configure Homekit option)
  4. In the Apple Home app, using the templates that trigger automation when somebody arrives, I can select the person (either myself or my wife) and then toggle the boolean ON. Likewise, I can use the Home template for when somebody leaves home to toggle the boolean OFF

Seems to work fine for me, but haven’t managed to get my wife’s iPhone to trigger the automation assigned to her yet. Hoping the Apple support community can shed some light on that issue. If I can make this work, it seems a lot better than messing around with giving HA access while not on WiFi as Apple already handles this via iCloud.

1 Like