Help Scripting Thermostats

Posted on
Mon Oct 14, 2019 1:12 pm
digtrail offline
Posts: 28
Joined: Jun 02, 2016

Help Scripting Thermostats

Trying to get a little handle on some scripting but having a hard time understanding python. My copy/paste/modify skills with other languages could get me by for some things but not now.

What I am trying to do is script my thermostats to only enter Mode Heat when more than one tstat calls for heat. I have zoned baseboard heat using an older model mod/con boiler. In these cool but not cold times of the year the boiler can not modulate down enough and will short fire when only one zone is calling for heat, I want to prevent this. I have 3 zones and would like to have any 1 zone wait for another zone before changing to Mode Heat. I have created variables and tried using triggers but there were so many possibilities between variables that I got lost in creating separate triggers for each.

Here is what I would like. Basement tstat current Mode is Off, temp drops below set point of 68, a trigger fires modifying variable BasementWait to true, both other tstats are Mode Off as well and set points are met. Then Living tstat temp drops below set point firing trigger that modifies variable LivingWait to true. Now that there are two tstats waiting for heat they will both receive commands to Mode Heat On which will open the zone valves and cause boiler to fire. If one zones set point would be reached there would be a delay changing the variable Wait to false, and when that variable is changed if the 3rd zones Wait variable is not also already Wait the script would change the only zone calling for heat to Mode Off. When there are again two zones waiting for heat script would again fire changing appropriate zone to Mode Heat. Hope this makes sense. Here is a little script that I tried cobbling together to control one zone from some examples I found but it doesn't work at all. I get this, 'VariableList' object is not callable at line 1. And I'd bet many more errors if it got past line 1, but at least I tried right. Can anybody help me with this? Thanks

bed = indigo.variables(915602964)
living = indigo.variables(40815081)
base = indigo.variables(915602964)

# get current temp

currentTemp = float(indigo.devices[1007237836].states["temp"])

# temp over 40

if currentTemp >= 40 and living.states['true'] and bed.states['true'] or base.states['true']:
indigo.devices.modeHeat(1643055815)
elif currentTemp < 40 and indigo.variables(40815081).states['true']:
indigo.devices.modeHeat(16430558150)
else:
indigo.devices.modeOff(16430558150)

Posted on
Mon Oct 14, 2019 1:15 pm
digtrail offline
Posts: 28
Joined: Jun 02, 2016

Re: Help Scripting Thermostats

Realized I posted something very similar to this a year ago, but never received notifications that there were replies. I hardly ever log in, just browse the forums normally. Sorry for the repost, I will try out suggestions from last year.

Posted on
Mon Oct 14, 2019 1:40 pm
digtrail offline
Posts: 28
Joined: Jun 02, 2016

Re: Help Scripting Thermostats

Ok. I followed last years suggestions I think. I now have this code,

bed = indigo.variables(915602964)
living = indigo.variables(40815081)
base = indigo.variables(915602964)
bedVal = bed.getValue(float)
livingVal = living.getValue(float)
baseVal = base.getValue(float)

# get current temp

currentTemp = float(indigo.devices[1007237836].states["temp"])

# temp over 40

if currentTemp >= 40 and livingVal['true'] and bedVal['true'] or baseVal['true']:
indigo.thermostat.setHvacMode(1643055815, indigo.kHvacMode.Heat)
elif currentTemp < 40 and livingVal['true']:
indigo.thermostat.setHvacMode(1643055815, indigo.kHvacMode.Heat)
else:
indigo.thermostat.setHvacMode(1643055815, indigo.kHvacMode.Off)

but still get the following error:
Script Error embedded script: 'VariableList' object is not callable
Script Error Exception Traceback (most recent call shown last):

embedded script, line 1, at top level
TypeError: 'VariableList' object is not callable

Any help is GREATLY appreciated. Thanks

Posted on
Mon Oct 14, 2019 3:17 pm
RogueProeliator offline
User avatar
Posts: 2501
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: Help Scripting Thermostats

Script Error embedded script: 'VariableList' object is not callable

This particular error is occurring when you are trying to get the variables -- you are using parentheses but you should be using brackets:
Code: Select all
bed = indigo.variables[915602964]
living = indigo.variables[40815081]
base = indigo.variables[915602964]

Adam

Posted on
Wed Oct 16, 2019 10:18 am
digtrail offline
Posts: 28
Joined: Jun 02, 2016

Re: Help Scripting Thermostats

Thanks for the help. I got this script to work for one Tstat. Now I need to work on expanding it to all 3 at once so it will cascade with them as they call for heat and then are satisfied. It will be more work, and I am sure I will be back asking for more help.

Code: Select all
bed = indigo.variables[915602964]
living = indigo.variables[40815081]
base = indigo.variables[915602964]
temp = indigo.variables[1072347650]
bedVal = bed.getValue(bool)
livingVal = living.getValue(bool)
baseVal = base.getValue(bool)
tempVal = temp.getValue(float)

