Seasonal adjustment for temperature & rain...

Posted on
Tue Sep 10, 2019 10:17 pm
jheddings offline
User avatar
Posts: 111
Joined: Dec 01, 2013
Location: Denver, CO

Seasonal adjustment for temperature & rain...

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

Posted on
Wed Sep 11, 2019 3:47 am
DaveL17 offline
User avatar
Posts: 4915
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Seasonal adjustment for temperature & rain...

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.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Fri Sep 13, 2019 9:08 pm
jheddings offline
User avatar
Posts: 111
Joined: Dec 01, 2013
Location: Denver, CO

Re: Seasonal adjustment for temperature & rain...

Thanks for the feedback (and excellent plugins)!

Posted on
Sat Sep 14, 2019 6:05 am
DaveL17 offline
User avatar
Posts: 4915
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Seasonal adjustment for temperature & rain...

My pleasure.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest