diff --git a/Modules/domoCreate.py b/Modules/domoCreate.py index 09ea64763..b99723a51 100644 --- a/Modules/domoCreate.py +++ b/Modules/domoCreate.py @@ -549,6 +549,7 @@ def set_default_value( self, Devices, unit, widget_record): "Alarm_ZL2": { "Type": 243, "Subtype": 22, "Switchtype": 0, }, "Alarm_ZL3": { "Type": 243, "Subtype": 22, "Switchtype": 0, }, "AirPurifierAlarm": { "Type": 243, "Subtype": 22, "Switchtype": 0, }, + "PowerFactor": { "Type": 243, "Subtype": 6, "Switchtype": 0, }, "Valve": { "Type": 243, "Subtype": 6, "Switchtype": 0, }, "FanSpeed": { "Type": 243, "Subtype": 6, "Switchtype": 0, }, "ThermoSetpoint": { "Type": 242, "Subtype": 1, }, diff --git a/Modules/domoMaj.py b/Modules/domoMaj.py index aa38a73aa..72079f932 100644 --- a/Modules/domoMaj.py +++ b/Modules/domoMaj.py @@ -581,13 +581,15 @@ def MajDomoDevice(self, Devices, NWKID, Ep, clusterID, value, Attribute_="", Col data = "09" UpdateDevice_v2(self, Devices, DeviceUnit, int(data), str(state), BatteryLevel, SignalLevel, ForceUpdate_=True) - if "Valve" in ClusterType: # Valve Position - if WidgetType == "Valve" and Attribute_ in ("026d", "4001", "0008"): - # value int is the % of the valve opening - # Percentage Widget - nValue = round(value, 1) - sValue = str(nValue) - UpdateDevice_v2(self, Devices, DeviceUnit, nValue, sValue, BatteryLevel, SignalLevel) + if "Valve" in ClusterType and (WidgetType == "Valve" and Attribute_ in ("026d", "4001", "0008")): + nValue = round(value, 1) + sValue = str(nValue) + UpdateDevice_v2(self, Devices, DeviceUnit, nValue, sValue, BatteryLevel, SignalLevel) + + if "PowerFactor" in ClusterType and WidgetType == "PowerFactor": + nValue = round(value, 1) + sValue = str(nValue) + UpdateDevice_v2(self, Devices, DeviceUnit, nValue, sValue, BatteryLevel, SignalLevel) if "ThermoMode" in ClusterType: # Thermostat Mode self.log.logging("Widget", "Debug", "ThermoMode %s WidgetType: %s Value: %s (%s) Attribute_: %s" % ( diff --git a/Modules/domoTools.py b/Modules/domoTools.py index 4c3b66640..25cfec594 100644 --- a/Modules/domoTools.py +++ b/Modules/domoTools.py @@ -568,7 +568,8 @@ def GetType(self, Addr, Ep): "fc80": "Heiman", "Distance": "Distance", "TamperSwitch": "TamperSwitch", - "Notification": "Notification" + "Notification": "Notification", + "PowerFactor": "PowerFactor" } def TypeFromCluster(self, cluster, create_=False, ProfileID_="", ZDeviceID_="", ModelName=""): diff --git a/Modules/tuyaTS0601.py b/Modules/tuyaTS0601.py index fd627786b..76b4a06d2 100644 --- a/Modules/tuyaTS0601.py +++ b/Modules/tuyaTS0601.py @@ -303,9 +303,13 @@ def ts0601_current(self, Devices, nwkid, ep, value): self.log.logging( "Tuya0601", "Debug", "ts0601_current - Current %s %s %s" % (nwkid, ep, value), nwkid, ) MajDomoDevice(self, Devices, nwkid, ep, "0b04", value, Attribute_="0508") checkAndStoreAttributeValue(self, nwkid, ep, "0b04", "0508", value) # Store int - store_tuya_attribute(self, nwkid, "Current", value) - + store_tuya_attribute(self, nwkid, "Current_%s" %ep, value) +def ts0601_power_factor(self, Devices, nwkid, ep, value): + self.log.logging( "Tuya0601", "Debug", "ts0601_current - Current %s %s %s" % (nwkid, ep, value), nwkid, ) + MajDomoDevice(self, Devices, nwkid, ep, "PowerFactor", value) + store_tuya_attribute(self, nwkid, "PowerFactor_%s" %ep, value) + def ts0601_summation_energy(self, Devices, nwkid, ep, value): self.log.logging( "Tuya0601", "Debug", "ts0601_summation_energy - Current Summation %s %s %s" % (nwkid, ep, value), nwkid, ) previous_summation = getAttributeValue(self, nwkid, ep, "0702", "0000") @@ -314,19 +318,19 @@ def ts0601_summation_energy(self, Devices, nwkid, ep, value): nwkid, ep, value, previous_summation, current_summation), nwkid, ) MajDomoDevice(self, Devices, nwkid, ep, "0702", current_summation, Attribute_="0000") checkAndStoreAttributeValue(self, nwkid, ep, "0702", "0000", current_summation) # Store int - store_tuya_attribute(self, nwkid, "Energy", value) + store_tuya_attribute(self, nwkid, "Energy_%s" %ep, value) def ts0601_summation_energy_raw(self, Devices, nwkid, ep, value): self.log.logging( "Tuya0601", "Debug", "ts0601_summation_energy - Current Summation %s %s %s" % (nwkid, ep, value), nwkid, ) MajDomoDevice(self, Devices, nwkid, ep, "0702", value, Attribute_="0000") checkAndStoreAttributeValue(self, nwkid, ep, "0702", "0000", value) # Store int - store_tuya_attribute(self, nwkid, "ConsumedEnergy", value) + store_tuya_attribute(self, nwkid, "ConsumedEnergy_%s" %ep, value) def ts0601_production_energy(self, Devices, nwkid, ep, value): self.log.logging( "Tuya0601", "Debug", "ts0601_production_energy - Production Energy %s %s %s" % (nwkid, ep, value), nwkid, ) MajDomoDevice(self, Devices, nwkid, ep, "0702", value, Attribute_="0001") checkAndStoreAttributeValue(self, nwkid, ep, "0702", "0001", value) # Store int - store_tuya_attribute(self, nwkid, "ProducedEnergy", value) + store_tuya_attribute(self, nwkid, "ProducedEnergy_%s" %ep, value) def ts0601_instant_power(self, Devices, nwkid, ep, value): @@ -338,7 +342,7 @@ def ts0601_instant_power(self, Devices, nwkid, ep, value): checkAndStoreAttributeValue(self, nwkid, ep, "0702", "0400", signed_int) MajDomoDevice(self, Devices, nwkid, ep, "0702", signed_int) - store_tuya_attribute(self, nwkid, "InstantPower", signed_int) # Store str + store_tuya_attribute(self, nwkid, "InstantPower_%s" %ep, signed_int) # Store str def ts0601_voltage(self, Devices, nwkid, ep, value): self.log.logging( "Tuya0601", "Debug", "ts0601_voltage - Voltage %s %s %s" % (nwkid, ep, value), nwkid, ) @@ -498,6 +502,7 @@ def ts0601_sensor_irrigation_mode(self, Devices, nwkid, ep, value): "smoke_state": ts0601_smoke_detection, "smoke_ppm": ts0601_smoke_concentration, "water_consumption": ts0601_water_consumption, + "power_factor": ts0601_power_factor, } def ts0601_tuya_cmd(self, NwkId, Ep, action, data):