Migrate Traccar to has entity naming (#96760)

This commit is contained in:
Joost Lekkerkerker 2023-07-18 08:56:15 +02:00 committed by GitHub
parent 9e67bccb89
commit 2c949d56dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -365,8 +365,11 @@ class TraccarScanner:
class TraccarEntity(TrackerEntity, RestoreEntity): class TraccarEntity(TrackerEntity, RestoreEntity):
"""Represent a tracked device.""" """Represent a tracked device."""
_attr_has_entity_name = True
_attr_name = None
def __init__(self, device, latitude, longitude, battery, accuracy, attributes): def __init__(self, device, latitude, longitude, battery, accuracy, attributes):
"""Set up Geofency entity.""" """Set up Traccar entity."""
self._accuracy = accuracy self._accuracy = accuracy
self._attributes = attributes self._attributes = attributes
self._name = device self._name = device
@ -401,11 +404,6 @@ class TraccarEntity(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."""
@ -468,7 +466,7 @@ class TraccarEntity(TrackerEntity, RestoreEntity):
self, device, latitude, longitude, battery, accuracy, attributes self, device, latitude, longitude, battery, accuracy, attributes
): ):
"""Mark the device as seen.""" """Mark the device as seen."""
if device != self.name: if device != self._name:
return return
self._latitude = latitude self._latitude = latitude