mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Migrate gpslogger to has entity name (#96594)
This commit is contained in:
parent
57352578ff
commit
7d4016d7bf
@ -66,8 +66,11 @@ async def async_setup_entry(
|
|||||||
class GPSLoggerEntity(TrackerEntity, RestoreEntity):
|
class GPSLoggerEntity(TrackerEntity, RestoreEntity):
|
||||||
"""Represent a tracked device."""
|
"""Represent a tracked device."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
_attr_name = None
|
||||||
|
|
||||||
def __init__(self, device, location, battery, accuracy, attributes):
|
def __init__(self, device, location, battery, accuracy, attributes):
|
||||||
"""Set up Geofency entity."""
|
"""Set up GPSLogger entity."""
|
||||||
self._accuracy = accuracy
|
self._accuracy = accuracy
|
||||||
self._attributes = attributes
|
self._attributes = attributes
|
||||||
self._name = device
|
self._name = device
|
||||||
@ -101,11 +104,6 @@ class GPSLoggerEntity(TrackerEntity, RestoreEntity):
|
|||||||
"""Return the gps accuracy of the device."""
|
"""Return the gps accuracy of the device."""
|
||||||
return self._accuracy
|
return self._accuracy
|
||||||
|
|
||||||
@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."""
|
||||||
@ -114,7 +112,10 @@ class GPSLoggerEntity(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={(GPL_DOMAIN, self._unique_id)}, name=self._name)
|
return DeviceInfo(
|
||||||
|
identifiers={(GPL_DOMAIN, self._unique_id)},
|
||||||
|
name=self._name,
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_type(self) -> SourceType:
|
def source_type(self) -> SourceType:
|
||||||
@ -165,7 +166,7 @@ class GPSLoggerEntity(TrackerEntity, RestoreEntity):
|
|||||||
@callback
|
@callback
|
||||||
def _async_receive_data(self, device, location, battery, accuracy, attributes):
|
def _async_receive_data(self, device, location, battery, accuracy, attributes):
|
||||||
"""Mark the device as seen."""
|
"""Mark the device as seen."""
|
||||||
if device != self.name:
|
if device != self._name:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._location = location
|
self._location = location
|
||||||
|
Loading…
x
Reference in New Issue
Block a user