From 3c8e7666d4befd9737a510a095a48f82112ef486 Mon Sep 17 00:00:00 2001 From: Stefan Allius Date: Sun, 15 Oct 2023 15:46:05 +0200 Subject: [PATCH] add inc and dec methods for proxy statistic counters --- app/src/inverter.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/inverter.py b/app/src/inverter.py index c098d28..14c90cb 100644 --- a/app/src/inverter.py +++ b/app/src/inverter.py @@ -68,6 +68,7 @@ class Inverter(AsyncStream): async def async_publ_mqtt(self) -> None: '''puplish data to MQTT broker''' db = self.db.db + stat = self.db.stat # check if new inverter or collector infos are available or when the home assistant has changed the status back to online if (('inverter' in self.new_data and self.new_data['inverter']) or ('collector' in self.new_data and self.new_data['collector']) or @@ -76,8 +77,13 @@ class Inverter(AsyncStream): self.ha_restarts = self.mqtt.ha_restarts for key in self.new_data: - if self.new_data[key] and key in db: - data_json = json.dumps(db[key]) + if self.new_data[key]: + if key in db: + data_json = json.dumps(db[key]) + elif key in stat: + data_json = json.dumps(stat[key]) + else: + continue logger_mqtt.debug(f'{key}: {data_json}') await self.mqtt.publish(f"{self.entitiy_prfx}{self.node_id}{key}", data_json) self.new_data[key] = False