From 5edb7ad2d35aa8d7ea6c253bd311c07b606bf42b Mon Sep 17 00:00:00 2001 From: Patrick Pichon Date: Mon, 5 Aug 2024 22:34:46 +0200 Subject: [PATCH] implement BatteryPercentage widget --- Modules/domoCreate.py | 6 ++++++ Modules/domoMaj.py | 6 +++++- Modules/tuyaTS0601.py | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Modules/domoCreate.py b/Modules/domoCreate.py index e52c92a04..54f599375 100644 --- a/Modules/domoCreate.py +++ b/Modules/domoCreate.py @@ -731,6 +731,12 @@ def set_default_value( self, Devices, device_id_ieee, device_unit, widget_record "Type": 243, "Subtype": 19 }, + "BatteryPercentage": { + "Type": 243, + "Subtype": 6, + "Switchtype": 0 + }, + "P1Meter": { "Type": 250, "Subtype": 1, diff --git a/Modules/domoMaj.py b/Modules/domoMaj.py index 309a758cf..df0bef3c3 100644 --- a/Modules/domoMaj.py +++ b/Modules/domoMaj.py @@ -137,6 +137,10 @@ def _domo_maj_one_cluster_type_entry( self, Devices, NwkId, Ep, device_id_ieee, nValue = int(value) update_domoticz_widget(self, Devices, device_id_ieee, device_unit, nValue, text, BatteryLevel, SignalLevel) + if WidgetType == "BatteryPercentage" and ClusterType == "Voltage" and Attribute_ == "0021": + sValue = str(nValue) + update_domoticz_widget(self, Devices, device_id_ieee, device_unit, 0, sValue, BatteryLevel, SignalLevel) + if ClusterType == "Alarm" and WidgetType == "Alarm_ZL3" and Attribute_ == "0020": if value is None or len(value) == 0: return @@ -532,7 +536,7 @@ def _domo_maj_one_cluster_type_entry( self, Devices, NwkId, Ep, device_id_ieee, update_domoticz_widget(self, Devices, device_id_ieee, device_unit, int(data), str(state), BatteryLevel, SignalLevel, ForceUpdate_=True) if "Valve" in ClusterType and (WidgetType == "Valve" and Attribute_ in ("026d", "4001", "0008")): - nValue = round(value, 1) + nValue = 0 sValue = str(nValue) update_domoticz_widget(self, Devices, device_id_ieee, device_unit, nValue, sValue, BatteryLevel, SignalLevel) diff --git a/Modules/tuyaTS0601.py b/Modules/tuyaTS0601.py index 08ea16051..954c9e5ca 100644 --- a/Modules/tuyaTS0601.py +++ b/Modules/tuyaTS0601.py @@ -283,6 +283,7 @@ def ts0601_battery(self, Devices, nwkid, ep, value ): checkAndStoreAttributeValue(self, nwkid, "01", "0001", "0000", value) self.ListOfDevices[nwkid]["Battery"] = value Update_Battery_Device(self, Devices, nwkid, value) + MajDomoDevice(self, Devices, nwkid, ep, "0001", "0021", value) store_tuya_attribute(self, nwkid, "BatteryStatus", value)