Execute action for X time based on times switch toggled

I have the zooz ZEN24 light switches. Currently, I have my office lights set to turn on based on the motion sensor in the room. This is only an issue when I happen to not move enough to trip the motion and end up in darkness.

This led me to ask the question: How would I right a rule so that my motion rule would be overridden for a set amount of time if the physical switch was toggled? Furthermore, how would I write it so that each toggle of the switch would add say 15 min to a timer that upon expiring the motion rule would then take back over?

This would be awesome to add multiple switches around the house because then I could add a slightly intuitive rule that wouldn't mess up my schedules if guests using the switches.

I'm very confused with all of RM so if anyone can provide some step by step or pictures that would be very helpful..

Ok this won't help you today, but you might enjoy the story. Girlfriend has been very accepting and patient of home automation, dare I say supportive?

Last night sitting in the living playing a board game, where the lights are motion controlled:

  • Lights go out
  • Wave arms
  • 60s, lights go out
  • wave arms
  • 60s light go out
  • wave arm
  • YOU HAVE TO FIX THIS BEFORE WE HAVE GUESTS.

So now I do have a fix. I have a my own lighting app, and it does 3 things:

  1. The longer the lights have been on, the longer the on time. It uses a ratio of motion/no motion and an absolute limit. For example if I pop into the living room for a minute the lights go out quickly, but if I'm there for say 15 minutes I get a longer grace period where I can be still.

  2. If the lights go out, then on again quickly, there's certainly a human there, and it automatically maxes out the time.

  3. To avoid partner rage, I have an override. "Alexa, turn on game time" sets a scene, and when the scene is set forces the lights on until it's not set.

I've kept it myself since it was a bit of a personal project, but maybe I should publish it. (it has a kind of plugin design, so it can do a ton of other things too if install the helper groovy apps)

2 Likes

On a scale of a four day weekend to four years in college with 10 years experience in the field...how hard is it to learn to write an application as you did?

1 Like

I use a samsung button to override some of my Luminance based lighting.

For example, I have a rule that lights up our living room in the evening, based on luminance dropping past a threshold. Because I use changed in the rule, it evaluates every time the sensor changes by a few ticks. This isn't usually an issue, as it does a great job handling cloudy days...however, in the evening, we often turn off the lights to watch a movie, and the lights click back on as soon as it gets a little bit darker outside. When this happens, WAF plummets.

So. I simply added a variable (override) and a Samsung button that sets it to True or False. Then I adjusted the automated lighting to check the variable. If it's true, the Luminance Lighting rule executes no actions.

To be fair, the button also executes a turn on or turn off as part of the override function (so I can immediately control the current state of the lights), but this was done because I had so many triggers, if/then/else statements etc in the original rule, that it made sense to separate it.

@asj's Alexa override accomplishes the same thing in a slightly
different way.

S

@JohnTX12 I'm a terrible one to answer that question. I've been programming so long I forget the effort it took the learn. That said I think the samsung getting started docs are so good, you could probably do something useful over a 4 day long weekend. You might not understand it all, but you could cut&paste your way to some success.

http://docs.smartthings.com/en/latest/getting-started/first-smartapp.html

The two built in lighting apps have are pretty cool. Doing a button override is the easiest l;ike @scottgu3 suggests, be it controlled from a physical button or from a Alexa->virtual button. And this is support I think by motion lighting.

RM4 is pretty amazing as well, but once things get too complicated I find it very slow editing rules. Since groovy makes sense I can work faster with a text editor+code. But this isn't the right approach for a lot of others. I'll share my app(s) this weekend.

1 Like

So I think I might be over complicating this in the hopes of accomplishing something beyond my level...

In theory this seems like it 'should' be a lot simpler to achieve...Though the last two hours I've been playing with RM would tell me otherwise...

During normal operation, motion sensor is tripped, lights turn on, lights turn off if no motion detected for X time.

What I would like to add:

If button (the ZOOZ switch on the wall for the lights) is pressed, pause the above motion rule for a set amount of time.

