Python version of an applescript to get a device list

Posted on
Fri Dec 12, 2014 10:34 pm
achterberg offline
Posts: 93
Joined: Feb 22, 2005
Location: Texas

Python version of an applescript to get a device list

This applescript returns a device list:
Code: Select all
tell application "IndigoServer" to return name of every device where supports on off is true and display in remote ui is true


How can one get the same list in python (python code fragments combined from forum searches)?
Code: Select all
devList = [dev for dev in indigo.devices.iter() if 'onOffState' in dev.states and 'displayState' in dev.states]

returns more devices than the applescript version.

What would be the correct keys (if that is the correct term) to use?

Posted on
Sat Dec 13, 2014 11:48 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Python version of an applescript to get a device list

I think you're close - you need to check the remoteDisplay property (not state):

Code: Select all
devList = [dev for dev in indigo.devices.iter() if 'onOffState' in dev.states and dev.remoteDisplay]


It would be possible for Python to return more devices since AppleScript doesn't support custom plugin devices. So if a plugin defined a custom device type and it had an 'onOffState' state (all devices have the remoteDisplay property) then you'd get it in Python but not in AppleScript.

[MODERATOR NOTE] moved to the pythons scripting forum

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Dec 13, 2014 8:32 pm
achterberg offline
Posts: 93
Joined: Feb 22, 2005
Location: Texas

Re: Python version of an applescript to get a device list

Thank you, this returns the exact same list. Onward through the fog.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests