Skip to content

Commit

Permalink
Fix rounding (#746)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-codechimp committed Feb 1, 2024
1 parent dbc4ff7 commit 4525932
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion custom_components/battery_notes/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/battery_notes/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 4525932

Please sign in to comment.