mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 17:04:04 -04:00
Use ZoneEntityStateAttribute enum in device_tracker (#175976)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
1b1a008816
commit
f69fd14f4b
@@ -7,7 +7,7 @@ from typing import TYPE_CHECKING, Any, final, override
|
||||
from propcache.api import cached_property
|
||||
|
||||
from homeassistant.components import zone
|
||||
from homeassistant.components.zone import ATTR_PASSIVE, ATTR_RADIUS
|
||||
from homeassistant.components.zone import ZoneEntityStateAttribute
|
||||
from homeassistant.const import ( # noqa: F401
|
||||
ATTR_BATTERY_LEVEL,
|
||||
ATTR_GPS_ACCURACY,
|
||||
@@ -368,10 +368,14 @@ class TrackerEntity(
|
||||
for entity_id in zones
|
||||
if (zone_state := self.hass.states.get(entity_id)) is not None
|
||||
),
|
||||
key=lambda z: z.attributes[ATTR_RADIUS],
|
||||
key=lambda z: z.attributes[ZoneEntityStateAttribute.RADIUS],
|
||||
)
|
||||
self.__active_zone = next(
|
||||
(z for z in zone_states if not z.attributes.get(ATTR_PASSIVE)),
|
||||
(
|
||||
z
|
||||
for z in zone_states
|
||||
if not z.attributes.get(ZoneEntityStateAttribute.PASSIVE)
|
||||
),
|
||||
None,
|
||||
)
|
||||
self.__in_zones = [z.entity_id for z in zone_states]
|
||||
|
||||
@@ -14,7 +14,7 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant import util
|
||||
from homeassistant.components import zone
|
||||
from homeassistant.components.zone import ENTITY_ID_HOME
|
||||
from homeassistant.components.zone import ENTITY_ID_HOME, ZoneEntityStateAttribute
|
||||
from homeassistant.config import (
|
||||
async_log_schema_error,
|
||||
config_per_platform,
|
||||
@@ -24,8 +24,6 @@ from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
ATTR_GPS_ACCURACY,
|
||||
ATTR_ICON,
|
||||
ATTR_LATITUDE,
|
||||
ATTR_LONGITUDE,
|
||||
ATTR_NAME,
|
||||
CONF_ICON,
|
||||
CONF_MAC,
|
||||
@@ -511,8 +509,8 @@ def async_setup_scanner_platform(
|
||||
zone_home = hass.states.get(ENTITY_ID_HOME)
|
||||
if zone_home is not None:
|
||||
kwargs["gps"] = [
|
||||
zone_home.attributes[ATTR_LATITUDE],
|
||||
zone_home.attributes[ATTR_LONGITUDE],
|
||||
zone_home.attributes[ZoneEntityStateAttribute.LATITUDE],
|
||||
zone_home.attributes[ZoneEntityStateAttribute.LONGITUDE],
|
||||
]
|
||||
kwargs["gps_accuracy"] = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user