Light On when Door Opens At Night

I thought this would be fairly simple. I'm trying to have my entry light come on when the front door opens at night. Both the door contact sensor and the light switch are z-wave.

In Rule Machine, I have the trigger event of the front door contact opening. In actions to run, I have entry light on with the condition of between sunset and 2300.

The light is coming on at all times when the front door is opened. What am I missing?

The condition you have is not actually in the rule. Creating a condition does not mean it is being used. You need to create a if statement in the rule.

If <condition>
     Light on
End If

An alternative, assuming your trigger is the door opening make the condition a required expression.

2 Likes

You are not using the condition in your rule. You have only defined it. Put the condition as a required expression to trigger.

Edit: great minds think alike. We must have been typing at the same time.

1 Like

Also note that if you want the light to turn off when the door is closed, nothing in this rule will do that. It would be possible to do something like that in this same rule (not that I normally encourage doing a bunch of stuff in the same rule for no good reason, but this is a simple enough case where it makes sense), or, of course, another one could do that, too.

But I might suggest Simple Automation Rules or Basic Rule for this, either of which can handle this automation -- including the restriction -- with ease. RM can certainly handle it too if configured with the right settings, but it is more difficult to get started with. Good luck!

1 Like

Ah, got it. It seems I wasn't going far enough. Here's what I have now.

You need to move the action down under the if. As written it will turn on and then check the condition. As others have said, moving that condition into a required expression would be better

Okay, moved it.

Now playing around with "Use Required Expression" if this is probably the best method of doing this.

Now with "Required Expression"

Assume this is a best practice for when rules become complicated?

1 Like

Thanks gents. Learning has occured!

3 Likes

It looks like you switched to using a required expression, which seems the better way to go here, but just for completeness, your screenshot above is missing the "End If" as the third action. You would need to click the "END-IF" at the bottom of the table to add it.

Where is "END-IF" and what is it used for?

It completes an "IF-Then" conditional statement and would be required in your second to last rule...the one with the IF(...)Then

It is not required in your last rule ...the one with the required expression.

You use it to close out an IF block.

image

1 Like

Where is this located?

I watched the video on rule machine located here and it didnt' go over it.

I found it but I had to run an If -Then which I did to turn the light off if my or my wife's phone were not present in 15 min.

Not sure that will do what you want. Not 100% sure of your situation but if the door is opened someone is probably home, yes? Which will mean the light will probably never go off since you check it immediately after the trigger. Probably a delay before the IF would be better. The wait for event is probably better than a delay, as it will stop the rule and restart on a trigger. If you use a delay, then another instance of the rule will be started. Turning the light on is missing but it should still be there, just forgot to put it in the example.

2 Likes

I do this with a simple automation rule. Mine is in the basement so I always have them come on, but you could easily add the restriction for time of day/illuminance.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.