add inc and dec methods for proxy statistic counters
This commit is contained in:
@@ -68,6 +68,7 @@ class Inverter(AsyncStream):
|
|||||||
async def async_publ_mqtt(self) -> None:
|
async def async_publ_mqtt(self) -> None:
|
||||||
'''puplish data to MQTT broker'''
|
'''puplish data to MQTT broker'''
|
||||||
db = self.db.db
|
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
|
# 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
|
if (('inverter' in self.new_data and self.new_data['inverter']) or
|
||||||
('collector' in self.new_data and self.new_data['collector']) 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
|
self.ha_restarts = self.mqtt.ha_restarts
|
||||||
|
|
||||||
for key in self.new_data:
|
for key in self.new_data:
|
||||||
if self.new_data[key] and key in db:
|
if self.new_data[key]:
|
||||||
data_json = json.dumps(db[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}')
|
logger_mqtt.debug(f'{key}: {data_json}')
|
||||||
await self.mqtt.publish(f"{self.entitiy_prfx}{self.node_id}{key}", data_json)
|
await self.mqtt.publish(f"{self.entitiy_prfx}{self.node_id}{key}", data_json)
|
||||||
self.new_data[key] = False
|
self.new_data[key] = False
|
||||||
|
|||||||
Reference in New Issue
Block a user