Hi again,
I've been running the above excellent script all week and things are going very well. So yesterday I decided to optimize things a bit just to get the most out of Indigo and maybe have a bit less clutter in the log and traffic on the network. The Stelpro stats are receiving updates from the OutsideTemp variable every 5 minutes and as I see them all updated in the same script it occurred to me that:
1. The stats display at .5 C resolution so even when the OutsideTemp var changed by .1 and resulted in no change to the .5 resolution display on the stat, the messages were still being sent.
2. Once I get all 13 installed that's a lot of logging and network traffic lol
So, I figured I could enhance the trigger that controls the sending of the messages and get even more efficiency from Indigo, but since I only know Applescript I used that for my proof of concept. Here's the work in progress so far, and it's working :
A. Set up variable - outSideTemp - what's coming in from the weather station or other source like the web or someplace
B. Setup variable - outSideTempRounded
C. Set up a trigger on change of variable outSideTemp
D. In the Conditions tab, I placed the following Applescript code: (because I'm still a python newb)
- Code: Select all
tell application "IndigoServer"
if (the value of variable "outSideTemp" = the value of variable "outSideTempRounded") then
return false
#Incoming Temp already equals the previously rounded/sent temp so take no action
end if
set a to value of variable "outSideTemp"
set theint to (round a rounding down) # keeps everything before the decimal e.g 16.7 becomes 16
set thedec to (round ((a - theint) * 2)) / 2 #results in rounding everything after the decinal to the nearest .5
if (the value of variable "outSideTempRounded" = theint + thedec as text) then
#theint + thedec joins the number back together
#Incoming Temp was rounded to .5 and equals the previously rounded/sent temp so take no action
return false
end if
set the value of variable "OutsideTempRounded" to theint + thedec as text #set the rounded variable
return true
#Incoming Temp was rounded to .5C and does not equal the previously rounded/sent temp so process this for sending
end tell
#credit to a number of Applescript forums for parts of the code of course
E . Pasted and configured Matt's python script from above to be executed in the actions tab. I also created a Log item to write to the screen that the incoming temp of x.x was rounded to x.y and sent out to the stats.
So far so good and works great!
The script takes the incoming temp and if it's already equal to the variable outSideTempRounded, returns False to the trigger halting it. When it does change it usually just increments slightly by a couple tenths up or down in a 5 minute period so it is rounded in the script and if it still equals the rounded temp variable, it returns False again and prevents the redundant temp being sent. Finally if the temp changed more than .5C due to the rounding it returns True and the trigger's script (from the post above) fires. It also sets the outSideTempRounded variable to the newly rounded temp ready to send the stat by the trigger's Action script.
The result is now Indigo only sends out to the stat the messages when they are required instead of x messages per hour to N number of stats which can fill the log and the network.. There are 2 things I need to reconcile though, and looking for advice on how to handle that.
1. converting the condition script to python.
Edit- not required, A/S is expected in the conditions tab.
2. When the condition returns true the python script fires and processes rounding on the same OutsideTempRounded variable but this time in .1C resolution. The resolution is only a minor issue because the stat rounds what it receives too, but what I am hoping is that I can have the script not round at all and just package the previously rounded variable and send it out. Every time I touch that masterpiece of a script though I break it lol.
EDIT - So turns out this post was more "scripting therapy" (
or I am a python newb) than a support request
as upon re-reading it I figured out that it just needed more thought!
This was a simple adjustment to make just needed to look learn/experiment with the python script to see how it was working. In the condition script I left it as Applescript as it was expected to be A/S in that tab.
In the Python script all that was needed was to modify the If statement to take out the rounding function from the set valRaw portion of the statement so that:
- Code: Select all
valraw = int(round(valfloat * math.pow(10, valprecision)))
becomes
- Code: Select all
valraw = int(valfloat * math.pow(10, valprecision))
This sends the previously rounded temp (as a result of the condition script) in C to the stats without affecting the Fahrenheit function of the script where there is no rounding, due to the stat displaying F in 1 degree resolution.
The trigger enhancement works really well now. I've even created some logging code to see when the trigger fires and how it decides whether to send the outside temp message or not to that stats. There is also a Timer set up to handle the case where the outside temperature may not have changed more than .5 C in a 4 hour period. That's a stat limitation for displaying the same temp before reverting to inside set point display. A trigger resends the last temp again and restarts the 4 hour Timer countdown.
It's only been a couple weeks since getting the first 3 of these Stelpro z-Wave thermostats and already have them fully integrated with my Indigo system using only the general thermostat definition and a couple triggers and some great support!
Hope this helps anyone else setting up these stats with Indigo!
Jim