Update plugin.py

Make sure for lookup values, that the key exists in the lookup table.
This commit is contained in:
Addie Janssen
2020-10-09 16:07:21 +02:00
parent 88d3880074
commit 94df6ac59b

View File

@ -6,11 +6,10 @@
# Source: https://github.com/addiejanssen/domoticz-solaredge-modbustcp-plugin # Source: https://github.com/addiejanssen/domoticz-solaredge-modbustcp-plugin
# Author: Addie Janssen (https://addiejanssen.com) # Author: Addie Janssen (https://addiejanssen.com)
# License: MIT # License: MIT
# Version: 1.0.0
# #
""" """
<plugin key="SolarEdge_ModbusTCP" name="SolarEdge ModbusTCP" author="Addie Janssen" version="1.0.0" externallink="https://github.com/addiejanssen/domoticz-solaredge-modbustcp-plugin"> <plugin key="SolarEdge_ModbusTCP" name="SolarEdge ModbusTCP" author="Addie Janssen" version="1.0.2" externallink="https://github.com/addiejanssen/domoticz-solaredge-modbustcp-plugin">
<params> <params>
<param field="Address" label="Inverter IP Address" width="150px" required="true" /> <param field="Address" label="Inverter IP Address" width="150px" required="true" />
<param field="Port" label="Inverter Port Number" width="100px" required="true" default="502" /> <param field="Port" label="Inverter Port Number" width="100px" required="true" default="502" />
@ -331,8 +330,14 @@ class BasePlugin:
if unit[Column.LOOKUP]: if unit[Column.LOOKUP]:
Domoticz.Debug("-> looking up...") Domoticz.Debug("-> looking up...")
lookup = unit[Column.LOOKUP]
value = lookup[inverter_values[unit[Column.MODBUSNAME]]] lookup_table = unit[Column.LOOKUP]
to_lookup = inverter_values[unit[Column.MODBUSNAME]]
if to_lookup in lookup_table:
value = lookup_table[to_lookup]
else:
value = "Key not found in lookup table: {}".format(to_lookup)
# When a math object is setup for the unit, update the samples in it and get the calculated value. # When a math object is setup for the unit, update the samples in it and get the calculated value.