-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
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: Use the home zone lat/lon coordinates when detected home by a stationary tracker #134075
base: dev
Are you sure you want to change the base?
Conversation
Can you please explain why we should use the GPS-Tracker over a non-gps one if both specify that the person is home |
@edenhaus Sure! While the Without those two, it simply vanishes from the default map view. You also just get a boring history more-info pop up like this one: |
Instead of using the GPS coordinates, we could also use the coordinates of the zone, where the non_gps one belongs too |
As it was already explained - currently a |
True, but since zones can be of arbitrary size, the user might conceivably still be interested in the gps position within that zone instead of just the center of it. |
For example due the big walls in my house the gps accuracy is bigger than the actual zone, so in my case I would prefer the zone coordinates. Also using the zone coordinates would be more consistent as with your proposal only coordinates would be available if also the gps device is home. In my opinion we should use the zone coordinates but I will discuss this topic internally |
☝️ This makes a lot of sense to me. That said, this is en entity component and for changes to that model (especially fundamental changes like this), we require an architectural proposal and discussion that have been approved prior to creating a pull request. Therefore, I suggest to start by creating a architectural proposal and discussion in our architecture repository first. ../Frenck |
As the architecture discussion home-assistant/architecture#1179 was answered, can you update the PR to match the discussion? |
11479ec
to
43a9966
Compare
4eecf6f
to
6a4f906
Compare
Done. The remaining failing test seems to be an issue with the dev branch and unrelated to this PR |
just adding #61299 which was closed ages ago because 'being worked on' ;-) can only cheer for this PR now, thx! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The number of code line in update_state is starting to get big, consider moving this logic into a helper method?
@@ -530,7 +531,23 @@ def _update_state(self) -> None: | |||
latest_not_home = _get_latest(latest_not_home, state) | |||
|
|||
if latest_non_gps_home: | |||
latest = latest_non_gps_home | |||
home_zone = self.hass.states.get(ENTITY_ID_HOME) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering, why only the home zone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because - at least to my understanding - stationary trackers don't support being in any other zones than the home zone.
Honestly that confused me too, because the architecture discussion sounded like they could be linked to any zone but they don't seem to be able of doing that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a good question. In PR #138475 there is a stationary tracker of source type bluetooth_le that is reporting a non home zone and that causes the person to be "away" rather than in the non-home zone. So yes, it appears that a stationary tracker can report a non home zone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PeteRager A bit more context building would go a long way here. I did not understand the previous review from you but now after looking at your PR (which you didn't label as yours) that makes a lot more sense.
Something like "Hey btw I'm also touching this feature right now for a different reason and that might require additional changes. Specifically, it seems that there are these assumptions, however those might not hold true under these circumstances"
Or just a "In My PR 1234" instead of just "In PR 1234". That's just one word making a lot of difference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs https://www.home-assistant.io/integrations/device_tracker/ have conflicting information. First they state it is either Home or Not Home; but then in the first bullet it says that a presence based system that includes coordinates it could be any zone name.
"A device tracker with router as a source can have one of two states: Home, or Not home.
-
Home: Your tracked device is in the home zone, detected by your network or Bluetooth-based presence detection. If you’re using a presence detection method that includes coordinates: when it’s in a zone, the state equals the name of the zone (case sensitive).
-
Not home: When a device isn’t at home and isn’t in any zone."
So there seems to be two cases of stationary trackers; one without coordinates - which is the case you are solving - and that is documented as being home / not_home only. In context of this PR it should be ok to only use the home zone. or to future proof you could just use the tracker state to lookup the zone and pull that. It would be nice if I have a router in my garage it would mark me as being "garage" or "not in the garage"
The case being addressed in #138475; is related to stationary trackers than have coordinates; and by definition since that has coordinates the logic being proposed here would not run.
Proposed change
When playing around with the demo instance, I saw that person entities had this map view when opening the more-info dialog
When playing around with my HA instance, they didn't.
This confused me, so I looked at the
person
implementation.I'd argue that if the latest tracker ishome
and there is also a latestgps
tracker that is alsohome
, there is no point in not using thegps
tracker, as it will provide a superset of the data the other non-gps tracker could provide.The architecture discussion sparked by this PR (home-assistant/architecture#1179) led to the decision that stationary trackers should remain prioritized, but also, to solve the issue of vanishing lat/lon attributes, the zones lat/lon shall be used.
The PR has been updated to reflect that.
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: