From 50f6f41d6ec912ae3df763aa8d8d7a1b32021b62 Mon Sep 17 00:00:00 2001 From: Addie Janssen <55428983+addiejanssen@users.noreply.github.com> Date: Sun, 27 Sep 2020 14:26:06 +0200 Subject: [PATCH] Changed device type for temperature --- plugin.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/plugin.py b/plugin.py index 87ff331..2790a4c 100644 --- a/plugin.py +++ b/plugin.py @@ -210,7 +210,7 @@ THREE_PHASE_INVERTER = [ [Unit.CURRENT_DC, "DC Current", 0xF3, 0x17, 0x00, {}, "current_dc", "current_dc_scale", "{:.2f}", None, None, None ], [Unit.VOLTAGE_DC, "DC Voltage", 0xF3, 0x08, 0x00, {}, "voltage_dc", "voltage_dc_scale", "{:.2f}", None, None, Average() ], [Unit.POWER_DC, "DC Power", 0xF8, 0x01, 0x00, {}, "power_dc", "power_dc_scale", "{:.2f}", None, None, Average() ], - [Unit.TEMPERATURE, "Temperature", 0x50, 0x05, 0x00, {}, "temperature", "temperature_scale", "{:.2f}", None, None, Maximum() ] + [Unit.TEMPERATURE, "Temperature", 0xF3, 0x05, 0x00, {}, "temperature", "temperature_scale", "{:.2f}", None, None, Maximum() ] ] # @@ -457,6 +457,33 @@ class BasePlugin: if unit[Column.MATH]: unit[Column.MATH].set_max_samples(self.max_samples) + + # We updated some device types over time. + # Let's make sure that we have the correct type setup. + + for unit in self._LOOKUP_TABLE: + if unit[Column.ID] in Devices: + device = Devices[unit[Column.ID]] + + if (device.Type != unit[Column.TYPE] or + device.SubType != unit[Column.SUBTYPE] or + device.SwitchType != unit[Column.SWITCHTYPE] or + device.Options != unit[Column.OPTIONS]): + + Domoticz.Log("Updating device \"{}\"".format(device.Name)) + + nValue = device.nValue + sValue = device.sValue + + device.Update( + Type=unit[Column.TYPE], + Subtype=unit[Column.SUBTYPE], + Switchtype=unit[Column.SWITCHTYPE], + Options=unit[Column.OPTIONS], + nValue=nValue, + sValue=sValue + ) + # Add missing devices if needed. if self.add_devices: