EZIO8SA get analog inputs

Posted on
Wed May 23, 2012 12:03 pm
alang_94526 offline
Posts: 250
Joined: Apr 13, 2009

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?

Posted on
Wed May 23, 2012 1:12 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

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)
Twitter | Facebook | LinkedIn

Posted on
Wed May 23, 2012 11:25 pm
alang_94526 offline
Posts: 250
Joined: Apr 13, 2009

Re: EZIO8SA get analog inputs

Nice :D That works well
Thanks

Posted on
Mon May 28, 2012 4:41 pm
alang_94526 offline
Posts: 250
Joined: Apr 13, 2009

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.

Posted on
Mon May 28, 2012 7:31 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

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

Posted on
Mon May 28, 2012 10:15 pm
alang_94526 offline
Posts: 250
Joined: Apr 13, 2009

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"

Posted on
Mon May 28, 2012 10:37 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

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

Posted on
Tue May 29, 2012 2:50 am
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

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").

Posted on
Tue May 29, 2012 8:03 am
alang_94526 offline
Posts: 250
Joined: Apr 13, 2009

Re: EZIO8SA get analog inputs

Thanks both of you. That fixed it.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 25 guests