Easydaq input on state in Applescript

Posted on
Tue Oct 16, 2012 9:49 pm
bob offline
User avatar
Posts: 500
Joined: Jun 14, 2006

Easydaq input on state in Applescript

I have an easydaq relay board, in devices it is labeled "relays4", the board's input 5 is labeled "rgate". Is this applescript snippet correct?

Code: Select all
if on state of device "rgate" then


I want to do an action if the input is true.

thanks,

bob

Posted on
Tue Oct 16, 2012 10:22 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Easydaq input on state in Applescript

No, there is no AppleScript support for accessing plugin device states. You can access them from python. Or, if you are just using it as a conditional, then the Conditional panel UI will let you select that input state.

Image

Posted on
Wed Oct 17, 2012 7:16 am
bob offline
User avatar
Posts: 500
Joined: Jun 14, 2006

Re: Easydaq input on state in Applescript

Matt,

Ok........ then can you give me the equivalent in Python for the line of Applescript I posted?

thanks,

bob

Posted on
Wed Oct 17, 2012 7:22 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Easydaq input on state in Applescript

Code: Select all
dev = indigo.devices["your easyDAQ device name or ID"]
if dev.states["channel05"]:
   indigo.server.log("relay rgate is ON")
else:
   indigo.server.log("relay rgate is OFF")

Image

Posted on
Mon Nov 19, 2012 5:06 pm
durosity offline
User avatar
Posts: 4320
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: Easydaq input on state in Applescript

In an attempt to group 6 different triggers into one I’ve been trying to use the above example like this:

Code: Select all
dev = indigo.devices["Lounge Master Switch"]
if dev.states["Group off"]:
   indigo.actionGroup.execute(114513799)
else dev.states["Mood 1"]:
   indigo.actionGroup.execute(141875067)


However it keeps stating to me ‘key Group off not defined in dictionary’. In the devices “States” window it lists “command = Group off” or Mood 1-5 depending on the button last pressed.

Also on a side note i can’t seem to find any way of having an Else If command for Mood 1-5, Eg if Mood 1 do this, Else If mood 2 do that, etc.. can this be done or do i have to have multiple little scripts?

Computer says no.

Posted on
Mon Nov 19, 2012 5:54 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Easydaq input on state in Applescript

The state name is "command" and the value is "Group off", so you'll want to get the value and test it something like this:

Code: Select all
dev = indigo.devices["Lounge Master Switch"]
if dev.states["command"] == "Group off":
   indigo.actionGroup.execute(114513799)
elif dev.states["command"] == "Mood 1":
   indigo.actionGroup.execute(141875067)


I have no idea what kind of device you're talking about though so that's just a guess. You'll probably want to move this discussion to the Extending Indigo with Plugins and Python forum since we're talking python scripting here.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Nov 20, 2012 3:10 am
durosity offline
User avatar
Posts: 4320
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: Easydaq input on state in Applescript

That worked perfectly.. i just didn’t get how it handled it past dev.states.

Indeed anything else like this should go in with python.. it was just because it was already in this thread! Thanks once again!

Computer says no.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 7 guests

cron