mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +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):
|
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()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user