indigo.device.getGroupList

Posted on
Sun Dec 10, 2017 6:06 pm
jrickmd offline
Posts: 109
Joined: Jun 01, 2003
Location: Texas

indigo.device.getGroupList

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?

Rick

Posted on
Mon Dec 11, 2017 9:25 am
jay (support) offline
Site Admin
User avatar
Posts: 14659
Joined: Mar 19, 2008
Location: Austin, Texas

Re: indigo.device.getGroupList

What kind of device is 1912245?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Dec 11, 2017 12:37 pm
jrickmd offline
Posts: 109
Joined: Jun 01, 2003
Location: Texas

Re: indigo.device.getGroupList

Device Group

Rick

Posted on
Mon Dec 11, 2017 2:26 pm
jay (support) offline
Site Admin
User avatar
Posts: 14659
Joined: Mar 19, 2008
Location: Austin, Texas

Re: indigo.device.getGroupList

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.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Dec 11, 2017 5:12 pm
jrickmd offline
Posts: 109
Joined: Jun 01, 2003
Location: Texas

Re: indigo.device.getGroupList

Ah ha! Knew I was confusing concepts. Thanks for the explanation and the code, Jay.

Rick

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest