Turn ON lights by motion sensor

Hello.

Trying to automate some bathroom lights, I searched for help here and thanks to @csteele I managed to make this, in with Basic Rules.
Now, because I want to "elevate" my rules, I got the need to make them in Rule Machine.
So, I wanted to translate one fully functional Basic Rule, into the Rule Machine. It looks like I am not such a good programmer (I am a mechanic, therefore I could be excused), because the lights do not behave as in the Basic Rule.

Can someone be so kind and help a fool like me?

Here is the Basic Rule:

And here are the Rules Machine I have tried:
Torn ON
ScreenHunter_06 Apr. 08 13.51

Turn OFF
ScreenHunter_07 Apr. 08 13.51

What have I done wrong, except the fact that I put the waiting time 10 sec instead of 1 min?
Basically this is the reason I want to move in the Rule Machine, to be able to turn OFF sooner.

Thank you.

Try something like this:

The "wait for" steps will cancel if your event fires again so it will start over if it goes active->inactive->active within the 1 minute

As well here is my setup, turns the lights on, waits for either motion to stop or start again and either turns lights off or keeps them on.

Image2

Thank you @jcarreira.

I made it like this and it works. It works with 1 min elapsed time for "wait for event".

My Aqara sensor, can trigger the next Active event, only after 45 sec after turning INACTIVE.
Therefore if I wait less than that, it does not work properly.

I was mislead by the behavior of Sonoff sensor (previously used in the same location), which stays ACTIVE one minute, but is able to trigger immediately after.

One important lesson learned: "know your sensor behavior, before any programming"

Thank you very much for your help. :+1:

1 Like

Thank you, @dpdurst.

I have tried your proposal. It works fine.
A different and nice approach, too.

1 Like

@jcarreira, @dpdurst you turned "my light" ON.
I feel ashamed, because I don't know if I shouldn't read some documentation, before asking this.
Anyway, I understand now that the programming options in HE are beyond my capability to improvise, without reading.

We were all where you are now. Don't worry about it. I've been coding for 20+ years and had to make mistakes to learn HE Rule Machine just like anyone else. Here's a secret every programmer knows but people outside don't.... we all ask questions and copy other people's code to get stuff working. There's a huge website (stackoverflow.com) where we do this and then copy-paste solutions directly into our projects. The win is in getting your stuff working, not in doing it without anyone's help.

3 Likes

I wouldn't feel bad at all about this, it took me some time of just doing some basic rules lights on and off stuff before I ventured into something more involved with the rule manager. But once it clicked with the smaller stuff it took off from there really quickly.. as we say, the lightbulb came on!

I'm going to throw this in, can you not achieve what you want using motion lighting app

Ditto...install the "Motion and Mode Lighting" app that is part of hubitat. It will make this VERY easy and is very powerful.

Go to Apps link on left
Then click the add built in app button top right
scroll down to "Motion and Mode Lighting Apps" click that

I tried the Motion Lighting App too, but I am not sure if I can pause/stop a rule there, by means of a button, when I want to take a bath, without the need of waving from time to time :wink:

@dpdurst does this actually work? Your Wait for event: MToilet Motion active is the same motion that'll trigger your rule. By definition, when the rule is triggered it'll cancel that Wait and never get to the second IF-THEN.

How I have mine is a virtual switch (over ride) and in the app have when it's on don't run rule. Or you could put in the turn off section to stop it turning off. Then using button control app toggle the switch

Replied via private message with logs for you to see in action. I use the same rule for closet lights except its a longer time they are left on.

So much simpler to use the motion lightning app to put in an override. unless you really love programming/rule machine.

That being said I used to have the problem of lights turning off while in the bath. Now i just add another cheap sonoff motion sensor to use as secondary motion sensor near the bath/shower area to keep the lights on. Never ever had a false turn off since.

I tie mine into humidity sensor which keeps the fan and lights on

1 Like

I thought about, and made a trial, but I'll have to refine. Thank you.

I tried this, in this morning. I like it, too.
Thanks.