From 447eee8df122a46efdbad5012ec4e7bc5817f088 Mon Sep 17 00:00:00 2001 From: Tuen Lee Date: Sat, 27 Apr 2024 21:39:59 +0000 Subject: [PATCH] #134 current watt and amps if we get None, we should mark them as 0 --- custom_components/polestar_api/sensor.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/custom_components/polestar_api/sensor.py b/custom_components/polestar_api/sensor.py index c32866c..c6671e5 100644 --- a/custom_components/polestar_api/sensor.py +++ b/custom_components/polestar_api/sensor.py @@ -678,6 +678,12 @@ async def async_update(self) -> None: if value is not None: self._attr_native_value = value self._sensor_data = value + # Charging current and charging power can become none, so we are going to set them to 0 + elif self._attr_native_value is None and self.entity_description.key in ('charging_current', 'charging_power'): + self._attr_native_value = 0 + self._sensor_data = 0 + + except Exception: _LOGGER.warning("Failed to update sensor async update") self._device.polestarApi.next_update = datetime.now() + timedelta(seconds=60)