mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
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
This commit is contained in:
parent
bae026a6fe
commit
16364636d1
@ -472,7 +472,13 @@ class FitbitSensor(Entity):
|
|||||||
def update(self):
|
def update(self):
|
||||||
"""Get the latest data from the Fitbit API and update the states."""
|
"""Get the latest data from the Fitbit API and update the states."""
|
||||||
if self.resource_type == "devices/battery" and self.extra:
|
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")
|
self._state = self.extra.get("battery")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
container = self.resource_type.replace("/", "-")
|
container = self.resource_type.replace("/", "-")
|
||||||
response = self.client.time_series(self.resource_type, period="7d")
|
response = self.client.time_series(self.resource_type, period="7d")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user