Group management additions
In Indigo 6, we introduce the DeviceFactory pattern which allows your plugin to have a factory like method that creates any number of devices as part of the config process. If your plugin creates multiple devices, those devices are automatically linked together into a device group. However, the only way to manage groups was through the DeviceFactory config UI. You couldn't add/remove devices from the group outside of that dialog. We've now added some arguments to allow you to manage these groups outside of the DeviceFactory UI.
The create() method on the indigo.Device class can now have another argument passed: groupWithDevice. The default value is None (so it won't be grouped with anything), but you may pass an ID of any other device that your plugin manages to have it added to that device's group (or one will be created if the target device isn't already in a group).
Also, we've added another argument to the delete() method on the indigo.Device class: autoDeleteSiblingDevices. The default value is True, but if you pass False then just the device itself will be deleted, but other devices in the device group will be left alone.
I'm trying to add a "subdevice" when the user creates a device. I'm trying to do this here:
- Code: Select all
def closedDeviceConfigUi(self, valuesDict, userCancelled, typeId, devId):
if not userCancelled:
if typeId == "masterSensor":
newdev = indigo.device.create(indigo.kProtocol.Plugin, deviceTypeId="subSensor", groupWithDevice=devId)
newdev.model = "Custom Sensor"
newdev.subModel = "Sub Sensor"
newdev.replaceOnServer()
return
Both devices get created, but they're not grouped in any way. Not the Edit Device UI, and not in the deletion dialog.
Related question - it appears that the "sub" device type must be defined in Devices.xml. What if I don't want the user to be able to ever create devices of that type directly? Is it possible to have the definition there, but have it be hidden from the Device Type list in the New Device dialog for the plugin?