Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State of zone entity should be friendly name when Privacy == Zone Name Only #105773

Open
tom-parkinson opened this issue Dec 14, 2023 · 16 comments
Open

Comments

@tom-parkinson
Copy link

tom-parkinson commented Dec 14, 2023

The problem

If "Zone Name Only" is set under the "Location Sent" setting of the Companion app, then the entity name of the zone gets shown on the person entity cards on the dashboard. This behaviour is inconsistent with the "Exact" location sent setting, which shows the friendly name of the zone.

289716558-e3ec539f-f6f1-467f-97b8-1c243098c843

In this example, kids have the “Location Sent” to “Exact” under Privacy in the app and for adults to “Zone Name Only”.
The dashboard with simple person entities shows correctly “Home” and “Away” for all. However, once in a pre-configured zone:

kids: it displays the zone’s friendly name, e.g. “School”
adults: it displays the zone’s entity, like “kids_school” instead of “School”.

There's a forum discussion thread with several users about this. It was also submitted as an issue on the frontend but no problems reported there.

What version of Home Assistant Core has the issue?

2023.12.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Device tracker

Link to integration documentation on our website

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

Diagnostics information

State and attributes of the privacy-enabled person as well as the zone when issue appears:
289707268-fc2ae90d-19f4-496e-836c-b08abf1e3ed2
289707275-df41bfe1-8bfb-45bf-9af9-02efd1fd9d75
289707282-a1eb0dc2-5721-4429-a998-0f6eba7a37ef

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@home-assistant
Copy link

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (device_tracker) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of device_tracker 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 device_tracker 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)


device_tracker documentation
device_tracker source
(message by IssueLinks)

@vvac
Copy link

vvac commented Jan 4, 2024

+1 to this request

@dakone22
Copy link

dakone22 commented Jan 9, 2024

async def async_update(self) -> None:
"""Update state of entity.
This method is a coroutine.
"""
if not self.last_seen:
return
if self.location_name:
self._state = self.location_name
elif self.gps is not None and self.source_type == SourceType.GPS:
zone_state = zone.async_active_zone(
self.hass, self.gps[0], self.gps[1], self.gps_accuracy
)
if zone_state is None:
self._state = STATE_NOT_HOME
elif zone_state.entity_id == zone.ENTITY_ID_HOME:
self._state = STATE_HOME
else:
self._state = zone_state.name
elif self.stale():
self.mark_stale()
else:
self._state = STATE_HOME
self.last_update_home = True

I had a quick look at the device update code, and if I understand the code here correctly, it shows that the friendly_name of the zone is obtained by accurately determining the zone based on gps.
But without gps, the location_name obtained from the device app is used instead of the zone name, I assume.
I guess it's enough to add an attempt to convert location_name to zone and get the friendly_name of the zone.

Only I am not sure how exactly to convert the zone id string into a zone object to get the friendly_name of the zone

I guess, something like this:

# ...
if self.location_name:
    zone_state = zone.get_zone_state(self.hass, self.location_name)
    self._state = self.location_name if zone_state is None else zone_state.name
# elif ...

assuming zone.get_zone_state should look something like this (based on zone.async_active_zone):

def get_zone_state(hass: HomeAssistant, zone_id: str) -> State | None:
    """ Find the active zone with given id. """

    zone = hass.states.get(zone_id)  # possible security hole? Device app can send any entity id
    if (
        not zone
        or zone.state == STATE_UNAVAILABLE
        or zone.attributes.get(ATTR_PASSIVE)
    ):
        return None
    
    return zone

@issue-triage-workflows
Copy link

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.

@tom-parkinson
Copy link
Author

I'm not sure if anyone will see this, but @dakone22 has offered much more insight than I can on the issue. Any idea how to get this resurfaced?

@vvac
Copy link

vvac commented Apr 10, 2024

This issue still persists in the newest version - zone is still being presented non-friendly when Privacy == Zone Name Only.

@djegum
Copy link

djegum commented May 2, 2024

I have the same issue in my HomeAssistant instance. I found out about this issue after setting the tracking to zone only. The number of people in a zone isn't updated, besides the Home zone.
image
I am currently at work and HA doesn't trigger the automation linked to this zone.

@n15c
Copy link

n15c commented May 31, 2024

Hey there,
Got the same issue, is there a workaround (beside changing to precise location)?

@issue-triage-workflows
Copy link

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.

@tom-parkinson
Copy link
Author

This hasn't been fixed

@github-actions github-actions bot removed the stale label Aug 29, 2024
@vvac
Copy link

vvac commented Aug 30, 2024 via email

@tivoo
Copy link

tivoo commented Sep 12, 2024

+1 on this request. Experiencing the exact same issue.

@issue-triage-workflows
Copy link

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.

@MitchTalmadge
Copy link

Still an issue

@github-actions github-actions bot removed the stale label Dec 11, 2024
@vvac
Copy link

vvac commented Dec 12, 2024 via email

@ncd7
Copy link

ncd7 commented Jan 7, 2025

I just enabled zone only privacy in the companion app and this broke my dashboard. As in it doesn't show the user friendly zone name and as a secondary effect doesn't show the correct icon either.

This has been an issue for over a year so I think someone from the community will have to fix it. There is a reasonable suggestion above. Could we brave a PR perhaps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants