|
|
@ -227,6 +227,11 @@ class MqttOutputPlugin(OutputPluginFactory): |
|
|
|
""" |
|
|
|
|
|
|
|
data = response.__dict__() |
|
|
|
|
|
|
|
if data is None: |
|
|
|
logging.warn("received data object is empty") |
|
|
|
return |
|
|
|
|
|
|
|
topic = params.get('topic', None) |
|
|
|
if not topic: |
|
|
|
topic = f'{data.get("inverter_name", "hoymiles")}/{data.get("inverter_ser", None)}' |
|
|
@ -243,6 +248,7 @@ class MqttOutputPlugin(OutputPluginFactory): |
|
|
|
# AC Data |
|
|
|
phase_id = 0 |
|
|
|
phase_sum_power = 0 |
|
|
|
if data['phases'] is not None: |
|
|
|
for phase in data['phases']: |
|
|
|
self.client.publish(f'{topic}/emeter/{phase_id}/voltage', phase['voltage'], self.qos, self.ret) |
|
|
|
self.client.publish(f'{topic}/emeter/{phase_id}/current', phase['current'], self.qos, self.ret) |
|
|
@ -255,6 +261,7 @@ class MqttOutputPlugin(OutputPluginFactory): |
|
|
|
# DC Data |
|
|
|
string_id = 0 |
|
|
|
string_sum_power = 0 |
|
|
|
if data['strings'] is not None: |
|
|
|
for string in data['strings']: |
|
|
|
if 'name' in string: |
|
|
|
string_name = string['name'].replace(" ","_") |
|
|
@ -279,17 +286,21 @@ class MqttOutputPlugin(OutputPluginFactory): |
|
|
|
self.client.publish(f'{topic}/YieldTotal', data['yield_total']/1000, self.qos, self.ret) |
|
|
|
if data['yield_today'] is not None: |
|
|
|
self.client.publish(f'{topic}/YieldToday', data['yield_today']/1000, self.qos, self.ret) |
|
|
|
if data['efficiency'] is not None: |
|
|
|
self.client.publish(f'{topic}/Efficiency', data['efficiency'], self.qos, self.ret) |
|
|
|
|
|
|
|
|
|
|
|
elif isinstance(response, HardwareInfoResponse): |
|
|
|
if data["FW_ver_maj"] is not None and data["FW_ver_min"] is not None and data["FW_ver_pat"] is not None: |
|
|
|
self.client.publish(f'{topic}/Firmware/Version',\ |
|
|
|
f'{data["FW_ver_maj"]}.{data["FW_ver_min"]}.{data["FW_ver_pat"]}', self.qos, self.ret) |
|
|
|
|
|
|
|
if data["FW_build_dd"] is not None and data["FW_build_mm"] is not None and data["FW_build_yy"] is not None and data["FW_build_HH"] is not None and data["FW_build_MM"] is not None: |
|
|
|
self.client.publish(f'{topic}/Firmware/Build_at',\ |
|
|
|
f'{data["FW_build_dd"]}/{data["FW_build_mm"]}/{data["FW_build_yy"]}T{data["FW_build_HH"]}:{data["FW_build_MM"]}',\ |
|
|
|
self.qos, self.ret) |
|
|
|
|
|
|
|
if data["FW_HW_ID"] is not None: |
|
|
|
self.client.publish(f'{topic}/Firmware/HWPartId',\ |
|
|
|
f'{data["FW_HW_ID"]}', self.qos, self.ret) |
|
|
|
|
|
|
|