mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use shorthand attributes in locative device tracker (#126740)
This commit is contained in:
parent
0fa1478f90
commit
fbf5d3966d
@ -35,25 +35,11 @@ class LocativeEntity(TrackerEntity):
|
||||
def __init__(self, device, location, location_name):
|
||||
"""Set up Locative entity."""
|
||||
self._name = device
|
||||
self._location = location
|
||||
self._location_name = location_name
|
||||
self._attr_latitude = location[0]
|
||||
self._attr_longitude = location[1]
|
||||
self._attr_location_name = location_name
|
||||
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
|
||||
def name(self):
|
||||
"""Return the name of the device."""
|
||||
@ -74,6 +60,7 @@ class LocativeEntity(TrackerEntity):
|
||||
"""Update device data."""
|
||||
if device != self._name:
|
||||
return
|
||||
self._location_name = location_name
|
||||
self._location = location
|
||||
self._attr_location_name = location_name
|
||||
self._attr_latitude = location[0]
|
||||
self._attr_longitude = location[1]
|
||||
self.async_write_ha_state()
|
||||
|
Loading…
x
Reference in New Issue
Block a user