core icon indicating copy to clipboard operation
core copied to clipboard

Zone (non-passive) has ZERO state even with persons inside

Open ildar170975 opened this issue 1 year ago • 13 comments
trafficstars

The problem

Instead of closed ("stalled") https://github.com/home-assistant/core/issues/87814

Here is some non-passive zone: 217966503-93aa23ab-a610-4937-b22e-8c87ed802307

The “states(‘zone.some_zone’)” is ZERO - even when persons inside it.

Compared with the “home” zone: 217966548-defc694f-d59f-428a-90b2-20424c88fd58

{{states.person | selectattr('entity_id','is_state','home') | map(attribute='entity_id') | list}}
states('zone.home') = {{states('zone.home')}}

gives 217966618-64b07a4f-c87b-4d64-8eee-f09b08185ce9

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”, 217966716-45c0be2a-122c-49b0-b3fc-1c4d918d4dc2

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

ildar170975 avatar Aug 10 '24 01:08 ildar170975

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 close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign zone Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove 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)

home-assistant[bot] avatar Aug 10 '24 01:08 home-assistant[bot]

does zone.some_zone overlaps with zone.home or any other zone?

mib1185 avatar Aug 10 '24 08:08 mib1185

No overlapping. I described a possible reason - a code cannot process friendly_names.

ildar170975 avatar Aug 10 '24 11:08 ildar170975

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

mib1185 avatar Aug 10 '24 11:08 mib1185

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: image 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.

ildar170975 avatar Aug 10 '24 11:08 ildar170975

with this provided details and the configuration, i'm now able to investigate how to fix this

mib1185 avatar Aug 10 '24 11:08 mib1185

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
image image

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)

image


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

mib1185 avatar Aug 11 '24 14:08 mib1185

Hi @mib1185 Thanks a lot for checking.

  1. Please give me 10 days, currently I am away from a normal human life; hope will come back and check it.
  2. 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.

ildar170975 avatar Aug 11 '24 21:08 ildar170975

@mib1185

Test 1:

  1. Create a zone "Самая Классная Зона" in UI (i.e. w/o customize) - which gave me a zone.samaia_klassnaia_zona entity.

  2. I see that this zone now has some person entities included: изображение

Conclusion: works OK.


Test 2:

  1. Create a zone in UI - 学校 ("school") - which gave me a zone.xue_xiao entity.

  2. Since I am not sure that "xue_xiao" is a proper transliteration изображение I decide to open more-info & change entity_id to zone.school.

  3. I see that this zone now has some person entities included: изображение

Conclusion: works OK.


Test 3:

  1. 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.

  1. I see that this zone now has some person entities included: изображение

  2. I cannot change entity_id to zone.school in 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.

ildar170975 avatar Aug 22 '24 16:08 ildar170975

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.

mib1185 avatar Aug 25 '24 19:08 mib1185

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.

ildar170975 avatar Aug 25 '24 20:08 ildar170975

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.

elupus avatar Aug 26 '24 06:08 elupus

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".

ildar170975 avatar Aug 26 '24 10:08 ildar170975

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

ildar170975 avatar Jan 28 '25 22:01 ildar170975

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

StaleLoafOfBread avatar Feb 23 '25 04:02 StaleLoafOfBread

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.

ildar170975 avatar Feb 23 '25 05:02 ildar170975

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.

StaleLoafOfBread avatar Mar 05 '25 08:03 StaleLoafOfBread

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.

ildar170975 avatar Mar 05 '25 10:03 ildar170975

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.

ildar170975 avatar Jun 10 '25 11:06 ildar170975