I am trying to compute the rain fall total over the past 5 days.
Precip_Total gets updated from weatherUnderground and whenever it changes I want to recompute the 5 day total.
I have this rule as a test (zone3 is a motion sensor)
rule "Recent Temps"
when
Item zone3 changed to OPEN
then
if (Precip_Total.historicState(now().minusDays(5)) != null) {
logInfo("Motion", "5 Days Ok")
}
if (Precip_Total.historicState(now().minusDays(4)) != null) {
logInfo("Motion", "4 Days Ok")
}
if (Precip_Total.historicState(now().minusDays(3)) != null) {
logInfo("Motion", "3 Days Ok")
}
if (Precip_Total.historicState(now().minusDays(2)) != null) {
logInfo("Motion", "2 Days Ok")
}
if (Precip_Total.historicState(now().minusDays(1)) != null) {
logInfo("Motion", "1 Days Ok")
}
if (Precip_Total.historicState(now().minusHours(5)) != null) {
logInfo("Motion", "5 Hour Ok")
}
if (Precip_Total.historicState(now().minusHours(4)) != null) {
logInfo("Motion", "4 Hour Ok")
}
if (Precip_Total.historicState(now().minusHours(3)) != null) {
logInfo("Motion", "3 Hour Ok")
}
if (Precip_Total.historicState(now().minusHours(2)) != null) {
logInfo("Motion", "2 Hour Ok")
}
if (Precip_Total.historicState(now().minusHours(1)) != null) {
logInfo("Motion", "1 Hour Ok")
}
logInfo("Motion", "Anything good?")
end
The only output I get is “Anything good?”
Here is my mysql table for this item
+---------------------+-------+
| Time | Value |
+---------------------+-------+
| 2016-05-31 20:06:00 | 0 |
| 2016-06-01 20:06:00 | 0 |
| 2016-06-02 20:06:00 | 0 |
| 2016-06-03 20:06:00 | 0 |
| 2016-06-04 20:06:00 | 0 |
| 2016-06-05 20:06:00 | 2.64 |
| 2016-06-06 20:06:00 | 2.64 |
+---------------------+-------+
7 rows in set (0.00 sec)
The entry from 6/6 was added by openhab, I then shutdown and added the other manually
If I just do a sumSince(now.minusDays(5)) I get 0
Any suggestions?