From 7dedcc2c8af677bcce997e0433d34ee35cf30fe7 Mon Sep 17 00:00:00 2001 From: PaeserBastelstube <122045840+PaeserBastelstube@users.noreply.github.com> Date: Sat, 7 Jan 2023 13:25:19 +0100 Subject: [PATCH] Add mqtt global head (print timestamp) and add DC-yield-daily MQTT record must have a timestamp for visualising last data received. DC-yield-daily is availible in "data" variable, but not printed in mqtt record. MQTT topics between ESP and RPI shoud be equel, so I sugest to change topic for YieldTotal --- tools/rpi/hoymiles/__main__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/rpi/hoymiles/__main__.py b/tools/rpi/hoymiles/__main__.py index 8fc1b727..8a163aa5 100644 --- a/tools/rpi/hoymiles/__main__.py +++ b/tools/rpi/hoymiles/__main__.py @@ -209,6 +209,10 @@ def mqtt_send_status(broker, inverter_ser, data, topic=None): if not topic: topic = f'hoymiles/{inverter_ser}' + # Global Head + if data['time'] is not None: + broker.publish(f'{topic}/time', data['time'].strftime("%d.%m.%y - %H:%M:%S")) + # AC Data phase_id = 0 for phase in data['phases']: @@ -220,10 +224,11 @@ def mqtt_send_status(broker, inverter_ser, data, topic=None): # DC Data string_id = 0 for string in data['strings']: - broker.publish(f'{topic}/emeter-dc/{string_id}/total', string['energy_total']/1000) - broker.publish(f'{topic}/emeter-dc/{string_id}/power', string['power']) broker.publish(f'{topic}/emeter-dc/{string_id}/voltage', string['voltage']) broker.publish(f'{topic}/emeter-dc/{string_id}/current', string['current']) + broker.publish(f'{topic}/emeter-dc/{string_id}/power', string['power']) + broker.publish(f'{topic}/emeter-dc/{string_id}/YieldDay', string['energy_daily']) + broker.publish(f'{topic}/emeter-dc/{string_id}/YieldTotal', string['energy_total']/1000) string_id = string_id + 1 # Global if data['powerfactor'] is not None: