Skip to content

Commit

Permalink
Check powerflow to previous
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Ott <[email protected]>
  • Loading branch information
DerOetzi committed Jan 6, 2024
1 parent 95be31a commit 78ed3b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion solaredge2mqtt/models/powerflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from typing import Dict, Optional, ClassVar

from solaredge2mqtt.logging import logger
from solaredge2mqtt.models.base import InfluxDBModel
from solaredge2mqtt.models.modbus import SunSpecBattery, SunSpecInverter, SunSpecMeter

Expand Down Expand Up @@ -214,7 +215,7 @@ def is_valid(self) -> bool:
)

@classmethod
def check_debounce(cls, powerflow: Powerflow) -> bool:
def is_not_valid_with_last(cls, powerflow: Powerflow) -> bool:
check = False

if cls.last_powerflow is not None:
Expand Down
8 changes: 6 additions & 2 deletions solaredge2mqtt/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,12 @@ async def modbus_and_wallbox_loop(
logger.warning("Invalid powerflow data: {powerflow}", powerflow=powerflow)
return

if Powerflow.check_debounce(powerflow):
logger.warning("Powerflow debounce: {powerflow}", powerflow=powerflow)
if Powerflow.is_not_valid_with_last(powerflow):
logger.warning(
"Value change not valid: {last_powerflow} {powerflow}",
last_powerflow=Powerflow.last_powerflow,
powerflow=powerflow,
)
return

logger.debug(powerflow)
Expand Down

0 comments on commit 78ed3b5

Please sign in to comment.