Sending a variable??

Posted on
Sun May 27, 2007 5:39 pm
anode offline
Posts: 697
Joined: May 27, 2007
Location: NC

Sending a variable??

I searched and found stuff semi-close.
But I need a 'hello world' proggy to jump start me.

What I am doing is using an industrial PLC in conjunction with x-10 and some homebrew hardware. I plan on sending over a variable to be inserted into Indigo.

Here's what I got:

tell application "IndigoServer"
set value of variable "Thermostat" to "87" as integer
end tell

And heres the error:
IndigoServer got an error: Can't set value of variable "Thermostat" to 87.

Wrench in the works right now (maybe?) is that I am trying this over the internet (I'm on da' road)

What am I missing?

Posted on
Mon May 28, 2007 12:49 am
Matt offline
Posts: 406
Joined: Aug 13, 2006
Location: Northern Idaho

(No subject)

Create the variable in Indigo first.

Click Windo, Select Variable List, and create a new variable called Thermostat using the New button

Posted on
Thu Jun 21, 2007 7:49 am
wikner offline
Posts: 181
Joined: Nov 02, 2003

Variables in Indigo

I may be wrong, but I think all variables in Indigo are stored (or at least they look, from appleScript like they are stored) as strings. I have used the following code:
Code: Select all
tell application "IndigoServer"
   if (exists variable "Temperature") then
      set (value of variable "Temperature") to "85"
   else
      make new variable with properties {name:"Temperature", value:"85"}
   end if
end tell

Posted on
Fri Jun 22, 2007 11:44 am
anode offline
Posts: 697
Joined: May 27, 2007
Location: NC

Re: Variables in Indigo

Thanks! I did try this and no luck. Even deleted the "temperature'" variable to see if it would create it. That failed too.

Maybe the prob is the server is on a different machine then the applescript?
And if that is the prob, then indigo is useless to me.


wikner wrote:
I may be wrong, but I think all variables in Indigo are stored (or at least they look, from appleScript like they are stored) as strings. I have used the following code:
Code: Select all
tell application "IndigoServer"
   if (exists variable "Temperature") then
      set (value of variable "Temperature") to "85"
   else
      make new variable with properties {name:"Temperature", value:"85"}
   end if
end tell

Posted on
Fri Jun 22, 2007 12:57 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Variables in Indigo

anode wrote:
Maybe the prob is the server is on a different machine then the applescript?

If the script is embedded in an Indigo action, and you are using the Indigo client on your remote machine, then you can run and have the Indigo Server on a remote machine execute the AppleScript automatically.

If you are just running the script from the Apple Sript Editor application and the Indigo Server is on another machine, then you need to use the "tell application on machine" notation to target the remote machine.

Regards,
Matt

Posted on
Thu Jul 19, 2007 4:44 pm
hammer32 offline
Posts: 66
Joined: May 13, 2006
Location: Copperas Cove, TX

(No subject)

I've got a similar problem trying to set the value of a variable within a script. I'm trying to use the DS10A type security sample script to set the value of a variable with the name of the devID to either alarm or normal:

Code: Select all
-- Sample attachment script that illustrates how to listen to
-- commands from security devices. Only the W800RF32
-- interface receives these commands.030515 (mmb)

using terms from application "Indigo"
   on receive security event of eventType with code devID
      if eventType is sec_SensorNormal_min then tell application "Indigo" to set value of variable devID to "normal"
      if eventType is sec_SensorNormal_max then tell application "Indigo" to set value of variable devID to "normal"
      if eventType is sec_SensorAlert_min then tell application "Indigo" to set value of variable devID to "alarm"
      if eventType is sec_SensorAlert_max then tell application "Indigo" to set value of variable devID to "alarm"
      
      log "(device ID " & devID & ")" using type "Security Sample"
      
      -- important: we must pass the event on to Indigo
      continue receive security event of eventType with code devID
   end receive security event
end using terms from


For this I'm using a security sensor with ID "109" and I've got a variable in Indigo called 109. When I run the script I get this in Indigo's log:

Code: Select all
17:24:44   Error   script error: Indigo got an error: Can't set value of variable 109 to "alarm".
17:24:47   Error   script error: Indigo got an error: Can't set value of variable 109 to "normal".

Posted on
Thu Jul 19, 2007 4:48 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

(No subject)

Are you using Indigo 2.0? If so, then change every instance of:

Code: Select all
application "Indigo"

to:

Code: Select all
application "IndigoServer"

Lastly, try casting the devID to a string like this:

Code: Select all
if eventType is sec_SensorNormal_min then tell application "IndigoServer" to set value of variable (devID as string) to "normal"

Matt

Posted on
Thu Jul 19, 2007 4:59 pm
hammer32 offline
Posts: 66
Joined: May 13, 2006
Location: Copperas Cove, TX

(No subject)

(devID as string)


Thanks! That did the trick (I'm still using 1.8 ).

-Sean

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests