Hello all. New to the Rule Machine.
I'm having a heck of a time trying to figure out how to automate a light to turn off after 30 minutes.
Basic set up. When the front light goes on, I would like that same light to turn off after 30 minutes.
I'm sure its easy, but I have no idea what I'm doing. I was able to turn my fan on and off at specified times. Joy!!
Have you tried the Simple Automation Rules app? If not you should install it and start there. It is much easier than RM. Not that this is a hard rule, just saying it's worth a look
Note that if you stick with the Rule instead of the app, you might want to make a small modification to your actions. Right now, your light will turn off 30 minutes after any time it's turned on. If you turn it on at 1 PM, turn it off at 1:20, then turn it back on at 1:29, it will still turn off at 1:30, even though it has only been on for 1 minute and not 30 (and it will also turn off at 1:59 if still on, and likewise for any "on" action you do at any time--these future, delayed "off" actions will pile up and still run as originally scheduled regardless of what you do in the meantime).
The solution if you use a delay and don't want this behavior is to explicitly cancel it, with a common pattern being something like:
Triggers: Front Door turns *changed*
Actions:
IF (Front Door is on) THEN
Delay 0:30:00 (cancelable)
Off: Front Door
ELSE
Cancel Delayed Actions
END-IF
I see you have code here. Assuming this is for Rule Manager. I have a series of forms to work in but would really like to have the code to work with. How do I get into that screen?
I am trying to do this exact thing and want to avoid the stacked off's due to multiple on's. I can set the cancelable in the screens but I don't know how to do the else in the screens. Code seems easier.
I do not think you can enter it as code. @bertabcd1234 is just typing it that way to make it easier to follow in the forums.
Rule Machine "Else" is only an option if you are inside a "if conditional statement". Create an If statement and then create a second conditional action for the else. Make sure to end all If's as all.
good catch @Hasty1 is correct, there is no reason for the rule to trigger on the "off" cycle. You should edit the trigger to only fire when the light is turned "on". If it fires on the "off" it could cancel the timer (I am not a RM expect, I don't even play one of the forums ).
I imagine the difference is really just whether the attribute/event value gets checked in the trigger or (if you do so) in your actions, with it being the latter here. As you note, the outcome is the same either way. Staff seem to be suggesting moving away from "changed" triggers lately, which makes me wonder if they're concerned about inefficiencies in conditionals or something, but for a rule this simple I assume it's unlikely to matter either way.
Sorry, I must be completely missing something. I am basically trying to do the same thing... when the door closes, turn off the light after some delay. But I don't see any delay setting. I feel like I must be in completely the wrong part of the app.
That looks like the simple automations app (aka simple lighting until the most recent platform update). This thread has been mostly about rule machine. But if you click the toggle switch for “turn on when opened” you’ll see another line pop up. That’s where the delay can go in simple automation.