Many of the values could be moved into config variables to avoid hard coding them. For now, I'm just trying it out to see if it makes much difference in the watering schedule. It's very basic, but any feedback or improvements are welcome!
- Code: Select all
coef_var = indigo.variables[1061581346] # seasonal multiplier for durations
temp_var = indigo.devices[1282681892].states["d01_temperatureHigh"] # forecast high temp
precip_var = indigo.devices[1282681892].states["d01_precipTotal"] # forecast precip
# normalize the current temperature from 40 to 120, 80 being nominal
high_temp = float(temp_var)
temp_coef = 2 * (high_temp - 40.0) / (120.0 - 40.0)
# adjust based on forecast high temp
if (temp_coef < 0): temp_coef = 0.0
# adjust for predicted rainfall (cutoff at 0.25 in of rain)
total_precip = float(precip_var)
precip_coef = (0.25 - total_precip) / (0.25)
# update the seasonal coefficient for the sprinklers...
coef = temp_coef * precip_coef
indigo.variable.updateValue(coef_var, str(coef))