Skip to content

Commit

Permalink
feat: remove default rounding on values (#202)
Browse files Browse the repository at this point in the history
* feat: remove default rounding on values

* formatting
  • Loading branch information
firstof9 authored Mar 26, 2023
1 parent dd2e803 commit 0ba7a28
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions custom_components/openevse/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ def native_value(self) -> Any:
self._state = None
if self._type in data.keys():
if self._type == "charge_time_elapsed":
self._state = round(data[self._type] / 60, 2)
self._state = data[self._type] / 60
elif self._type == "usage_total" and isinstance(data[self._type], int):
self._state = round(data[self._type] / 1000, 2)
self._state = data[self._type] / 1000
elif self._type in [
"usage_session",
"charging_current",
"charging_power",
]:
self._state = round(data[self._type] / 1000, 2)
self._state = data[self._type] / 1000
elif self._type == "charging_voltage":
self._state = round(data[self._type], 0)
self._state = data[self._type]
else:
self._state = data[self._type]

Expand Down
3 changes: 3 additions & 0 deletions tests/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ async def test_sensors(hass, test_charger, mock_ws_start):
state = hass.states.get("sensor.openevse_charge_time_elapsed")
assert state
assert state.state == "4.1"
state = hass.states.get("sensor.openevse_total_usage")
assert state
assert state.state == "64.582"

0 comments on commit 0ba7a28

Please sign in to comment.