Migrate gpslogger to has entity name (#96594)

pull/96817/head
Joost Lekkerkerker 2023-07-18 09:37:38 +02:00 committed by GitHub
parent 57352578ff
commit 7d4016d7bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 8 deletions

View File

@ -66,8 +66,11 @@ async def async_setup_entry(
class GPSLoggerEntity(TrackerEntity, RestoreEntity):
"""Represent a tracked device."""
_attr_has_entity_name = True
_attr_name = None
def __init__(self, device, location, battery, accuracy, attributes):
"""Set up Geofency entity."""
"""Set up GPSLogger entity."""
self._accuracy = accuracy
self._attributes = attributes
self._name = device
@ -101,11 +104,6 @@ class GPSLoggerEntity(TrackerEntity, RestoreEntity):
"""Return the gps accuracy of the device."""
return self._accuracy
@property
def name(self):
"""Return the name of the device."""
return self._name
@property
def unique_id(self):
"""Return the unique ID."""
@ -114,7 +112,10 @@ class GPSLoggerEntity(TrackerEntity, RestoreEntity):
@property
def device_info(self) -> DeviceInfo:
"""Return the device info."""
return DeviceInfo(identifiers={(GPL_DOMAIN, self._unique_id)}, name=self._name)
return DeviceInfo(
identifiers={(GPL_DOMAIN, self._unique_id)},
name=self._name,
)
@property
def source_type(self) -> SourceType:
@ -165,7 +166,7 @@ class GPSLoggerEntity(TrackerEntity, RestoreEntity):
@callback
def _async_receive_data(self, device, location, battery, accuracy, attributes):
"""Mark the device as seen."""
if device != self.name:
if device != self._name:
return
self._location = location