From 78ed3b54ab9c98f94131c7c10a5f9c212d1a81ce Mon Sep 17 00:00:00 2001 From: Johannes Ott Date: Sat, 6 Jan 2024 22:36:47 +0100 Subject: [PATCH] Check powerflow to previous Signed-off-by: Johannes Ott --- solaredge2mqtt/models/powerflow.py | 3 ++- solaredge2mqtt/service.py | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/solaredge2mqtt/models/powerflow.py b/solaredge2mqtt/models/powerflow.py index 8122355..db8cd9c 100644 --- a/solaredge2mqtt/models/powerflow.py +++ b/solaredge2mqtt/models/powerflow.py @@ -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 @@ -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: diff --git a/solaredge2mqtt/service.py b/solaredge2mqtt/service.py index 3549ec8..2544f9c 100644 --- a/solaredge2mqtt/service.py +++ b/solaredge2mqtt/service.py @@ -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)