View unanswered posts | View active topics It is currently Sat May 18, 2013 4:18 pm



Reply to topic  [ 9 posts ] 
 EZIO8SA get analog inputs 
Author Message

Joined: Apr 13, 2009
Posts: 151
Post EZIO8SA get analog inputs
Here's an easy one for all you Applescript experts out there.
I am using an EZIO8SA with 2 analog inputs connected to thermistors to manage my pool solar heating.
I'm not experienced in Applescript and was trying to figure out how to get the value of the 2 analog inputs into 2 variables.
I was hacking around last night and could not get the right syntax. Essentially, I'm trying assign the value of analog input 1 to variable PoolTemp and the value of analog input 2 to SolarTemp.
The closest I got was
set value of {PoolTemp, SolarTemp} to get analog inputs of device "Pool Control"
It will return 2 numbers {1234, 5678} but won't assign them to the the 2 variables (because I don't know what I'm doing ;-) )
Any ideas?


Wed May 23, 2012 12:03 pm
Profile
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6642
Location: Austin, Texas
Post Re: EZIO8SA get analog inputs
You don't need a script - just use the Action Collection plugin's "Insert Device State into Variable" action. Select the EZIO, click on the "Edit Action Settings..." and select "analogInput1" from the "Insert state" popup and select the variable from the "Into variable" popup.

_________________
Jay (Indigo Support)
Image


Wed May 23, 2012 1:12 pm
Profile WWW

Joined: Apr 13, 2009
Posts: 151
Post Re: EZIO8SA get analog inputs
Nice :D That works well
Thanks


Wed May 23, 2012 11:25 pm
Profile

Joined: Apr 13, 2009
Posts: 151
Post Re: EZIO8SA get analog inputs
Still having newby Applescript issues.
I am trying to do a simple if then else where the if is looking for some conditions to be true such as the solar panel temperature is above the target pool temperature.
I cannot get this to work at all and I ended up hacking it back to the following very simple if statement:


set value of variable "TestSolarTemp" to 108
-- turn on solar if solar temp gets 8 degrees above target temp and pool temp not there yet. Else turn it off
-- if ((value of variable "SolarStatus" = "false") and (value of variable "SolarTemp" > ((value of variable "PoolTempTarget") + 8)) and (value of variable "PoolMode" = "Pool3") and (value of variable "PoolTemp" < ((value of variable "PoolTempTarget") - 2))) then
if (value of variable "TestSolarTemp" > 93) then
set value of variable "SolarStatus" to "true"

As you can see I commented out the slightly more complex if statement and put in a stupid simple one. I set TestSolarTemp to 108.
The if statement is if that value is greater than 93, then set the variable SolarStatus to true.

What I find is that even though the Variables List window shows TestSolarTemp being set to 109.
The value according the the if statement is 1.
i.e. if I successively replace 93 with a value until it is considered true.

Any ideas? I am assuming there is some sort of initialization or declaration of variables required that I'm missing.


Mon May 28, 2012 4:41 pm
Profile
Site Admin
User avatar

Joined: Jan 27, 2003
Posts: 11679
Location: Texas
Post Re: EZIO8SA get analog inputs
Indigo variable values in AppleScript are always returned as strings. So you need to cast them to a number before you try to compare then with > or < to another number. So instead of just this:

Code: Select all
value of variable "SolarTemp"

use this:

Code: Select all
value of variable "SolarTemp" as number

_________________
Image


Mon May 28, 2012 7:31 pm
Profile WWW

Joined: Apr 13, 2009
Posts: 151
Post Re: EZIO8SA get analog inputs
Thanks Matt, but that didn't help. I did the following and it still takes the else branch.


set value of variable "TestSolarTemp" to 108 as number

-- turn on solar if solar temp gets 8 degrees above target temp and pool temp not there yet. Else turn it off
-- if ((value of variable "SolarStatus" = "false") and (value of variable "SolarTemp" > ((value of variable "PoolTempTarget") + 8)) and (value of variable "PoolMode" = "Pool3") and (value of variable "PoolTemp" < ((value of variable "PoolTempTarget") - 2))) then
if (value of variable "TestSolarTemp" > 93) then
set value of variable "SolarStatus" to "true"


Mon May 28, 2012 10:15 pm
Profile
Site Admin
User avatar

Joined: Jan 27, 2003
Posts: 11679
Location: Texas
Post Re: EZIO8SA get analog inputs
I wasn't referring to the "set" part, but rather every part where you were using a variable value in a numerical < or > compare.

_________________
Image


Mon May 28, 2012 10:37 pm
Profile WWW

Joined: Aug 09, 2010
Posts: 761
Location: CA
Post Re: EZIO8SA get analog inputs
alang_94526 wrote:
Code: Select all
set value of variable "TestSolarTemp" to 108 as number

-- turn on solar if solar temp gets 8 degrees above target temp and pool temp not there yet. Else turn it off
-- if ((value of variable "SolarStatus" = "false") and (value of variable "SolarTemp" > ((value of variable "PoolTempTarget") + 8)) and (value of variable "PoolMode" = "Pool3") and (value of variable "PoolTemp" < ((value of variable "PoolTempTarget") - 2))) then
if (value of variable "TestSolarTemp" > 93) then
   set value of variable "SolarStatus" to "true"

Try this...
Code: Select all
set value of variable "TestSolarTemp" to 108

-- turn on solar if solar temp gets 8 degrees above target temp and pool temp not there yet. Else turn it off
if value of variable "SolarStatus" = "false" and (value of variable "SolarTemp") as number > (value of variable "PoolTempTarget") as number + 8 and value of variable "PoolMode" = "Pool3" and (value of variable "PoolTemp") as number < (value of variable "PoolTempTarget") as number - 2 then
   set value of variable "SolarStatus" to "true"
end if

Note in the code above that anytime an Indigo variable has any kind of numerical operation or comparison done to it, the variable must be converted ("cast") to a number since, as Matt said, all Indigo variables are text ("strings").


Tue May 29, 2012 2:50 am
Profile WWW

Joined: Apr 13, 2009
Posts: 151
Post Re: EZIO8SA get analog inputs
Thanks both of you. That fixed it.


Tue May 29, 2012 8:03 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.