We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 680af4e commit 368c2bbCopy full SHA for 368c2bb
1 file changed
custom_components/battery_notes/sensor.py
@@ -923,19 +923,21 @@ def _update_state(self, result):
923
self._attr_available = False
924
state = None
925
926
- if state == self._state:
+ clamped_state = max(0, min(100, state)) if state is not None else state
927
+
928
+ if clamped_state == self._state:
929
return
930
- self._state = state
- self.coordinator.current_battery_level = state
931
+ self._state = clamped_state
932
+ self.coordinator.current_battery_level = clamped_state
933
934
self._attr_available = True
935
self._attr_native_value = self.coordinator.rounded_battery_level
936
937
_LOGGER.debug(
938
"%s sensor battery_plus set to: %s via template",
939
self.entity_id,
- state,
940
+ clamped_state,
941
)
942
943
@property
0 commit comments