Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #129 midnight glitch for HA2024.1 #130

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions custom_components/fusion_solar/fusion_solar/energy_sensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import math

from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.components.sensor import SensorEntity, SensorDeviceClass, SensorStateClass
Expand Down Expand Up @@ -60,14 +61,12 @@ def native_value(self) -> float:
if entity is not None:
current_value = entity.state
if current_value == 'unavailable':
_LOGGER.info(
f'{self.entity_id}: not available.')
_LOGGER.info(f'{self.entity_id}: not available.')
return

realtime_power = self.coordinator.data[self._data_name][ATTR_REALTIME_POWER]
if realtime_power == '0.00':
_LOGGER.info(
f'{self.entity_id}: not producing any power, so not updating to prevent positive glitched.')
if math.isclose(realtime_power, 0, abs_tol = 0.001):
_LOGGER.info(f'{self.entity_id}: not producing any power, so no energy update to prevent glitches.')
return float(current_value)

if self._data_name not in self.coordinator.data:
Expand Down
Loading