Resolve Bugs for multiple sockets device
Just create one device for A, kWh, V, W per plug in case of multiple sockets (DPS)
This commit is contained in:
21
plugin.py
21
plugin.py
@@ -337,7 +337,8 @@ class BasePlugin:
|
|||||||
max_dps = max_unit
|
max_dps = max_unit
|
||||||
|
|
||||||
#groups management: #syntax: 1;2 : 3;4
|
#groups management: #syntax: 1;2 : 3;4
|
||||||
max_unit = max_unit + 1
|
# +5 instead of +1 to have spare room for the extra devices for Amp, W, kWh
|
||||||
|
max_unit = max_unit + 5
|
||||||
if(Parameters["Mode4"]!="None"):
|
if(Parameters["Mode4"]!="None"):
|
||||||
groups = Parameters["Mode4"].split(":")
|
groups = Parameters["Mode4"].split(":")
|
||||||
for group in groups:
|
for group in groups:
|
||||||
@@ -353,14 +354,16 @@ class BasePlugin:
|
|||||||
if(val <= max_dps): #single socket dps
|
if(val <= max_dps): #single socket dps
|
||||||
Domoticz.Device(Name="Tuya SmartPlug (Switch)", Unit=val, TypeName="Switch").Create()
|
Domoticz.Device(Name="Tuya SmartPlug (Switch)", Unit=val, TypeName="Switch").Create()
|
||||||
Domoticz.Log("Tuya SmartPlug Device (Switch) #" + str(val) +" created.")
|
Domoticz.Log("Tuya SmartPlug Device (Switch) #" + str(val) +" created.")
|
||||||
Domoticz.Device(Name="Tuya SmartPlug (A)" , Unit=val+1, TypeName="Current (Single)").Create()
|
## After the last DPS add the global devices
|
||||||
Domoticz.Log("Tuya SmartPlug Device (A) #" + str(val+1) +" created.")
|
if(val == max_dps):
|
||||||
Domoticz.Device(Name="Tuya SmartPlug (kWh)", Unit=val+2, TypeName="kWh").Create()
|
Domoticz.Device(Name="Tuya SmartPlug (A)" , Unit=val+1, TypeName="Current (Single)").Create()
|
||||||
Domoticz.Log("Tuya SmartPlug Device kWh #" + str(val+2) +" created.")
|
Domoticz.Log("Tuya SmartPlug Device (A) #" + str(val+1) +" created.")
|
||||||
Domoticz.Device(Name="Tuya SmartPlug (V)", Unit=val+3, TypeName="Voltage").Create()
|
Domoticz.Device(Name="Tuya SmartPlug (kWh)", Unit=val+2, TypeName="kWh").Create()
|
||||||
Domoticz.Log("Tuya SmartPlug Device (V) #" + str(val+3) +" created.")
|
Domoticz.Log("Tuya SmartPlug Device kWh #" + str(val+2) +" created.")
|
||||||
Domoticz.Device(Name="Tuya SmartPlug (W)", Unit=val+4, TypeName="Usage").Create()
|
Domoticz.Device(Name="Tuya SmartPlug (V)", Unit=val+3, TypeName="Voltage").Create()
|
||||||
Domoticz.Log("Tuya SmartPlug Device (W) #" + str(val+4) +" created.")
|
Domoticz.Log("Tuya SmartPlug Device (V) #" + str(val+3) +" created.")
|
||||||
|
Domoticz.Device(Name="Tuya SmartPlug (W)", Unit=val+4, TypeName="Usage").Create()
|
||||||
|
Domoticz.Log("Tuya SmartPlug Device (W) #" + str(val+4) +" created.")
|
||||||
|
|
||||||
else: #group: selector switch
|
else: #group: selector switch
|
||||||
Options = {"LevelActions": "|",
|
Options = {"LevelActions": "|",
|
||||||
|
|||||||
Reference in New Issue
Block a user