From 3d35541cf9f728443986504269b34bb8bafb0a65 Mon Sep 17 00:00:00 2001 From: Tuen Lee Date: Tue, 26 Dec 2023 22:05:19 +0100 Subject: [PATCH] sensor should also get exception on async update --- custom_components/polestar_api/sensor.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/custom_components/polestar_api/sensor.py b/custom_components/polestar_api/sensor.py index 461fa63..74afb7d 100644 --- a/custom_components/polestar_api/sensor.py +++ b/custom_components/polestar_api/sensor.py @@ -539,6 +539,9 @@ def unit_of_measurement(self) -> str: async def async_update(self) -> None: """Get the latest data and updates the states.""" - await self._device.async_update() - self._attr_native_value = self._device.get_value( - self.description.query, self.description.field_name, self.get_skip_cache()) + try: + await self._device.async_update() + self._attr_native_value = self._device.get_value( + self.description.query, self.description.field_name, self.get_skip_cache()) + except Exception: + _LOGGER.warning("Failed to update sensor async update")