From 8d048c4cfa229a1accd9ab2c090aac06daca0991 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Tue, 18 Jul 2023 09:43:29 +0200 Subject: [PATCH] Migrate geofency to has entity name (#96592) --- .../components/geofency/device_tracker.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/geofency/device_tracker.py b/homeassistant/components/geofency/device_tracker.py index 892116121a0..66cbbcbd67e 100644 --- a/homeassistant/components/geofency/device_tracker.py +++ b/homeassistant/components/geofency/device_tracker.py @@ -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)