Skip to content

Commit

Permalink
Take absolute value of net metered channel
Browse files Browse the repository at this point in the history
Previous versions of this integration were taking the polarized value
when net metering was on. Switching to taking the net value resulted in
some installations starting to report negative values. While that may
have been technically correct, Home Assistant expects positive values to
be flowing into the energy dashboard, so we'll take the absolute value.
  • Loading branch information
jkeljo committed Sep 4, 2023
1 parent 13f7bac commit 95a5cd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion custom_components/greeneye_monitor/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"issue_tracker": "https://github.com/jkeljo/hacs-greeneye-monitor/issues",
"loggers": ["greeneye"],
"requirements": ["greeneye_monitor==4.1"],
"version": "2023.09.03"
"version": "2023.9.4"
}
5 changes: 4 additions & 1 deletion custom_components/greeneye_monitor/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ def extra_state_attributes(self) -> dict[str, Any] | None:
"""Return total wattseconds in the state dictionary."""
if self._net_metering:
watt_seconds = self._sensor.net_watt_seconds
if watt_seconds:
watt_seconds = abs(watt_seconds)
else:
watt_seconds = self._sensor.absolute_watt_seconds

Expand Down Expand Up @@ -425,7 +427,8 @@ def __init__(
def native_value(self) -> float | None:
"""Return the total number of kilowatt hours measured by this channel."""
if self._net_metering:
return self._sensor.net_kilowatt_hours
net_kwh = self._sensor.net_kilowatt_hours
return abs(net_kwh) if net_kwh else None
else:
return self._sensor.absolute_kilowatt_hours

Expand Down

0 comments on commit 95a5cd2

Please sign in to comment.