# temp over 40

if tempVal >= 40 and living.value=="true" and bed.value=="true" or base.value=="true":
   indigo.thermostat.setHvacMode(1643055815, indigo.kHvacMode.Heat)
elif tempVal < 40 and living.value=="true":
   indigo.thermostat.setHvacMode(1643055815, indigo.kHvacMode.Heat)
else:
   indigo.thermostat.setHvacMode(1643055815, indigo.kHvacMode.Off)

Posted on
Wed Oct 16, 2019 10:41 am
digtrail offline
Posts: 28
Joined: Jun 02, 2016

Re: Help Scripting Thermostats - SUCCESS!

Success!
I was able to get all three Tstats to work using the script above. I created an action group with three separate actions. Each action executes the embedded script, with the script being changed only for which Tstat it controls by changing the device ID. It work instantly once the trigger calling the action group fires. If anybody else wants to use this please do. I currently have a total of 22 triggers to do all of this. Most of them are set to change variables such as what the room temp is, what the set point is, and what I call wait which is the variable that indicates if there is a need for heat in that zone. These triggers could most likely be cleaned up with code, but hey they work as is now with the scripting in the action group. Thanks to those that helped last year and this year with getting me to the right place with the code.

Posted on
Wed Oct 16, 2019 11:19 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Help Scripting Thermostats

Excellent, glad you got it sorted.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Oct 16, 2019 10:01 pm
digtrail offline
Posts: 28
Joined: Jun 02, 2016

Re: Help Scripting Thermostats -Spoke to soon

Welp, Said I'd be back. I spoke to soon on the success route. Code worked when using run command from the embed section of the action group and during rudimentary testing. But real life situations and further testing brought a weakness in the code to the forefront.

I couldn't figure out why it wasn't working the way I intended but now the way the code was written makes sense to me, however I did not see it at first.

I wanted it to return if varD is >= and varA is "true" and varB "true" or varA "true" and varC "true" then, followed by the else if, followed by the else. But the way its written its running if varA is "true" and varB is "true" OR varC is "true" and that varC is getting in the way. So there was a simple change. Add the missing var to the OR part of the statement. After some more testing it seems to be working as intended.

If I was better at writing or coding this could be a good tutorial since there is a lot of logic going on in the background to populate all of the necessary variables and I think it would be of interest to the Indigo community. I had to replicate the normal logic of the Tstats in Indigo. They normally decide that there was a temp change or a set point change and now those two don't match so lets call for heat or stop the call for heat. I don't want that to happen so I am using Indigo to control the Tstats and tell them when I want them to actually heat. Here is the what is really a simple code snippet (for most but not me) that seems to work as intended, for if it might be of use to others who are copy/pasters like me. Like I said though most of the logic is in the triggers that populate variables.

Code: Select all
bed = indigo.variables[915602964]
living = indigo.variables[40815081]
base = indigo.variables[1460408437]
temp = indigo.variables[1072347650]
bedVal = bed.getValue(bool)
livingVal = living.getValue(bool)
baseVal = base.getValue(bool)
tempVal = temp.getValue(float)

# temp over 40

if tempVal >= 40 and living.value=="true" and bed.value=="true" or base.value=="true" and living.value=="true":
   indigo.thermostat.setHvacMode(1643055815, indigo.kHvacMode.Heat)
elif tempVal < 40 and living.value=="true":
   indigo.thermostat.setHvacMode(1643055815, indigo.kHvacMode.Heat)
else:
   indigo.thermostat.setHvacMode(1643055815, indigo.kHvacMode.Off)

Posted on
Thu May 26, 2022 11:47 am
geowar offline
Posts: 7
Joined: Apr 27, 2022

Re: Help Scripting Thermostats

FYI: Here's how I'd write it
Note: all ID's have been moved to the top so if they change they can be edited in one place
Otherwise it's possible to miss them when they're embedded elsewhere in the sources.
Code: Select all
//ID's
bedID = 915602964
livingID = 40815081
baseID = 1460408437
tempID = 1072347650
hvacID = 1643055815

//variables
bed = indigo.variables[bedID]
living = indigo.variables[livingID]
base = indigo.variables[baseID]
temp = indigo.variables[tempID]

//values
bedVal = bed.getValue(bool)
livingVal = living.getValue(bool)
baseVal = base.getValue(bool)
tempVal = temp.getValue(float)

if tempVal >= 40 and living.value=="true" and bed.value=="true" or base.value=="true":
   indigo.thermostat.setHvacMode(hvacID, indigo.kHvacMode.Heat)    #Did you mean to cool here?
elif tempVal < 40 and living.value=="true":
   indigo.thermostat.setHvacMode(hvacID, indigo.kHvacMode.Heat)
else:
   indigo.thermostat.setHvacMode(hvacID, indigo.kHvacMode.Off)

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 13 guests

cron