Seasonal adjustment for temperature & rain... Post a reply

This question is a means of identifying and preventing automated submissions.



:D :) :( :o :shock: :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:
BBCode is ON, [img] is ON, [flash] is OFF, [url] is ON, Smilies are ON

Post options


   

Expand view Topic review: Seasonal adjustment for temperature & rain...

Re: Seasonal adjustment for temperature & rain...

Post by DaveL17 » Sat Sep 14, 2019 6:05 am

My pleasure.

Re: Seasonal adjustment for temperature & rain...

Post by jheddings » Fri Sep 13, 2019 9:08 pm

Thanks for the feedback (and excellent plugins)!

Re: Seasonal adjustment for temperature & rain...

Post by DaveL17 » Wed Sep 11, 2019 3:47 am

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.

Seasonal adjustment for temperature & rain...

Post by jheddings » 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!

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

Top