mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Migrate geofency to has entity name (#96592)
This commit is contained in:
parent
bc6a41fb94
commit
8d048c4cfa
@ -50,6 +50,9 @@ async def async_setup_entry(
|
|||||||
class GeofencyEntity(TrackerEntity, RestoreEntity):
|
class GeofencyEntity(TrackerEntity, RestoreEntity):
|
||||||
"""Represent a tracked device."""
|
"""Represent a tracked device."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
_attr_name = None
|
||||||
|
|
||||||
def __init__(self, device, gps=None, location_name=None, attributes=None):
|
def __init__(self, device, gps=None, location_name=None, attributes=None):
|
||||||
"""Set up Geofency entity."""
|
"""Set up Geofency entity."""
|
||||||
self._attributes = attributes or {}
|
self._attributes = attributes or {}
|
||||||
@ -79,11 +82,6 @@ class GeofencyEntity(TrackerEntity, RestoreEntity):
|
|||||||
"""Return a location name for the current location of the device."""
|
"""Return a location name for the current location of the device."""
|
||||||
return self._location_name
|
return self._location_name
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Return the name of the device."""
|
|
||||||
return self._name
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return the unique ID."""
|
"""Return the unique ID."""
|
||||||
@ -92,7 +90,10 @@ class GeofencyEntity(TrackerEntity, RestoreEntity):
|
|||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
return DeviceInfo(identifiers={(GF_DOMAIN, self._unique_id)}, name=self._name)
|
return DeviceInfo(
|
||||||
|
identifiers={(GF_DOMAIN, self._unique_id)},
|
||||||
|
name=self._name,
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_type(self) -> SourceType:
|
def source_type(self) -> SourceType:
|
||||||
@ -125,7 +126,7 @@ class GeofencyEntity(TrackerEntity, RestoreEntity):
|
|||||||
@callback
|
@callback
|
||||||
def _async_receive_data(self, device, gps, location_name, attributes):
|
def _async_receive_data(self, device, gps, location_name, attributes):
|
||||||
"""Mark the device as seen."""
|
"""Mark the device as seen."""
|
||||||
if device != self.name:
|
if device != self._name:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._attributes.update(attributes)
|
self._attributes.update(attributes)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user