From 4e709254c7d38a503fa64f7715f515ca650d3980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Jonas=20S=C3=A4mann?= Date: Tue, 24 May 2022 19:59:40 +0200 Subject: [PATCH 1/2] pypackage add event log entry count for 1161 --- tools/rpi/hoymiles/decoders/__init__.py | 8 +++++++- tools/rpi/hoymiles/outputs.py | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/rpi/hoymiles/decoders/__init__.py b/tools/rpi/hoymiles/decoders/__init__.py index 8aaf2d369..8e4e91bba 100644 --- a/tools/rpi/hoymiles/decoders/__init__.py +++ b/tools/rpi/hoymiles/decoders/__init__.py @@ -46,6 +46,7 @@ class StatusResponse(Response): temperature = None frequency = None powerfactor = None + event_count = None def unpack(self, fmt, base): """ @@ -120,6 +121,7 @@ def __dict__(self): data['temperature'] = self.temperature data['frequency'] = self.frequency data['powerfactor'] = self.powerfactor + data['event_count'] = self.event_count data['time'] = self.time_rx return data @@ -544,7 +546,7 @@ def temperature(self): """ Inverter temperature in °C """ return self.unpack('>H', 38)[0]/10 @property - def alarm_count(self): + def event_count(self): """ Event counter """ return self.unpack('>H', 40)[0] @@ -667,6 +669,10 @@ def powerfactor(self): def temperature(self): """ Inverter temperature in °C """ return self.unpack('>H', 58)[0]/10 + @property + def event_count(self): + """ Event counter """ + return self.unpack('>H', 60)[0] class Hm1200Decode11(EventsResponse): """ Inverter generic events log """ diff --git a/tools/rpi/hoymiles/outputs.py b/tools/rpi/hoymiles/outputs.py index 84d057e3a..62a4cb938 100644 --- a/tools/rpi/hoymiles/outputs.py +++ b/tools/rpi/hoymiles/outputs.py @@ -114,6 +114,8 @@ def store_status(self, response, **params): data_stack.append(f'{measurement},string={string_id},type=current value={string["current"]:3f} {ctime}') string_id = string_id + 1 # Global + if data['event_count'] is not None: + data_stack.append(f'{measurement},type=total_events value={data["event_count"]} {ctime}') if data['powerfactor'] is not None: data_stack.append(f'{measurement},type=pf value={data["powerfactor"]:f} {ctime}') data_stack.append(f'{measurement},type=frequency value={data["frequency"]:.3f} {ctime}') From 391fec99d20b1fd8c53f453370da54b5543c97f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Jonas=20S=C3=A4mann?= Date: Sun, 29 May 2022 07:22:44 +0200 Subject: [PATCH 2/2] Pypackage fix interval sleep time --- tools/rpi/hoymiles/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/rpi/hoymiles/__main__.py b/tools/rpi/hoymiles/__main__.py index a9f8e9ed0..71b0fe134 100644 --- a/tools/rpi/hoymiles/__main__.py +++ b/tools/rpi/hoymiles/__main__.py @@ -268,7 +268,7 @@ def mqtt_on_command(client, userdata, message): print('', end='', flush=True) if loop_interval > 0 and (time.time() - t_loop_start) < loop_interval: - time.sleep(time.time() % loop_interval) + time.sleep(loop_interval - (time.time() - t_loop_start)) except KeyboardInterrupt: sys.exit()