Skip to content

Instantly share code, notes, and snippets.

@jheddings
Last active December 19, 2020 08:01
Show Gist options
  • Save jheddings/68609aaf2a17aef6dcf4f874f69e0410 to your computer and use it in GitHub Desktop.
Save jheddings/68609aaf2a17aef6dcf4f874f69e0410 to your computer and use it in GitHub Desktop.
Fast method for balancing temperature in Indigo using multiple sensors.
# turn on the fan if temperature in the house is uneven
try:
import indigo
except ImportError:
print 'ERROR - this script must be run from within Indigo'
raise ImportError("module 'indigo' not found")
logger_name = 'HVAC Balancer'
################################################################################
## custom Indigo objects
# "Downstairs Thermostat"
thermostat = indigo.devices[1532090072]
# device ID's for temperature sensors
sensors = (695911461, 1215250024)
var_max_temp = indigo.variables.get('cfg_hvac_balance_max', None)
var_min_temp = indigo.variables.get('cfg_hvac_balance_min', None)
################################################################################
## utility methods
# display an informational message
def log(msg, *args):
indigo.server.log(msg.format(*args), type=logger_name)
# display an error message
def error(msg, *args):
indigo.server.log(msg.format(*args), type=logger_name, isError=True)
################################################################################
## MAIN ENTRY
temps = [ int(indigo.devices[dev_id].displayStateValRaw) for dev_id in sensors ]
min_temp = min(temps)
max_temp = max(temps)
current_temp = int(thermostat.displayStateValRaw)
# when the HVAC is in 'heat' mode, we need to ensure there are no 'cold' spots
if thermostat.hvacMode == indigo.kHvacMode.Heat:
if var_max_temp is not None and max_temp > int(var_max_temp.value):
log('Temperature is too hot: {}', max_temp)
indigo.thermostat.setFanMode(thermostat, value=indigo.kFanMode.Auto)
elif min_temp < current_temp:
log('Temperature is unbalanced; starting fan: {}', min_temp)
indigo.thermostat.setFanMode(thermostat, value=indigo.kFanMode.AlwaysOn)
else:
log('Temperature is stable: {} - {}', min_temp, max_temp)
indigo.thermostat.setFanMode(thermostat, value=indigo.kFanMode.Auto)
# when the HVAC is in 'cool' mode, we need to ensure there are no 'hot' spots
elif thermostat.hvacMode == indigo.kHvacMode.Cool:
if var_min_temp is not None and min_temp < int(var_min_temp.value):
log('Temperature is too cold: {}', min_temp)
indigo.thermostat.setFanMode(thermostat, value=indigo.kFanMode.Auto)
elif max_temp > current_temp:
log('Temperature is unbalanced; starting fan: {}', max_temp)
indigo.thermostat.setFanMode(thermostat, value=indigo.kFanMode.AlwaysOn)
else:
log('Temperature is stable: {} - {}', min_temp, max_temp)
indigo.thermostat.setFanMode(thermostat, value=indigo.kFanMode.Auto)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment