Compare thermostat temperatures as a condition

Posted on
Thu Aug 14, 2014 1:55 pm
stevemac00 offline
Posts: 79
Joined: Sep 02, 2013

Compare thermostat temperatures as a condition

In a trigger condition I need to compare thermostat temperatures (to know if there's a large differential). If there's a way to do this with the built-in conditions let me know but for now I'm trying to write a condition script. It's easy in python but I can't figure out what's wrong in applescript (I've ascertained there's no python supported in conditions).

For python example:
return (indigo.devices[404038560].temperatures[0] - indigo.devices[313210440].temperatures[0] > 3)

Also:
The "compile and test" does nothing when I simply write return false. How does one test a long conditional (I have many more test than the above). What should I be seeing in the log for test?

Thanks.

Posted on
Thu Aug 14, 2014 2:53 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Compare thermostat temperatures as a condition

indigo.server.log (unicode(indigo.devices[768183209].states["temperatureInput1"]))
will print the !!string!! of the current temperature of MY thermostat

temp1 = float(indigo.devices[768183209].states["temperatureInput1"]) # is the number
temp2 = float( indigo.devices[number of other device].states["name of other state"])
if temp1-temp2 > 3:
do something


see also the other post on how to get the names of all states of all devices
http://forums.indigodomo.com/viewtopic.php?f=107&t=12264


hope that helps.
Karl

Posted on
Thu Aug 14, 2014 3:00 pm
stevemac00 offline
Posts: 79
Joined: Sep 02, 2013

Re: Compare thermostat temperatures as a condition

So you can use python in a conditional script? I always got unknown token which led me to believe it was only Applescript aware.

Posted on
Thu Aug 14, 2014 3:03 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Compare thermostat temperatures as a condition

dont believe so, only applescript.
this was example to be used in the "action" part..

wrote my last applecript 6 month ago, will need to look up how to do it.. give me 5 minutes.

Posted on
Thu Aug 14, 2014 3:07 pm
jay (support) offline
Site Admin
User avatar
Posts: 18221
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Compare thermostat temperatures as a condition

If you want to use the built-in conditions, then just create variables and store the device temps in them (create a trigger that watches for any change and inserts the device state into the variable). Then you can use a variable to variable compare.

You can't use Python scripts in conditions - at least, not on the Condition tab. You can, however, write a Python script as the action and perform the comparison there. If you want to proceed, then you can execute an Action Group that contains the appropriate actions.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Aug 14, 2014 3:28 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Compare thermostat temperatures as a condition

Code: Select all
tell application "IndigoServer"
   set temp to temperatures of device named "ThermostatExerciseRoom" as number
   log (temp)
end tell


will get the temperature of my ExerciseRoom room thermostat into variable temp
then log writes it into the log file
while you are in an embedded script you don't need tell .. end tell

Posted on
Wed Aug 20, 2014 8:31 pm
stevemac00 offline
Posts: 79
Joined: Sep 02, 2013

Re: Compare thermostat temperatures as a condition

Good suggestions but my conditionals are long with many comparisons. in my case, it was easiest to put all the conditionals Ina pythons script which is triggered by any tstat temp change. I'm getting a lot of code in different places which will make it difficult to manage one day but I'm happy to be able to put my logic somewhere.

There so many scripts, some embedded and some attached in a variety of places - spaghetti code.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 15 guests