Added test for values < 0

This commit is contained in:
Addie Janssen
2020-10-09 17:07:04 +02:00
parent f268dae08f
commit f9cc7747c2

View File

@ -9,7 +9,7 @@
#
"""
<plugin key="SolarEdge_ModbusTCP" name="SolarEdge ModbusTCP" author="Addie Janssen" version="1.0.3" externallink="https://github.com/addiejanssen/domoticz-solaredge-modbustcp-plugin">
<plugin key="SolarEdge_ModbusTCP" name="SolarEdge ModbusTCP" author="Addie Janssen" version="1.0.4" externallink="https://github.com/addiejanssen/domoticz-solaredge-modbustcp-plugin">
<params>
<param field="Address" label="Inverter IP Address" width="150px" required="true" />
<param field="Port" label="Inverter Port Number" width="100px" required="true" default="502" />
@ -334,7 +334,7 @@ class BasePlugin:
lookup_table = unit[Column.LOOKUP]
to_lookup = int(inverter_values[unit[Column.MODBUSNAME]])
if to_lookup < len(lookup_table):
if to_lookup >= 0 and to_lookup < len(lookup_table):
value = lookup_table[to_lookup]
else:
value = "Key not found in lookup table: {}".format(to_lookup)