Help - Plugin State to Variable

Posted on
Sat Feb 09, 2013 8:15 am
kcossabo offline
Posts: 38
Joined: Dec 02, 2007

Help - Plugin State to Variable

I am interested in using the NOAA plugin to trigger an event. I have the plugin setup, and it has data. I can create an event to trigger based on the temperature changing below 32, BUT, what I want is then to have the temperature in a variable. So I can do something like

say "The temperature is cold outside, it is " & ((value of variable "Temp") as string) & " , burrrr"

How, or can I, get the device state into an apple script?

Posted on
Sat Feb 09, 2013 10:52 am
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Help - Plugin State to Variable

Use the "Variable Actions->Insert Device State into Variable" action in Indigo 6. In Indigo 5 it's in the Action Collection plugin.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Feb 09, 2013 12:34 pm
kcossabo offline
Posts: 38
Joined: Dec 02, 2007

Re: Help - Plugin State to Variable

You ROCK!! thank you.....

With the insert states.....

say "The current weather condition is " & ((value of variable "NOAACurrentCondition") as string) & ", with a temperature of " & ((value of variable "NOAATempF") as string) & ", with the wind " & ((value of variable "NOAAWind") as string)

works like a charm.....

May try Version 6, after many years of adding to this great program, might be time to rethink all that I am doing with it to make sure I am optimum...

Have a great day.

Posted on
Fri Feb 15, 2013 9:25 am
bmcgowan13 offline
Posts: 67
Joined: Jan 13, 2013

Re: Help - Plugin State to Variable

Jay-
I've been struggling to create an AppleScript to set a variable CurrentTemp to the NOAA plugin TemperatureF.

I came across this post and used the Plugin to create the trigger in about 10 seconds--great plugin and it saves a bunch of time.

I'm trying to understand how it works... So is this what the Action Collection Applescript plugin executes?

acId = "com.perceptiveautomation.indigoplugin.ActionCollection"
actionPlugin = indigo.server.getPlugin(acId)
if actionPlugin.isEnabled():
actionPlugin.executeAction("insertState", deviceId=135305663, props={'devState':'playStatus','variable':1229620185})

Is this the correct Applescript to set my variable CurrentTemp to the NOAA temp?

Posted on
Fri Feb 15, 2013 10:06 am
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Help - Plugin State to Variable

AppleScript has no access to plugin device states. Plugins are written in Python, not AppleScript.

The script you posted above is a Python script that will call the "Insert Device State into Variable" action to insert what appears to be the "playStatus" state of an iTunes device into a variable (though it's syntactically incorrect - the last line should be indented). It is one technique you could use in a Python script if you wanted to do it in a script rather than use the action UI (you would of course want to use the correct state for the NOAA plugin as shown in the states list for it).

That is not what the actual action code does, however, since the script is calling the the action to do the work. A shortened version of what the plugin does (with no type or error checking, etc):

Code: Select all
stateValue = indigo.devices[DEVICEID].states[DEVICESTATE]  #get the state value from the device
indigo.variable.updateValue(VARID,value=stateValue)  # set the variable value to the state value


I recommend calling the action as your script does though since the action makes sure that the variable type is correct and will do a lot of error checking (like make sure that the device id, state, and variable id's are correct and available).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 34 guests