Two Rule Questions

I'm looking for the best way (or even how) to do these two things in a rule.

1) Create a condition if something has change within the X minutes.

Example...if the back door contact has changed within the last 60 seconds.

I see the "exceeds" option, but I don't quite think that works for this.

2) Keep a rule from running again if it's already run that day or it's been X number of minutes

Example...Rule cannot rerun once triggered for another 8 hours.

THANKS!

The second one is pretty straightforward, so let's do that one first. In this example I'll send a notification no more than once a day if a temperature sensor drops below 50°

Required condition: private boolean is true

Trigger: Temp Sensor < 50

Actions:

  • Set private boolean false
  • Send notification
  • Set Private boolean True, delayed 24 hours

For the next 24 hours, if the temp sensor reports a temp below 50, no notification will be sent as the required condition is false.

Thanks! I'll give that a shot. That one of the two has a lot more uses.

For your first scenario, the easiest way is probably to trigger the rule on the back door contact changing and then wait for whatever other event must happen within 60 seconds. While trying to figure out how to make that work, I found this:

In short, that post explains that if the 'wait for event' passes without the event happening, then the %device% variable gets set to 'timeout'. You can test for this and only act if %device% is != 'timeout'. To access the %device% variable in a rule, you need to create a local or hub variable and set it to %device%. In my example below I created a local variable in the rule named "local_device".

The rule below will trigger when the Kitchen Door contact changes. If Button 1 on Remote Switch 1 is pressed within 10 seconds, the Kitchen Table lights will turn on. If 10 seconds goes by without the button being pressed, the lights will not turn on.

Note: since this fires on the change of the door contact sensor, the rule will run twice if the door is opened and then closed, but in my testing, the logs only showed the 'wait for event' being evaluated once. It looks like the 'wait for event' action is automatically cancelled/replaced by the subsequent trigger of the rule.

If you wanted the timer to run from the first change of the contact sensor instead of the last change of the contact sensor, you could use the Private Boolean method to get the rule to only run once per 60 seconds after the initial trigger.

Here is my example where if I push a button within 10 seconds of opening or closing a door, a light will be turned on:

Again...thanks! I'll give this a shot too. Appreciate the quick response and detail!