If I want to track the duration of certain states (eg: how long a contact is opened, how long is a switch in each state?, etc) and under specific scopes (today, this week, yesterday, last week, etc), is RM the way to go? I'm guessing I want to store the results in global variables so it can be referenced in other rules or displayed in dashboard tiles. I don't need stats for all my devices but only specific ones.
One approach is to run a rule whenever a device state changes (eg: contact opened) and use a lot of rules involving variable math on date/time in epoch seconds. But this seems overly complicated for a rule (or actually, a few rules) and perhaps there is an app that does it better.
And perhaps it would be easier if I can just query the eventlog of each device and get the state history that way. So either have the query run at intervals to update stats or have a device state change to trigger the query. But I guess I need to learn Java to do this?
My specific use case is for a humidifier with on a contact sensor on a output vent flap so that when it's running, the contact is open and when idle the contact is closed. I don't want the humidifier to burn out from running for too long and if it runs for more than x hours per day, I cut power to it using a smartplug.