From 16364636d1e48fe0080767241849b274ec3998f8 Mon Sep 17 00:00:00 2001 From: czechmark Date: Fri, 13 Nov 2020 17:10:04 -0500 Subject: [PATCH] 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 --- homeassistant/components/fitbit/sensor.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/homeassistant/components/fitbit/sensor.py b/homeassistant/components/fitbit/sensor.py index f6e3fd90fe5..387eb78448c 100644 --- a/homeassistant/components/fitbit/sensor.py +++ b/homeassistant/components/fitbit/sensor.py @@ -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")