I create 2 devices as follows:
Code: Select all
if dev_id not in Devices:
mySwitchUnit = Domoticz.Unit(Name=dev_id, DeviceID=dev_id, Unit=1, Type=244, Subtype=73, Switchtype=0, Options={}, Used=1, Description="")
mySwitchUnit.Create()
myTextUnit = Domoticz.Unit(Name=dev_id, DeviceID=dev_id, Unit=2, TypeName="General", Subtype=19, Options={}, Used=1, Description="")
myTextUnit.Create()
Code: Select all
def onDeviceRemoved(self, DeviceID, Unit):
Domoticz.Log("Device onDeviceRemoved for DeviceID: " +str(DeviceID)+" and Unit: "+str(Unit))
if Unit == 1:
Domoticz.Log("Device onDeviceRemoved unit 1 so delete 2")
Devices[DeviceID].Units[2].Delete()
else:
Domoticz.Log("Device onDeviceRemoved unit 1 so delete 1")
Devices[DeviceID].Units[1].Delete()