Skip to content

Commit

Permalink
Merge pull request #365 from bj00rn/chore/calculate-correct-dc-link-v…
Browse files Browse the repository at this point in the history
…oltage
  • Loading branch information
argoyle authored Jul 8, 2023
2 parents 56df5e9 + a4a6417 commit a80833f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion custom_components/ferroamp/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ def update_state_from_events(self, events):
if neg is None and pos is None:
return False
else:
self._attr_native_value = int(neg / count + pos / count)
self._attr_native_value = round(float(pos / count - neg / count), 2)
self._attr_extra_state_attributes = dict(neg=round(float(neg / count), 2),
pos=round(float(pos / count), 2))
return True
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ async def test_setting_ehub_sensor_values_via_mqtt_message(hass, mqtt_mock):
}

state = hass.states.get("sensor.ferroamp_dc_link_voltage")
assert state.state == "0"
assert state.state == "768.27"
assert state.attributes == {
'device_class': 'voltage',
'friendly_name': 'EnergyHub DC Link Voltage',
Expand Down

0 comments on commit a80833f

Please sign in to comment.