How Much Has It Rained Recently?

I'm trying to throw a virtual switch (Raining) when there's been at least 1 inch of rain in the past week to stop irrigation. I'm using local variables and I have some questions with regards to the following rule.

Note each day after midnight I shift the daily totals back one day and restart summing up the current day's precipitation. In the other runs I simply add to the current day's precipitation. The really wacky stuff starts then, when trying to get the total for the week and act on the total.

  1. Is "decimal" the correct type?
  2. Is the math I'm using going to bog down the hub (note I'm only running this rule 4x/day)?
  3. Is there a way to simplify the math? Particularly when I derive the total. Due to limitations in how RM allows changes in variables, it seems like I have to gradually build up the total.
  4. Is there a simpler way to do all of this?
  5. Am I crazy doing this?


I’m just going to throw this out there. I used to have logic like that to control my irrigation system, but it was cumbersome at best. A few weeks ago, I shelled out $120 for a Rachio 3e and now all this intelligence just happens. And I can get a display on my dashboard showing me what it did, or is planning to do.

1 Like

Yes, I'm considering Rachio for my regular irrigation system, but this is for a hose-end Orbit Iris valve that separately provides water to an area not served by the regular system for various reasons, so I'm kind of stuck using the Hubitat for this.

Here's a wild idea. If you had Rachio for your main irrigation system, you could add a fake zone in it for the Orbit. Rachio won't know the difference, yet will let you configure that zone's parameters as if its water valve was actually controlled by it. Then use Hubitat to mirror the on/off state from that Rachio zone to your Orbit.

I use the Rachio Community app in Hubitat. I just checked Rule Machine and found I could in fact set up "If Rachio Zone x becomes open then turn on something else".

I haven't actually done this, but I'm thinking of adding a zone to my irrigation system to cover a new area and this was one of the ways I was thinking I might do it.

I decided to work on simplifying the math. Instead of taking the past 7 days precipitation, I decided to use exponential decay for the total of past time periods. All that means is that for the current total, I multiply the past total by a number less than one and add the current 6-hour total.

So the following was my set of actions prior to switching to exponential decay

IF (Time between 12:00 AM PDT and 1:00 AM PDT(F) [FALSE]) THEN
	Set day6 to day5
	Set day5 to day4
	Set day4 to day3
	Set day3 to day2
	Set day2 to day1
	Set day1 to day0
	Set day0 to WDG - Davis Weather Data precipitationLast6Hours
ELSE
	Set temporary to WDG - Davis Weather Data precipitationLast6Hours
	Set day0 to (day0 + temporary)
END-IF
Set total to (day0 + day1)
Set total to (total + day2)
Set total to (total + day3)
Set total to (total + day4)
Set total to (total + day5)
Set total to (total + day6)
IF (Time between 12:00 AM PDT and 1:00 AM PDT(F) [FALSE]) THEN
	Set temporary to (day0 * 3.0)
	Set total to (total + temporary)
ELSE-IF (Time between 6:00 AM PDT and 7:00 AM PDT(F) [FALSE]) THEN
	Set total to (total + day0)
ELSE-IF (Time between 12:00 PM PDT and 1:00 PM PDT(T) [TRUE]) THEN
	Set temporary to (day0 / 3.0)
	Set total to (total + temporary)
END-IF
IF (Variable total(0) >= 0.75(F) [FALSE]) THEN
	On: Irrigation Raining
ELSE
	Off: Irrigation Raining
END-IF

And now it is:

Set total to (total * 0.93)
Set temporary to WDG - Davis Weather Data precipitationLast6Hours
Set total to (total + temporary)
IF (Variable total(0) >= 0.30(F) [FALSE]) THEN
	On: Irrigation Raining
ELSE
	Off: Irrigation Raining
END-IF

I used 0.93 because that means by day 6, the contribution to the total is 16% of the original value, which seemed reasonable considering how fast things dry out here.

I wrote an app which does a similar thing except I use 5 days.

Day before yesterday (recorded)
Yesterday (recorded)
Today (recorded)
Tomorrow (Forecast from wu)
Day after tomorrow (Forecast from wu)

Then I used a ‘weighting’ multiplier (1-5) to get a figure for each day, then added them up.
If the sum is less than a configured level, turn on the switch (to water) else don’t :slight_smile:

I used weighting because I think it’s more important to consider the recorded rainfall (which has a higher weighting) of more value than the forecast data.

This has been working well enough for me for a couple of years .

Andy