Turn Light off after 30 minutes

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!!

Thanks in advance!

If light turns on
Turn off delay 30 mins
End if

Welcome to hubitat.

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

3 Likes

Screen Shot 2020-05-09 at 11.10.21 AM

@TechMedX is completely correct. This is super simple and perfect for learning the Simple Automation app.

3 Likes

This is what I came up with...was in the process of waiting to see if it will work.
Auto Off

Thanks for the info guys :slight_smile:

How did you get the off option? Are you selecting conditional actions?

Never mind... I figure it out! Thank you so much guys!

2 Likes

This would work too.

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
4 Likes

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.

2 Likes

So I think I figured it out, though not completely intuitive.

Need to test it.

2 Likes

It'll work. :+1:

1 Like

You are better to setup

Trigger: light turn on

Actions
Cancle delayed actions
Turn light off -> delay 30min (cancelable)

@TechMedX is right, that is just formatting that discourse (the forum software) can apply to text that you write here.

This is called preformatted text

And this is an example of quoted text

Rule machine has only one interface.

3 Likes

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 :laughing: ).

Either way will work fine, using only the ON does remove 1 event subscription though (which is good).

The number of subscriptions actually looks the same to me too. Here's a "switch changed" I've subscribed to in Rule 4.0:

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.

2 Likes

That's what I get for assuming. :wink:

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.

Any help would be greatly appreciated.

Thanks!

You might be :slight_smile:.

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.

2 Likes