What I want to do is when the temperature is over 40, even if a zone is calling for heat it won't be able to unless there is another zone also calling for heat. Since these thermostats directly control the zone valves I figure the best way is to do this is to toggle the thermostats mode fromOff to Heat and back to Off as zones open/close. I have triggers that are working and updating variables that read current temp, set temp, compare those and modifies another variable to true if a zone wants heat.
To cut down on triggers I thought a script would be best to run any time there is a change in the value of the variable that indicates a call for heat. This script would read the variable and if two or more were true then the thermostat would switch to Heat mode. I would create an action group that would contain the nearly identical script for each thermostat and run the scripts when triggered by the change in any of the zones call for heat. Problem is I don't know any python. I cobbled together a few applescripts for Indigo a couple years ago, and copy/pasted my way thru a simple python on last year but this is beyond me even though it is pretty simple. I have this so far which I mashed together using different examples I found here on the forum. But it doesn't come any where close to working and I knew it wouldn't. But I thought it might be a good starting point for somebody to help me with. Any solutions?
- Code: Select all
# variables are true if zone is calling for heat, false if not
bed = indigo.variables(915602964)
living = indigo.variables(40815081)
base = indigo.variables(915602964)
# get current temp
currentTemp = float(indigo.devices[1007237836].states["temp"])
# is temp over 40
if currentTemp >= 40 and living.states['true'] and bed.states['true'] or base.states['true']:
indigo.devices.modeHeat(1643055815)
# temp is under 40
elif currentTemp < 40 and indigo.variables(40815081).states['true']:
indigo.devices.modeHeat(16430558150)
# the conditions above are not met
else:
indigo.devices.modeOff(16430558150)