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

Person tracking does not trust zone name if source type is not GPS #134344

Open
Ten0 opened this issue Dec 31, 2024 · 6 comments
Open

Person tracking does not trust zone name if source type is not GPS #134344

Ten0 opened this issue Dec 31, 2024 · 6 comments

Comments

@Ten0
Copy link

Ten0 commented Dec 31, 2024

The problem

Person entities will copy the device_tracker's zone only if it has source_type: gps, or if the state is either home or not_home.
Otherwise, it will always set the state to unknown.

This is not desirable behavior: if I have another device tracker that reports zones without gps information, the zones it provides should be trusted when used as device_tracker for a person.

Specifically, it looks like this line:

elif state.state == STATE_NOT_HOME:

should be replaced by: if state is not unknown nor unavailable, so as to allow using as fallback non-gps trackers that report another value than home or not_home. (Or better yet, the "not not_home nor home nor gps" should be an intermediate level, so that zone trackers are prioritized over stationary device trackers that only report not_home)

Is that something that sounds reasonable, and I could open a PR for it?

What version of Home Assistant Core has the issue?

core-2024.12.5

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

Person

Link to integration documentation on our website

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

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

@home-assistant
Copy link

@mib1185
Copy link
Contributor

mib1185 commented Dec 31, 2024

there are two different type of tracking entities - ScannerEntity and TrackerEntities - the later are for tracking the location of a device, so it has always SourceType.GPS set. A ScannerEntity is network based, so it only has state home or not home (away).
So there can't be a device_tracker providing a location (zone) as state, without having SourceType.GPS set

@Ten0
Copy link
Author

Ten0 commented Dec 31, 2024

Thanks for your quick answer.

there are two different type of tracking entities - ScannerEntity and TrackerEntities

And then there's the entity I added in there via set_state, that improves detection of whether I'm in a particular place based on combining GPS data (or lack thereof) with "which wifi am I connected to" data to determine that I'm in a particular location without necessarily having GPS data (esp. if it hasn't reported in a long time if e.g. low phone battery or low accuracy).

It doesn't look like it would be hurtful to allow all device_tracker entities to report more precise location states than not_home even if they aren't GPS.

@mib1185
Copy link
Contributor

mib1185 commented Dec 31, 2024

A ScannerEntity reports the connected state of a device on the local network. If the device is connected the ScannerEntity will have state home and if the device is not connected the state will be not_home.

A TrackerEntity tracks the location of a device and reports it either as a location name, a zone name or home or not_home states. A TrackerEntity normally receives GPS coordinates to determine its state. Either location_name or latitude and longitude should be set to report state.

so a ScannerEntity should never report a location - but a TrackerEntity.

And then there's the entity I added in there via set_state,

your self created entity needs to be an TrackerEntity if it should provide the location

@Ten0
Copy link
Author

Ten0 commented Dec 31, 2024

your self created entity needs to be an TrackerEntity if it should provide the location

I understand this, however I feel like this should not be a requirement (if by "location" you mean "zone"), which is why I created this issue.

@mib1185
Copy link
Contributor

mib1185 commented Dec 31, 2024

The difference between these two types of device tracker entities is on purpose, so that consuming integrations know what to expect.

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

2 participants