Migrate gpslogger to has entity name (#96594)
parent
57352578ff
commit
7d4016d7bf
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue