Page 1 of 1

indigo.device.getGroupList

PostPosted: Sun Dec 10, 2017 6:06 pm
by jrickmd
I feel like I'm either confused about this device call or it is not working.

Here is my code:
Code: Select all
groupSecurity = indigo.device.getGroupList(1912245) # "Security Walk Devices"

# toggle a random device
indigo.server.log(str(len(groupSecurity)))
dev = randint(0,len(groupSecurity)-1)
indigo.server.log(str(dev))
devNumber = groupSecurity[dev]
indigo.server.log(str(devNumber))

and the log output:

Code: Select all
   Script                          1
   Script                          0
   Script                          1912245


There are 7 different items selected within this group so I should get the output of:

Code: Select all
7
a random number between 0 and 6
the actual ID of the item within the group, not the ID of the group itself


what am I missing?

Re: indigo.device.getGroupList

PostPosted: Mon Dec 11, 2017 9:25 am
by jay (support)
What kind of device is 1912245?

Re: indigo.device.getGroupList

PostPosted: Mon Dec 11, 2017 12:37 pm
by jrickmd
Device Group

Re: indigo.device.getGroupList

PostPosted: Mon Dec 11, 2017 2:26 pm
by jay (support)
Ah, that's the issue. You're confusing two different concepts. The Device Group device type in the Virtual Devices interface is a collection of unrelated devices in a single, standalone device (acting somewhat like a scene) so you control them all at the same time as if they were one device (and treating them as a meta state device). If you are trying to get all the devices in a Device Group, you need to get all the device id's from the device's props:

Code: Select all
groupSecurity = indigo.devices[1912245]  # "Security Walk Devices"
device_ids = groupSecurity.ownerProps["deviceList"]
# device_ids now has a list of device id's (each are strings so you'll need to coerce to ints to use)
for device_id_string in device_ids:
    dev = indigo.devices[int(device_id_string)]
    # do whatever with the dev here


The API call that you're using is meant to identify devices that are related somehow. Most often, these devices are "subordinate" or separate "personalities" that represent a different aspect of a physical (or logical) device. For instance, a multi-sensor device may support reporting motion, light, temperature, and humidity. Each of those "personalities" are represented as a separate device in Indigo (in this case, each are individual sensor devices), but they are in fact all part of the same physical device. Another example is an Airfoil instance: it contains multiple speaker devices, which are individual Indigo devices, but they are all in fact related to (and dependent upon) the main Airfoil instance device.

Re: indigo.device.getGroupList

PostPosted: Mon Dec 11, 2017 5:12 pm
by jrickmd
Ah ha! Knew I was confusing concepts. Thanks for the explanation and the code, Jay.