I need a rule that counts the number of vibration active events within a 5 minute period.
I'm not sure how to do this in Rule Machine. Any help is greatly appreciated.
Can you provide more details on what you’re trying to do?
Do you need to count the vibration events starting from an initial one and for the next five minutes, then the count resets to zero? Or do you need a sliding window type counter, e.g. a variable should at all times reflect how many vibration events occurred in the last five minutes ? Or would it be enough to wait until the vibration sensor goes inactive for X time with a five minute timeout?
Best if you tell us more about the use case, what automation you’re looking to drive with this approach.
I'm using the vibration sensor in a rule that will notify me when the dryer has stopped. The issue is that while the dryer is running, the vibration sensor alternates between active and inactive every few seconds or so. If I can count the number of activations within a period of time, such as 5 minutes, I can determine if the dryer has been running continuously. When the sensor remains inactive for a period of time, such as one minute, then I know the dryer has completed its cycle.
I use RM for just that purpose. I chose to implement two rules, but you could do it in one if you wanted to:
- One rule triggers on vibration active and stays for 30 seconds (the "stays" is there to avoid false positives, like dropping an object on the dryer). The action simply turns on a virtual switch representing the state of the dryer running. The rule has a required expression on the virtual switch being off to avoid re-triggering.
- One rule triggers on vibration inactive and stays for 1 minute. I determined with this sensor that if it remains inactive for a full minute then it's very unlikely the dryer is still running. The action is to turn off the virtual switch. There is also a required expression on the virtual switch being on.
That's similar to what I've attempted to do with two rules.
Would it be too much to ask that you post those rules? Thanks!
Rule 1:

Rule 2:

You can add more actions to either rule, or you can trigger other rules (or notifiers, etc) using the virtual device on/off transitions.