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.

1 Like

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.

1 Like

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.

One practial solution is to use the beacon independent from HA. I removed my beacon from HA, added it to Pushcut (available on Appstore) and created a webhook-endpoint in HA, which is triggered by Pushcut (Backgroundaction), when entering the beacon-range. Also, if nessesary, you can create a second webhook-endpoint, when leaving beacon-range and trigger this by Pushcat too (e. g. light on/off). Inside Pushcat, you can define a timeout-period after loosing the beacon signal, for the leaving event. It works reliable so far here.

Cool, can you post your yaml to make it work?

I missed out.
The last phone in the house upgraded to the latest version of the app some days ago. Now I canā€™t test anymore. I have been a bit to slacking with thisā€¦

There is no need to configure anything, just create an automation with:

trigger:
  platform: webhook
  webhook_id: very_long_and_secret_hex_number
...

The endpoint will be created automatically by HA. Then add your beacon to pushcat, create a background action for entering your beacon zone in pushcat and trigger the url of your webhook_id, i. g.

https://your.HA.address/api/webhook/very_long_and_secret_hex_number

and set method POST and content type Plain. And you have to allow location requests ā€˜alwaysā€™ in iOS for pushcat.

If needed, do the same for a leaving webhook.

Thats all!

1 Like

Hi @DSchumacher2104
I am trying to configure the app but it seems donā€™t recognise when entering the beacon-range.
Could you please share your config for the app?
Thank you!