Generic way to test "time since state became X" for device attributes?

Is there a generic way to be able to write an expression in RM4 like:

IF (Garage Motion inactive for 15 minutes) Off: Garage Lights

I know each device has its own event log and with some custom code I can look back in that log to figure out when an attribute changed. Just wondering if there is a nice/generic way to do that same test in RM.

Note that this wouldn't be for Triggering a rule, just a conditional check.

This may help not sure haven't looked into it myself yet:

You may also wish to consider the following:

Thanks, both of those look more like delays/timers that get set. Thinking about this more what I want is a "last changed" timestamp tracked for all device attributes.

IF (Garage Motion inactive AND Garage Motion last changed <= now - 15m) Off: Garage Lights

Breaking it out as a separate timestamp attribute would let you do all sorts of fun stuff conditionally on the attribute.

The way that I've use the switch timer is as follows:

  1. I have a simple lighting automation that Turns on the switch timer when the switch is turned on. An attribute of the switch time switch, is how long (minutes or seconds) I want it to count down.
  2. I have a RM that turns off the switch (or does some other action), when the switch timer switch "turns off".
    Simple, but powerful. I'm also sure it can be done in a variety of other ways.

How do you know that the Garage Lights are inactive? A light is usually on or off. Do these lights have a motion sensor?

Sorry, the naming is just copied over from my devices, in this case it is a light switch motion sensor combo. I'll fix my example so it is clear :slight_smile:

Ok, how about a rule like this:

TRIGGER: Light change

Delay 15 minutes
Wait for Condition: Garage Motion Lights inactive
Off: Garage Lights

Right, that is what I do now but there are some cases where I'd like to check "how long has attribute X been in state Y", I just picked a simple example to illustrate it. I can work around the lack of last-changed information in each rule it is just more cumbersome to do so.

Sounds like I should submit a feature request for something like this :slight_smile:

Created a FR: Attribute Metadata in RM

Yes, something like you are looking for does not exist so far