core
core copied to clipboard
Zone (non-passive) has ZERO state even with persons inside
The problem
Instead of closed ("stalled") https://github.com/home-assistant/core/issues/87814
Here is some non-passive zone:
The “states(‘zone.some_zone’)” is ZERO - even when persons inside it.
Compared with the “home” zone:
{{states.person | selectattr('entity_id','is_state','home') | map(attribute='entity_id') | list}}
states('zone.home') = {{states('zone.home')}}
gives
which is correct.
But this does not work - the 1st statement gives a correct list of persons inside the zone, the 2nd statement is wrong:
{{states.person | selectattr('entity_id','is_state','XXXXXXXXXXX') | map(attribute='entity_id') | list}}
states('zone.some_zone') = {{states('zone.some_zone')}}
where “XXXXXXXXXXX” is a friendly name for the “zone.some_zone”,
Checked with one more non-home zone (not passive too) with 3 persons inside - same ZERO state.
My guess that a zone entity has a properly set state if it has no customized friendly_name.
What version of Home Assistant Core has the issue?
2024.8
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
Integration causing the issue
zone
Link to integration documentation on our website
https://www.home-assistant.io/integrations/zone/
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (zone) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of zone can trigger bot actions by commenting:
@home-assistant closeCloses the issue.@home-assistant rename Awesome new titleRenames the issue.@home-assistant reopenReopen the issue.@home-assistant unassign zoneRemoves the current integration label and assignees on the issue, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the issue.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.
(message by CodeOwnersMention)
zone documentation zone source (message by IssueLinks)
does zone.some_zone overlaps with zone.home or any other zone?
No overlapping. I described a possible reason - a code cannot process friendly_names.
How did you customize the friendly name of this zone? It would be helpful to see the yaml configuration for this zone (but redact the coordinates). The zone integration uses the name of the zone (as it is configured in the yaml) to compare it against the persons states
Config:
zone:
- name: izmailovskii
latitude: xxx
longitude: xxx
radius: 50
passive: false
icon: mdi:pine-tree
homeassistant:
customize:
zone.izmailovskii:
friendly_name: "Измайловский"
When a person in this zone - it's state is "Измайловский".
Simulated this on a screen below:
i.e.
person entities get a valid state = friendly_name.
But a state of the zone is 0 - because you process names, not friendly names.
Trust me - it is NORMAL for people to define friendly_names on their own language ))))
Like a Japanese person will use a zone.school with a friendly name "学校".
Then all his/her kids will have a state "学校" (as expected) - but states(zone.school) is 0 always.
with this provided details and the configuration, i'm now able to investigate how to fix this
Hi @ildar170975
i've tested it now by creating a zone called Измайловский via UI and than entered the zone - it was successful.
here is my test setup
The entity ID zone.izmailovskii was automatically set when configuring the zone via UI (Settings -> Areas, labels & zones -> Zones -> Add zone) with the name Измайловский.
the zone coordinates were the home a friend where i was invited to a bbq yesterday, so i could test it under real circumstances ^^
| UI config screenshot | state details |
|---|---|
you can see the entity id is zone.izmailovskii and friendly name is Измайловский
now i entered the zone yesterday and the state of my person.mib85 changed to Измайловский and the zone has counted one person in the zone. (the short interruptions were caused by short time leaving the zone)
Summarized I would say, the zone and person states works as expected, even with friendly names. Most properly the root cause of your issues is based in the customization via yaml. I would suggest to setup your zones via UI
Hi @mib1185 Thanks a lot for checking.
- Please give me 10 days, currently I am away from a normal human life; hope will come back and check it.
- I am sure that using a customized friendly_name should not break any functionality. I guess the “zone” domain is the only place in HA where customization breaks functionality. Suggest to improve this place. A possible way - adding a new attribute to a “person” entity - “zone_id” which is equal to a zone’s entity_id (stripped from “zone” part).
Also, think about users from China, Japan - not sure that transliteration works properly.
@mib1185
Test 1:
-
Create a zone "Самая Классная Зона" in UI (i.e. w/o
customize) - which gave me azone.samaia_klassnaia_zonaentity. -
I see that this zone now has some
personentities included:
Conclusion: works OK.
Test 2:
-
Create a zone in UI -
学校("school") - which gave me azone.xue_xiaoentity. -
Since I am not sure that "xue_xiao" is a proper transliteration
I decide to open more-info & change
entity_idtozone.school. -
I see that this zone now has some
personentities included:
Conclusion: works OK.
Test 3:
- Create a zone in yaml -
学校("school"):
zone:
- name: 学校
latitude: ...
longitude: ...
radius: 75
passive: false
icon: mdi:home-city
which gave me a zone.xue_xiao entity.
-
I see that this zone now has some
personentities included: -
I cannot change
entity_idtozone.schoolin more-info:
but I hope I will be able to change entity_id after defining unique_id:
zone:
- name: 学校
latitude: ...
longitude: ...
...
unique_id: 8b8a139a-e97b-4840-b8fd-6a391b06ee2d
But - no:
Conclusion: works OK, but you cannot specify a needed entity_id.
As I already said - zone seems to be the only place in HA where using a customize breaks functionality.
Suggest to reconsider.
The customisation of yaml based configurations is more or less a patchwork, so that modern UI features might also be used with these old-style yaml entities. Therefore it's most likely that this behaviour wouldn't get fixed, because the solution is quite simple, just configure the zone via UI, when UI features (like renaming or setting friendly names) is needed.
Respectfully disagree. Since zones still can be officially defined in yaml - customizing them cannot be called a patchwork. No one can force users to use UI in places where yaml still may be used. And as I already said - zone integration is the ONLY place in HA where using “customize” breaks functionality. Also users who uses hieroglyphs (as I demonstrated) cannot be obliged to use UI, rename entity_ids etc just to get a normal functionality.
As for
Therefore it's most likely that this behaviour wouldn't get fixed
it depends on particular developers: if they do not care about users, ofc they will not implement necessary changes.
As said. Customization of entities is considered deprecated. If an entity need to be changed, it need to be done in UI or through that entity`s configuration if it is configured through yaml.
Customization feature will very likely not be fixed, more likely it is going to be removed. That said, if you step up and provide fixes and maintain the customization feature there are people who will review and if good, accept fixes.
Considered by whom and where? Do you have it declared in official docs?
Update 28.10.24: no answer is given for explaining "Customization of entities is considered deprecated" - so I consider these words as a "fake news".
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.
up
I found this issue because I was about to file it myself and stumbled across #138454. I have a zone configured completely via the UI. I gave it a friendly name via the UI as well. Now that zone's state and persons attribute do not properly update. This means that @mib1185's proposed solution at https://github.com/home-assistant/core/issues/123504#issuecomment-2308963754 does not work.
My zone's default friendly name (well with the real person's name swapped out) is StaleLoafOfBread's Work
The entity it is zone.staleloafofbread_s_work
The customized friendly name I tried giving it was Work
I have no other zones using the word Work at all.
I discovered this because I was trying to find a way to get the zone for a given person entity and the only way I could figure out how was to iterate over the person attribute off all zones till I found the person's entity_id.
Core: 2025.2.5
Supervisor: 2025.02.1
Operating System: 14.2
Frontend: 20250221.0
That https://github.com/home-assistant/core/issues/123504#issuecomment-2308963754 solution does not work even w/o friendly_name defined in UI. It may work for languages with Latin letters & similar - but not for Cyrillic, Jewish, Japanese etc.
I have found a work around. You need to edit the name of the zone in the zone editor (not on the entity like you would for anything else). The entity id will remain the same but the friendly name will be updated. I think technically the friendly name remains null and the name attribute updates. Currently on mobile and it's rather late so can't check the technicalities right now.
I have found a work around. You need to edit the name of the zone in the zone editor
Right, but this is merely a "workaround". HA should NOT depend on a way an entity is customized.
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.
Not solved in fact.