diff --git a/homeassistant/components/person/__init__.py b/homeassistant/components/person/__init__.py index 6701822ec7ba..75ce0b550735 100644 --- a/homeassistant/components/person/__init__.py +++ b/homeassistant/components/person/__init__.py @@ -565,7 +565,7 @@ class Person( self._latitude = coordinates.attributes.get(ATTR_LATITUDE) self._longitude = coordinates.attributes.get(ATTR_LONGITUDE) self._gps_accuracy = coordinates.attributes.get(ATTR_GPS_ACCURACY) - self._in_zones = coordinates.attributes.get(ATTR_IN_ZONES, []) + self._in_zones = state.attributes.get(ATTR_IN_ZONES, []) @callback def _update_extra_state_attributes(self) -> None: diff --git a/tests/components/person/test_init.py b/tests/components/person/test_init.py index 7b2711d60a44..09bced3529ee 100644 --- a/tests/components/person/test_init.py +++ b/tests/components/person/test_init.py @@ -236,18 +236,19 @@ async def test_setup_two_trackers( hass.bus.async_fire(EVENT_HOMEASSISTANT_START) await hass.async_block_till_done() - # Router tracker at home with gps_accuracy — the person entity gets latitude, - # longitude and accuracy from the home zone (the coordinates source), not - # from the router tracker's own attributes. + # Router tracker at home — the person entity gets latitude, longitude and + # accuracy from the home zone (the coordinates source), not from the router + # tracker's own attributes. `in_zones`, however, is propagated from the + # source tracker. # Note: a router tracker would not really have gps_accuracy; it is set here - # (together with in_zones=["zone.fake"]) only to assert it is NOT propagated. + # only to assert it is NOT propagated. hass.states.async_set( DEVICE_TRACKER, "home", { ATTR_SOURCE_TYPE: SourceType.ROUTER, ATTR_GPS_ACCURACY: 99, - ATTR_IN_ZONES: ["zone.fake"], + ATTR_IN_ZONES: ["zone.home"], }, ) await hass.async_block_till_done() @@ -255,6 +256,7 @@ async def test_setup_two_trackers( state = hass.states.get("person.tracked_person") assert state.state == "home" assert state.attributes == expected_attributes | { + ATTR_IN_ZONES: ["zone.home"], ATTR_LATITUDE: 32.87336, ATTR_LONGITUDE: -117.22743, ATTR_SOURCE: DEVICE_TRACKER, @@ -447,6 +449,7 @@ async def _async_setup_person_two_trackers(hass: HomeAssistant, user_id: str) -> _GPS_NOT_HOME, "home", { + ATTR_IN_ZONES: ["zone.home"], ATTR_LATITUDE: 32.87336, ATTR_LONGITUDE: -117.22743, ATTR_SOURCE: DEVICE_TRACKER, @@ -459,6 +462,7 @@ async def _async_setup_person_two_trackers(hass: HomeAssistant, user_id: str) -> _SCANNER_OFFICE, "home", { + ATTR_IN_ZONES: ["zone.home"], ATTR_LATITUDE: 32.87336, ATTR_LONGITUDE: -117.22743, ATTR_SOURCE: DEVICE_TRACKER, @@ -573,6 +577,7 @@ async def test_state_priority_overrides_recency( _ROUTER_HOME, "home", { + ATTR_IN_ZONES: ["zone.home"], ATTR_LATITUDE: 32.87336, ATTR_LONGITUDE: -117.22743, ATTR_SOURCE: DEVICE_TRACKER_2,