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.31k stars 30.62k forks source link

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

Open tom-parkinson opened 10 months ago

tom-parkinson commented 10 months ago

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[bot] commented 10 months ago

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 commented 10 months ago

+1 to this request

dakone22 commented 9 months ago

https://github.com/home-assistant/core/blob/29cac5b093443a86044224ed5365fbbb70760840/homeassistant/components/device_tracker/legacy.py#L889-L912

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[bot] commented 6 months 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.

tom-parkinson commented 6 months ago

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 commented 6 months ago

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

djegum commented 6 months ago

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 commented 5 months ago

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

issue-triage-workflows[bot] commented 2 months 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.

tom-parkinson commented 2 months ago

This hasn't been fixed

vvac commented 2 months ago

Agreed with Tom

pt., 30 sie 2024 o 00:42 Tom Parkinson @.***> napisał(a):

This hasn't been fixed

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/105773#issuecomment-2319191208, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEO35J7BBWA7AFBF3Q6ONV3ZT6PVXAVCNFSM6AAAAABAVQ5XVCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJZGE4TCMRQHA . You are receiving this because you commented.Message ID: @.***>

tivoo commented 1 month ago

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