mirror of
https://github.com/home-assistant/core.git
synced 2026-04-02 00:20:30 +01:00
Clamp surepetcare battery percentage to 0-100 (#166824)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -73,8 +73,8 @@ class SureBattery(SurePetcareEntity, SensorEntity):
|
||||
try:
|
||||
per_battery_voltage = state["battery"] / 4
|
||||
voltage_diff = per_battery_voltage - SURE_BATT_VOLTAGE_LOW
|
||||
self._attr_native_value = min(
|
||||
int(voltage_diff / SURE_BATT_VOLTAGE_DIFF * 100), 100
|
||||
self._attr_native_value = max(
|
||||
0, min(int(voltage_diff / SURE_BATT_VOLTAGE_DIFF * 100), 100)
|
||||
)
|
||||
except KeyError, TypeError:
|
||||
self._attr_native_value = None
|
||||
|
||||
Reference in New Issue
Block a user