Skip to content

Commit b9d5a21

Browse files
Merge pull request #817 from WillCodeForCats/code-quality
Log battery rating warning once
2 parents 126cb80 + b6d0c2c commit b9d5a21

File tree

1 file changed

+12
-5
lines changed
  • custom_components/solaredge_modbus_multi

1 file changed

+12
-5
lines changed

custom_components/solaredge_modbus_multi/sensor.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,6 +2242,10 @@ class SolarEdgeBatteryAvailableEnergy(SolarEdgeSensorBase):
22422242
suggested_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
22432243
suggested_display_precision = 3
22442244

2245+
def __init__(self, platform, config_entry, coordinator):
2246+
super().__init__(platform, config_entry, coordinator)
2247+
self._log_warning = True
2248+
22452249
@property
22462250
def unique_id(self) -> str:
22472251
return f"{self._platform.uid_base}_avail_energy"
@@ -2263,11 +2267,14 @@ def native_value(self):
22632267
self._platform.decoded_common["B_RatedEnergy"]
22642268
* self._platform.battery_rating_adjust
22652269
):
2266-
_LOGGER.warning(
2267-
f"I{self._platform.inverter_unit_id}B{self._platform.battery_id}: "
2268-
"Battery available energy exceeds rated energy. "
2269-
"Set configuration for Battery Rating Adjustment when necessary."
2270-
)
2270+
if self._log_warning:
2271+
_LOGGER.warning(
2272+
f"I{self._platform.inverter_unit_id}B{self._platform.battery_id}: "
2273+
"Battery available energy exceeds rated energy. "
2274+
"Set configuration for Battery Rating Adjustment when necessary."
2275+
)
2276+
self._log_warning = False
2277+
22712278
return None
22722279

22732280
else:

0 commit comments

Comments
 (0)