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 battery
pull/43206/head
czechmark 2020-11-13 17:10:04 -05:00 committed by GitHub
parent bae026a6fe
commit 16364636d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -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")