Seasonal adjustment for temperature & rain...
Posted: Tue Sep 10, 2019 10:17 pm
I finally got around to an automated seasonal adjustment for my sprinkler watering times. Thanks to "Multiply durations by Variable value" and the Daily Forecast device from Fantastic Weather, I was able to craft a little script that executes whenever the observation time changes. My approach considers high temperature and expected rainfall to do some normalizing and come up with a multiplier. The actual schedule runs conditionally if wind and temperature are reasonable.
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!
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))