home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.56k stars 30.74k forks source link

Automations with "zone" trigger don't work anymore #51788

Closed breti closed 1 year ago

breti commented 3 years ago

The problem

I have two automations that are triggered when I leave the house and when I return. They have worked faultlessly for more than a year until April. Since the May update, however, the automations are only triggered sporadically - sometimes one of them, but usually none at all. I can't find a cause for this - the person's status is still recognised correctly and the absence times are correct.

How can I find out why the automations no longer trigger?

What is version of Home Assistant Core has the issue?

2021.6.3 (issue first seen in 2021.5.x)

What was the last working version of Home Assistant Core?

2021.4.x

What type of installation are you running?

Home Assistant OS

Integration causing the issue

zone

Link to integration documentation on our website

https://www.home-assistant.io/integrations/zone/

Example YAML snippet

alias: Abwesend
description: ''
trigger:
  - entity_id: person.jens
    event: leave
    platform: zone
    zone: zone.home
condition:
  - condition: state
    entity_id: input_boolean.heating_mode_auto
    state: 'on'
action:
  - service: input_select.select_option
    target:
      entity_id: input_select.heating_mode
    data:
      option: abwesend/zeitgesteuert
mode: single

alias: Anwesend
description: ''
trigger:
  - entity_id: person.jens
    event: enter
    platform: zone
    zone: zone.home
condition:
  - condition: state
    entity_id: input_boolean.heating_mode_auto
    state: 'on'
action:
  - service: input_select.select_option
    target:
      entity_id: input_select.heating_mode
    data:
      option: anwesend/zeitgesteuert
mode: single

Anything in the logs that might be useful for us?

I don't think so

Additional information

Firefox_Screenshot_2021-06-12T20-09-22 017Z Firefox_Screenshot_2021-06-12T20-10-13 149Z Firefox_Screenshot_2021-06-12T20-11-14 151Z Firefox_Screenshot_2021-06-12T20-11-56 875Z Firefox_Screenshot_2021-06-12T20-11-42 067Z Firefox_Screenshot_2021-06-12T20-12-28 275Z

breti commented 3 years ago

Today, the absent automation was triggered, but the present automation was not. Firefox_Screenshot_2021-06-13T19-12-45 409Z Firefox_Screenshot_2021-06-13T19-11-47 811Z

breti commented 3 years ago

Doesn't anyone really have any ideas? I have restarted everything, applied all updates, but nothing helps.

breti commented 3 years ago

This one works:

trigger:
  - platform: state
    entity_id: person.jens
    from: home

resp.

trigger:
  - platform: state
    entity_id: person.jens
    to: home

So it's clearly related to the "zone" integration trigger.

schiegg commented 3 years ago

I can confirm this in version 2021.6.3 since my device_tracker entities were changed from the GPSLogger integration to the Home Assistant Companion app. At first, I thought the problems were induced by the companion location settings - not recognizing the entities as home correctly any more - but now I can clearly narrow that down to the untriggered automations.

Can anybody report this problem for a more recent version of HA? I am unable to update right now as I am waiting for a bug-fixing PR to be merged.

schiegg commented 3 years ago

It seems there already was a correction with #51847 (integrated in 2021.7.2?) Would be interesting to know if this is directly connected to this issue here, so we could close it.

breti commented 3 years ago

Thanks for the info! I have updated to 2021.7.2 and configured the Zone Trigger again. I will report if it works now.

