Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lumapu committed Jun 2, 2022
2 parents c7d039a + a9d4418 commit e7d0e4a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/rpi/hoymiles/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
8 changes: 7 additions & 1 deletion tools/rpi/hoymiles/decoders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class StatusResponse(Response):
temperature = None
frequency = None
powerfactor = None
event_count = None

def unpack(self, fmt, base):
"""
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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 """
Expand Down
2 changes: 2 additions & 0 deletions tools/rpi/hoymiles/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Expand Down

0 comments on commit e7d0e4a

Please sign in to comment.