Skip to content

Commit

Permalink
Revert "Include the check for yearEnergy and monthEnergy also. See #135"
Browse files Browse the repository at this point in the history
This reverts commit 82cb53f.
  • Loading branch information
tijsverkoyen committed Jan 26, 2024
1 parent 2d92d5a commit 1aed151
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions custom_components/fusion_solar/fusion_solar/energy_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from homeassistant.components.sensor import SensorEntity, SensorDeviceClass, SensorStateClass
from homeassistant.const import UnitOfEnergy

from .const import ATTR_TOTAL_LIFETIME_ENERGY, ATTR_TOTAL_CURRENT_YEAR_ENERGY, ATTR_TOTAL_CURRENT_MONTH_ENERGY, \
ATTR_REALTIME_POWER
from .const import ATTR_TOTAL_LIFETIME_ENERGY, ATTR_REALTIME_POWER

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -45,14 +44,10 @@ def name(self) -> str:

@property
def native_value(self) -> float:
# It seems like Huawei Fusion Solar returns some invalid data for the cumulativeEnergy, yearEnergy and
# monthEnergy just before midnight.
# So we update the value only if the system is producing power at the moment.
if (
ATTR_TOTAL_LIFETIME_ENERGY == self._attribute
or ATTR_TOTAL_CURRENT_YEAR_ENERGY == self._attribute
or ATTR_TOTAL_CURRENT_MONTH_ENERGY == self._attribute
):
# It seems like Huawei Fusion Solar returns some invalid data for the lifetime energy just before midnight
# Therefore we validate if the new value is higher than the current value
if ATTR_TOTAL_LIFETIME_ENERGY == self._attribute:
# Grab the current data
entity = self.hass.states.get(self.entity_id)
if entity is not None:
try:
Expand Down

0 comments on commit 1aed151

Please sign in to comment.