Skip to content

Commit

Permalink
#134 current watt and amps if we get None, we should mark them as 0
Browse files Browse the repository at this point in the history
  • Loading branch information
leeyuentuen committed Apr 27, 2024
1 parent b4807a2 commit 447eee8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions custom_components/polestar_api/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 447eee8

Please sign in to comment.