Rule to detect dead sensor

Hey all, I have a few motion sensors some of which send battery levels.

All of these sensors motion and bat levels I have persisted in RRD4J.

Looking at those charts, I just noticed that one of my sensors is dead. It hasn’t reported motion for like a week (and it is in my living room so it HAS seen motion) and the battery level is flat lines (although not at 0). Clearly it isn’t reporting. I want to write a rule to detect this and report to me.

I’m thinking of setting a timer every time motion is reported for like 24 hours. If it gets motion, it resets the timer again for 24 hours, but if the timer runs out, I’d like it to look at the history of the battery level and if it hasn’t changed for some amount of time, - send a dead sensor warning. Wondering how to write an IF statement to check history of an item persisted in RRD4J?

Also, if anyone else has dome something similar, I’d love to hear how you did it!

Thanks,

I did see that rule, but it doesn’t actually look at the history at all, it just looks at the last value 1x per day. I’m looking for flat tines over a certain period of time. Hoping someone known how to check the data in the RRD4J DB.