don't initialize must_incr values with zero

- when the connection is just established by the inverter.
  sometimes the inverters send invalid data with the value zero.
  In this case, we no longer initialize the must_incr values,
  to avoid sending invalid data to the mqtt broker and the
  Home Assistant
This commit is contained in:
Stefan Allius
2023-10-26 20:23:53 +02:00
parent 658f42d4fe
commit 0c9f953476
2 changed files with 80 additions and 12 deletions

View File

@@ -341,7 +341,14 @@ class Infos:
dict = dict[key]
name += key + '.'
update = keys[-1] not in dict or (not must_incr and dict[keys[-1]] != result) or (must_incr and dict[keys[-1]] < result)
if keys[-1] not in dict:
update = (not must_incr or result>0)
else:
if must_incr:
update = dict[keys[-1]] < result
else:
update = dict[keys[-1]] != result
if update: dict[keys[-1]] = result
name += keys[-1]
yield keys[0], update
@@ -349,7 +356,7 @@ class Infos:
update = False
name = str(f'info-id.0x{info_id:x}')
self.tracer.log(level, f'{name} : {result}{unit}')
self.tracer.log(level, f'{name} : {result}{unit} update: {update}')
i +=1