Update fitbit battery status (#42980)
* Read the device_status in order to update the fitbit battery * Read the device_status in order to update the fitbit batterypull/43206/head
parent
bae026a6fe
commit
16364636d1
|
@ -472,7 +472,13 @@ class FitbitSensor(Entity):
|
|||
def update(self):
|
||||
"""Get the latest data from the Fitbit API and update the states."""
|
||||
if self.resource_type == "devices/battery" and self.extra:
|
||||
registered_devs = self.client.get_devices()
|
||||
device_id = self.extra.get("id")
|
||||
self.extra = list(
|
||||
filter(lambda device: device.get("id") == device_id, registered_devs)
|
||||
)[0]
|
||||
self._state = self.extra.get("battery")
|
||||
|
||||
else:
|
||||
container = self.resource_type.replace("/", "-")
|
||||
response = self.client.time_series(self.resource_type, period="7d")
|
||||
|
|
Loading…
Reference in New Issue