[SOLVED] Rule to show rainfall yesterday (persistence)

I have a raingauge set up to deliver mm rainfall to my OH2.2.

On that data, I use

rainmm.deltaSince(now.toDateMidnight, "rrd4j")

to give me rainfall since midnight, minusHours(1) to give me rainfall in the last hour etc.

Everything works :sweat_smile:

Now I want to also show yesterdays rainfall - meaning from midnight to midnight the day before this one. Is there a simple “deltaSince” command which would bring me that ? I am guessing that you could fiddle with the “now.” part - to set a different endpoint for the deltaSince ?

Anyone who has an example of this ?

rainmm.deltaSince(now.minusDays(1).toDateMidnight, "rrd4j") - rainmm.deltaSince(now.toDateMidnight, "rrd4j")

But wouldnt this give me the rain from 24h ago until last midnight (so if it is 12:20 now, I would get the rain from yesterday at 12:20 until midnight ?

The result I get indicate that…?

It shouldnt’.
You can also do:

rainmm.deltaSince(now.withTimeAtStartOfDay.minusDays(1), "rrd4j") - rainmm.deltaSince(now.withTimeAtStartOfDay, "rrd4j")

now.withTimeAtStartOfDay.minusDays(1) // Yesterday 00:00:00
now.withTimeAtStartOfDay // Today 00:00:00

I’m an idiot - can’t read my own data. Your first suggestion - as well as the last one works !!

Thanks - I actually didnt know that you could just insert the pointer after now. like you showed. With that it was easy to do i.e. “rain day before yesterday” as well…

Thanks !!

Where do one look up the valid syntax and possibilities for this ?

In VSCode that language server should pop-up the options available

Yes, they can be combined in lots of ways:

For example I want to set a timer to 18:36 today
So I have

The now expression goes likes this:

.withTimeAtStartOfDay - Today 00:00
.plusDays(1) - Jumps to tomorrow to avoid daylight changing problems so: Tomorrow 00:00
.minusHours(24 - Hours) - Today 18:00
.plusMinutes(mins) - Today 18:36

Et voila!

1 Like