Is it related to the beta version of the companion app (which I'm running)?

schiegg commented 3 years ago

Great @breti 👍

Is it related to the beta version of the companion app (which I'm running)?

I don't think so. Just mentioned it for other folks who might despair like me...

breti commented 3 years ago

51847 has been merged in 2021.7.0 ff.

grafik

I've been out for a walk yesterday evening and the zone trigger worked flawlessly.

breti commented 3 years ago

Unfortunately this is not fixed in 2021.7.2.

grafik

grafik

Thomas55555 commented 3 years ago

This one works:

trigger:
  - platform: state
    entity_id: person.jens
    from: home

resp.

trigger:
  - platform: state
    entity_id: person.jens
    to: home

So it's clearly related to the "zone" integration trigger.

I have the same problem. But I figured out, that the event trigger is working, if there is only the Android companion app device tracker is connected to the person entity. If there is the Android companion app and a stationary device tracker are connected to the person entity, then it is not working. How many device trackers are linked to your person entity?

breti commented 3 years ago

How many device trackers are linked to your person entity?

Two - the android companion app and a FRITZ!Box device tracker (based on the ARP cache of the router).

Thomas55555 commented 3 years ago

What happens if you deactivate the Fritz box tracker? Is it working again? It was like that in my case.

schiegg commented 3 years ago

@Thomas55555 I have multiple device_tracker instances running but only one connected to each person at a time and it did not work so I don't think there's a direct implication between the number of them and the faulty zone trigger. But maybe you're right that it somehow depends on the device_tracker as it did work as long as the GPSLogger integration was used for this.

@breti Were there any changes to this with 2021.8.8?

breti commented 3 years ago

Sorry, I didn't try a zone-based trigger again. I don't think there's any point in trying again and again unless a developer looks at it and at least gives some tips on which log files might be relevant.

Stillrainy commented 3 years ago

Same problem with me. I linked the router-based device tacker with the person entity. And the zone automation cannot running after I left home.

MarcoNica commented 2 years ago

For me i get the same issue when the last person state comes from the FritzTools. An the an automatation uses Zone as trigger or condition.

The error that throws when using zone: In 'zone' condition: error matching person.marco with zone.home: entity person.marco has no 'latitude' attribute

fubar-coder commented 2 years ago

It seems that the "zone" trigger still doesn't work in 2021.12.1.

mountainsandcode commented 2 years ago

Reason for this is probably as follows - the zone trigger and condition are designed to work with coordinates of the zones, not the zone names themselves (see explanation and link to code snippets in https://github.com/home-assistant/core/pull/65040#discussion_r793587746). As some device_trackers may not report coordinates, this could lead the trigger/ condition to not be matched.

mountainsandcode commented 2 years ago

Per https://github.com/home-assistant/core/pull/65344 this will be fixed in 2022.3 (i.e., not the release that is coming this month, but next month)

Altycoder commented 2 years ago

This is still an issue in 2022.3.0, my zone enter/leave automations are only working some of the time.

What can I provide to help debugging?

mountainsandcode commented 2 years ago

As far as I can see (https://github.com/home-assistant/core/pulls?q=is%3Apr+is%3Aclosed+label%3A%22integration%3A+zone%22+), this was not addressed in 2022.03.0 - so let's hope for 2022.04.0

Altycoder commented 2 years ago

Right OK, it's still an issue in 2022.3.1 as well it would seem (not long upgraded to the new minor version)

mister2d commented 2 years ago

Right OK, it's still an issue in 2022.3.1 as well it would seem (not long upgraded to the new minor version)

@Altycoder is this still happening? I'm on 2022.3.5 and my zone triggers still don't fire.

Altycoder commented 2 years ago

It's a bit hit and miss to be honest, some zones work but others don't including home and when they do work they are often very slow to react (several minutes sometimes)

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

breti commented 2 years ago

I haven't tested it again, but looking at the PRs, it doesn't look like this is fixed.

Altycoder commented 2 years ago

I haven't tested it again, but looking at the PRs, it doesn't look like this is fixed.

Same here

fratzi commented 2 years ago

I have the same problem now since I used wifi detection on my person state. At first I only used iOs cloud integration for presence detection on my person, with worked fine. Then I added wifi detection (fritz box), after this it does not work anymore. Also the trigger GUI does not let me select the person anymore. It's gone - I only can select a device, but not the person. I have to edit YAML. But this still does not work.

Only fix is to use state platform instead of zone.

Home Assistant 2022.10.2 Frontend 20221006.0 - latest

tomsommer commented 2 years ago

enter/leave isn't triggered if entity_id is person. with a location device attached to it (Hass iOS app), can confirm in 2022.10.4 Person goes [Location] -> Away and no event is triggered for leave and no Logbook zone-entry exists for the Person

MRedZac commented 1 year ago

More than 1,5 years and still no fix for the zones topic used in 97,5 % of all Home Assistant Installations ? - Serious ?

frenck commented 1 year ago

I think the unclarity here (and in our docs), is that the zone trigger only works on location based device trackers (GPS powered). Zone triggers calculate leaving/entering a zone based on those coordinates and take GPS accuracy into account.

https://www.home-assistant.io/docs/automation/trigger/#zone-trigger

image

That means if a location is triggered by a device tracker that doesn't use GPS coordinates (e.g., a device tracker from network presence), or when the person's location changes caused by a device tracker that doesn't use GPS coordinates: It won't trigger.

If you want to trigger specific state changes in a zone, person, or device tracker: Use a state trigger/condition.

../Frenck

tomsommer commented 1 year ago

Does this requirement make sense though? I mean, leave/enter events are triggered, so why is there a need for GPS coordinates?

frenck commented 1 year ago

Does this requirement make sense though?

That is a different discussion, it currently works as designed. This is an issue tracker, not a feature request forum :)

mark-szabo commented 1 year ago

@frenck can you please link the respective feature request entry so we can upvote it?

frenck commented 1 year ago

I'm not aware of such a feature request. Check (or search) the feature requests section on our Community forums for that.

mark-szabo commented 1 year ago

@frenck https://community.home-assistant.io/t/wth-why-the-heck-does-the-zone-trigger-only-fire-when-gps-based-trackers-change-state/482487

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

traysh commented 1 year ago

Still not working. Honestly, the terminology used in home assistant is misleading. If it is not enough for a person to enter a zone, it shouldn't be a zone trigger, but a GPS trigger. Please either fix the UX or the code and the docs. It's not a coincidence many people are getting here.

MRedZac commented 1 year ago

For me, all works fine.

Beste Grüße / Sincerly yours / Sincères salutations / Bescht Gréiss / 73 de

Marco HELTEN


Von: Danilo Luvizotto @.> Gesendet: Tuesday, March 14, 2023 8:25:42 PM An: home-assistant/core @.> Cc: Marco Helten @.>; Comment @.> Betreff: Re: [home-assistant/core] Automations with "zone" trigger don't work anymore (#51788)

Still not working. Honestly, the terminology used in home assistant is misleading. If it is not enough for a person to enter a zone, it shouldn't be a zone trigger, but a GPS trigger. Please either fix the UX or the code and the docs. It's not a coincidence many people are getting here.

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/51788#issuecomment-1468700307, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AXUD2PXSCNJDWVUBZXADJNDW4DA3NANCNFSM46TBYCIA. You are receiving this because you commented.Message ID: @.***>

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.