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:
@@ -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,6 +354,8 @@ 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.")
|
||||||
|
## After the last DPS add the global devices
|
||||||
|
if(val == max_dps):
|
||||||
Domoticz.Device(Name="Tuya SmartPlug (A)" , Unit=val+1, TypeName="Current (Single)").Create()
|
Domoticz.Device(Name="Tuya SmartPlug (A)" , Unit=val+1, TypeName="Current (Single)").Create()
|
||||||
Domoticz.Log("Tuya SmartPlug Device (A) #" + str(val+1) +" created.")
|
Domoticz.Log("Tuya SmartPlug Device (A) #" + str(val+1) +" created.")
|
||||||
Domoticz.Device(Name="Tuya SmartPlug (kWh)", Unit=val+2, TypeName="kWh").Create()
|
Domoticz.Device(Name="Tuya SmartPlug (kWh)", Unit=val+2, TypeName="kWh").Create()
|
||||||
|
|||||||
Reference in New Issue
Block a user