Use shorthand attributes in locative device tracker (#126740)

This commit is contained in:
epenet 2024-09-25 18:27:18 +02:00 committed by GitHub
parent 0fa1478f90
commit fbf5d3966d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -35,25 +35,11 @@ class LocativeEntity(TrackerEntity):
def __init__(self, device, location, location_name): def __init__(self, device, location, location_name):
"""Set up Locative entity.""" """Set up Locative entity."""
self._name = device self._name = device
self._location = location self._attr_latitude = location[0]
self._location_name = location_name self._attr_longitude = location[1]
self._attr_location_name = location_name
self._unsub_dispatcher = None self._unsub_dispatcher = None
@property
def latitude(self):
"""Return latitude value of the device."""
return self._location[0]
@property
def longitude(self):
"""Return longitude value of the device."""
return self._location[1]
@property
def location_name(self):
"""Return a location name for the current location of the device."""
return self._location_name
@property @property
def name(self): def name(self):
"""Return the name of the device.""" """Return the name of the device."""
@ -74,6 +60,7 @@ class LocativeEntity(TrackerEntity):
"""Update device data.""" """Update device data."""
if device != self._name: if device != self._name:
return return
self._location_name = location_name self._attr_location_name = location_name
self._location = location self._attr_latitude = location[0]
self._attr_longitude = location[1]
self.async_write_ha_state() self.async_write_ha_state()