Page 1 of 1

Seasonal adjustment for temperature & rain...

PostPosted: Tue Sep 10, 2019 10:17 pm
by jheddings
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!

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))

Re: Seasonal adjustment for temperature & rain...

PostPosted: Wed Sep 11, 2019 3:47 am
by DaveL17
Looks good to me. You don't necessarily need to cast temp_var and precip_var as floats since they're already floats in Indigo (reals)., but it doesn't cost a lot to make sure that your script will always work regardless of the incoming data type either.

Re: Seasonal adjustment for temperature & rain...

PostPosted: Fri Sep 13, 2019 9:08 pm
by jheddings
Thanks for the feedback (and excellent plugins)!

Re: Seasonal adjustment for temperature & rain...

PostPosted: Sat Sep 14, 2019 6:05 am
by DaveL17
My pleasure.