If button (the ZOOZ switch on the wall for the lights) is pressed, pause the above motion rule for a set amount of time.

I've found where to disable it...how do I make it only disable for a set amount of time though?

There are a few paths to accomplish this: The easiest, IMHO, would be to go with Motion Lighting as all that logic is baked into it already and you can do exactly what you are mentioning. Create a ML app that triggers on motion and then add the button as a trigger to keep the lights on.

The second path is in RM, create a separate rule for the Zooz switch and when pressed, disable your motion rule. This is what I do as I like creating my own logic if at all possible. So, Rule 1, the motion rule, triggers on motion. Rule 2, the button rule, pauses the motion rule when pressed and resumes it when pressed again. I do this with all my wall switches; If the switch gets turned on, motion lighting for that room pauses until the switch gets turned off again.

A third option (and also one that I use) is that if you have Alexa or GH, create a virtual switch in HE and share that with Alexa/GH. Then, create a routine in Alexa/GH and have it toggle the virtual switch. Create a rule in RM that does as the Zooz button rule does above, but have the virtual switch turn off after x minutes (mine are set to 60 minutes). What this accomplishes is that I can tell Alexa "Don't turn off [room name] lights" and the virtual switch gets turned on. Then, RM kicks in and pauses the motion rule for 60 minutes. If I need to have the lights on longer, I have another routine ("Alexa, don't turn off the [room name] lights until I tell you to") that overrides the timer in RM. My wife loves this one as if she is in the dining room with friends, she tells Alexa to keep the lights on and they stay on. Otherwise, they just turn on and off with motion.

There are a few paths to accomplish this: The easiest, IMHO, would be to go with Motion Lighting as all that logic is baked into it already and you can do exactly what you are mentioning. Create a ML app that triggers on motion and then add the button as a trigger to keep the lights on.

So I've looked and thought I had it...but I can't get the switch to disable the lights turning off...

The second path is in RM, create a separate rule for the Zooz switch and when pressed, disable your motion rule. This is what I do as I like creating my own logic if at all possible. So, Rule 1, the motion rule, triggers on motion. Rule 2, the button rule, pauses the motion rule when pressed and resumes it when pressed again. I do this with all my wall switches; If the switch gets turned on, motion lighting for that room pauses until the switch gets turned off again.

So this would work but the main issue is that my wife (and sometimes...myself) forget to turn lights off which was what the motion activation was for in the first place. Creating a rule that would then require a second switch toggle would not be a complete solution.

A third option (and also one that I use) is that if you have Alexa or GH, create a virtual switch in HE and share that with Alexa/GH. Then, create a routine in Alexa/GH and have it toggle the virtual switch. Create a rule in RM that does as the Zooz button rule does above, but have the virtual switch turn off after x minutes (mine are set to 60 minutes). What this accomplishes is that I can tell Alexa "Don't turn off [room name] lights" and the virtual switch gets turned on. Then, RM kicks in and pauses the motion rule for 60 minutes. If I need to have the lights on longer, I have another routine ("Alexa, don't turn off the [room name] lights until I tell you to") that overrides the timer in RM. My wife loves this one as if she is in the dining room with friends, she tells Alexa to keep the lights on and they stay on. Otherwise, they just turn on and off with motion.

I'd love to attempt to create some of this...could you send me screenshots of how your rules are setup so I can try and copy it?

I have a couple different versions of this going on (as I've been experimenting... again lol). This one uses a group to control if the lights have been turned on from Alexa versus motion.

I haven't fully tested this way of doing it yet
First, I created a group ONLY for Alexa:

Then, I have a rule that triggers when that group turns on:

Finally, I have that group shared to Alexa and part of a "Kitchen" group:

The other way I have of doing it is as follows:
I've been using this method for months now and works pretty flawlessly

First, create a virtual switch:

Then, create 2 Alexa routines:

Finally this is my RM4 rule (ignore the OR as I was messing around with this rule to add our guest bedroom and condition editing wasn't available yet):

@asj did you ever end up posting your app?

Yup! I posted it here:

It's sorely lacking in docs, and I'm working on improving that.