iBeacons unusable when having a home zone - add subzones (solved with workaround)

Kind of rebooting Trigger automation with passive zones here as this is very related to the mobile app and I think Robbie is the right person to shine some light on it.

Spent some hours testing on this but I could have missed something, let me know then.

Situation:
iBeacons are located in the house. They should provoke an automation if an iPhone sees them (HA app reports this to HA). The house is in a relatively big zone.

Problem:
iBeacons only provoke an automation:

  1. via a zone change.
  2. if the zone is not overlapping with another zone.
  3. if the zone is not passive.

The result is that it only works when giving the iBeacon zone a false GPS location outside of the home zone and making it non passive. And the result of that again is that a person would be shown to be in a location where he/she is absolutely not.

Proposed solution:
Add subzones to HA. Home as a zone and subzones such as garage, bathroom, etc.

zones:
  - name: Home
    latitude: 123456
    longitude: 789101
    radius: 30
    icon: mdi:home
    subzone:
    - garage
      uuid: b429cee8-eff7-48e6-97b3-bbf5cc9fc52b
      major: 0
      minor: 1
    - bathroom
      uuid: b429cee8-eff7-48e6-97b3-bbf5cc9fc52b
      major: 0
      minor: 2

Then an automation could be:


- alias: Enter garage > light on
  trigger:
  - platform: zone
    entity_id: person.someone
    zone: zone.home
    subzone: garage
    event: enter
  action:
  - service: light.turn_on
    data_template:
      entity_id: light.garage

Hoping for some comments and then open a final one on Github maybe.

Here is my workaround:

Instead of using a zone change as trigger, use a template trigger on the longitude and latitude of the device. Compare it to the iBeacon zone. The zone should be passive so that only iBeacon can trigger it. When the device is in iBeacon range, it will take the exact lat and long numbers of that beacon’s zone, so have unique zone coordinates.

Example:

zone:
  - name: Garage
    latitude: 1.2345
    longitude: 6.7890
    radius: 0.3
    icon: mdi:garage
    passive: true
homeassistant:
  customize:
    zone.garage:
      track_ios: true
      beacon:
        uuid: 27c9d278-7712-4210-be69-0fb9613c1229
        major: 1
        minor: 2
- alias: iBeacon example garage light
  trigger:
  - platform: template
    value_template: "value_template: "{{ (states.device_tracker.device.attributes.longitude == states.zone.garage.attributes.longitude) and (states.device_tracker.device.attributes.latitude == states.zone.garage.attributes.latitude) }}"
  action:
  - service: light.turn_on
    data_template:
      entity_id: light.garage
  - delay:
      seconds: 5
  - service: notify.device
    data:
      message: "request_location_update"

In the automation, the action is performed, whereafter a position update for the device is triggered to ‘send’ it back to the main/previous zone. You might want to leave this out, or experiment with it.

Considering the GPS drift in iPhone coordinates, how might reliability be guaranteed? I use iBeacons to support arrival automation. The most recent HA releases have diminished reliability of the trigger.

It should not matter because when the iPhone sees the iBeacon, HA app will take the exact coordinates of the zone where the iBeacon is linked to.

OK. Currently I have two beacons, configured identically, marking my home zone. One inside the WiFi coverage and one outside WiFi coverage.The companion app sees the both beacons, but often times doesn’t pass zone coordinates to HA resulting in a failed trigger.

The app does not pass phone’s gps coordinates to HA when it sees a beacon. It tells HA that you are in the zone the beacon is linked to. For example, in testing I set up a zone 1000s KMs away from my current location. Once the app sees that beacon, it adopts the coordinates given to that zone in the configuration, and then will let HA know about that. (Not sure if it only passes the coordinates or already tells the zone name.)

I think if you set up your beacons to be linked to your home zone without it being passive, assuming you allow gps zone entering/leaving as well, you do not need anything from this topic. It should work unless the beacons don’t do their task properly.

I would find sub-zoning useful for defining home zone entry points. Looking for ways to reliably inform my HA server I’m home.

I’ll back out here and see what happens. HA zone configuration from the UI doesn’t support iBeacons.

Seems like something changed in the latest HA mobile app update. This makes the user actually enter the zone, something which is unwanted in my case. I am testing with radius 0 now, probably does not help. I saw that the 2020.4 update will have quite some changes to the location, so waiting for that before submitting a Github issue.

I don’t believe beacon zones should have changed in behavior - could you describe what you expect should be happening? 2020.4 is out and live now.

@zacwest, I’m not sure if my situation is the same as @Saturnus, but I’m seeing new behavior with the current App Store version of the app, 2020.4. I have “passive” beacon-based zones which have coordinates+radius inside my Home zone. My understanding of “passive” is that they should not set the state of device trackers, however with the latest app, my iOS device device_tracker location is being set to these passive zones. As a result, my “person” device thinks I am not “Home”, but instead thinks I’m in the beacon zone.

Besides turning off the beacons, are there other ideas to get this scenario to work?

Thanks,
Benjamin

My understanding of the previous location handling is mirrored in the new one:

  1. For GPS zones, enter and exits use the GPS information from the device as the location update.
  2. For Beacon zones, enters set the location to the Zone directly, without going through locations. Exits do not do anything.

If this differs from your understanding, I’d encourage you to make a GitHub issue so we can discuss it there. I’m unable to find anything materially different between 2020.3.1 and 2020.4 with regard to how beacon zones are treated.

@b3nj1 is describing the problem I am having too, yes. @zacwest

passive: true is not respected anymore now.

The app didn’t ever handle passive or not, so it must be some unexpected secondary effect. What do you expect the passive beacon zone to do?

Well hmm, I just literally tested it:
Pre 22 July update: device enters iBeacon zone, but does not take that zone as device tracker zone.
Post 22 July update: device enters iBeacon zone and does take that zone as device tracker zone.

What I personally need is an iBeacon to trigger stuff but not influence my zone. I mean, I am home and might use the iBeacon to toggle a light, then I should not enter zone.light. That is why I posted the workaround in the 2nd post. It still works but cannot prevent anymore that for the specified delay the device will be in the iBeacon’s zone in addition to having those gps coordinates.

If you’ve got the test setup already, would you mind turning on a higher debug level so we can see what the app is sending for both?

logger:
  default: info
  logs:
    homeassistant.components.mobile_app: debug

It will help me narrow down exactly what’s different. Feel free to redact the latitude and longitude information as much as you’d like, I don’t think the exact coordinates matter there.