mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 05:37:44 +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):
|
||||
"""Represent a tracked device."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
_attr_name = None
|
||||
|
||||
def __init__(self, device, gps=None, location_name=None, attributes=None):
|
||||
"""Set up Geofency entity."""
|
||||
self._attributes = attributes or {}
|
||||
@ -79,11 +82,6 @@ class GeofencyEntity(TrackerEntity, RestoreEntity):
|
||||
"""Return a location name for the current location of the device."""
|
||||
return self._location_name
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the device."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique ID."""
|
||||
@ -92,7 +90,10 @@ class GeofencyEntity(TrackerEntity, RestoreEntity):
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""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
|
||||
def source_type(self) -> SourceType:
|
||||
@ -125,7 +126,7 @@ class GeofencyEntity(TrackerEntity, RestoreEntity):
|
||||
@callback
|
||||
def _async_receive_data(self, device, gps, location_name, attributes):
|
||||
"""Mark the device as seen."""
|
||||
if device != self.name:
|
||||
if device != self._name:
|
||||
return
|
||||
|
||||
self._attributes.update(attributes)
|
||||
|
Loading…
x
Reference in New Issue
Block a user