From 057ff234d729ecc863d4cfc829866f0f12f8b127 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Thu, 1 Feb 2024 16:49:22 +0000 Subject: [PATCH] Fix rounding --- custom_components/battery_notes/binary_sensor.py | 2 +- custom_components/battery_notes/sensor.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/battery_notes/binary_sensor.py b/custom_components/battery_notes/binary_sensor.py index 5a484eff3..12b75af1b 100644 --- a/custom_components/battery_notes/binary_sensor.py +++ b/custom_components/battery_notes/binary_sensor.py @@ -272,7 +272,7 @@ async def async_state_changed_listener( if isfloat(wrapped_battery_state.state): if self.round_battery: - battery_level = int(wrapped_battery_state.state) + battery_level = round(float(wrapped_battery_state.state), 0) else: battery_level = round(float(wrapped_battery_state.state), 1) else: diff --git a/custom_components/battery_notes/sensor.py b/custom_components/battery_notes/sensor.py index a9edee42b..16af6f7db 100644 --- a/custom_components/battery_notes/sensor.py +++ b/custom_components/battery_notes/sensor.py @@ -321,7 +321,7 @@ def async_state_changed_listener( self._attr_available = True if self.round_battery: - self._attr_native_value = int(wrapped_battery_state.state) + self._attr_native_value = round(float(wrapped_battery_state.state), 0) else: self._attr_native_value = round(float(wrapped_battery_state.state), 1)