Page 1 of 1

How do I check if a (virtual) device ist on or off?

PostPosted: Sat Jul 22, 2017 10:47 am
by Umtauscher
The headline sais it all.

Code: Select all
tell application "IndigoServer"
   if on state of "Loudspeaker2" is true then ...

I get the error "can't get On state of Loudspeaker2"
What am I doing wrong here?
TIA

Re: How do I check if a (virtual) device ist on or off?

PostPosted: Sat Jul 22, 2017 1:54 pm
by FlyingDiver
Use Python, not AppleScript. :lol:

Re: How do I check if a (virtual) device ist on or off?

PostPosted: Sun Jul 23, 2017 4:03 pm
by jay (support)
I agree with FlyingDiver - do it in Python:

Code: Select all
dev = indigo.devices[IDOFDEVICEHERE]
if dev.onState:
    # Do whatever here


If for some reason you can't, however, you've got the AppleScript syntax wrong:

Code: Select all
tell application "IndigoServer"
   if on state of device "Loudspeaker2" is true then ...


you have to specify that it's a device you're looking at (device "Loudspeaker2").

Re: How do I check if a (virtual) device ist on or off?

PostPosted: Mon Jul 24, 2017 12:21 am
by Umtauscher
Thanks Jay