Turn on with motion UNLESS turned off from wall switch or voice?

Hi, I have a Groovy SmartApp that I wrote for my SmartThings Hub that, as I understand, will no longer work in a couple of months when SmartThings ends support for its Groovy SmartApps. I am trying to find what my best option is for when this change is complete. For context I am a Software Engineer but I do not have much time outside of my regular job to work on coding and setting up a coding environment. The SmartThings Groovy IDE was ideal for me because it just worked without having to spend any time on setting it up.

The SmartApp I wrote I call “Motion Plus” and the primary functionality is that of a regular routine that makes lights turn on when motion is detected, and turn off when motion is not detected for a configurable amount of time, however, my app has the added functionality of not turning the lights back on with motion if they were turned off from another source (such as a smart light switch or a virtual assistant) before they were turned off from lack of motion. For example, if I enter my bedroom at night my bedroom lights will turn on, then when I get into bed and tell Google to turn off my lights, they will turn off and not turn back on when I toss in my sleep or get up to use the bathroom unless I explicitly turn them back on myself. The SmartApp has many other features that I have built into it through the years, but this is the most important functionality and the reason I wrote the SmartApp in the first place.

Are there any easy options for me to keep the functionality of this SmartApps once Groovy is gone? If so what is that option? From my understanding if I want to stick with SmartThings, not only would I have to switch to hosting the app myself, I would also have to rewrite it for Java. Rewriting it doesn’t seem so bad if it is just a matter of changing the syntax (it’s only about 400 lines of code, many of which are debugging comments), but it sounds like I would have to find a way to host it and overcome other obstacles. I have heard that Hubitat has Groovy support. Is it likely that switching to Hubitat would be my easiest option?

I am willing to share the code from my SmartApp upon request if it helps answer my questions (or even if you would like to use it for yourself).

You could probably do what you want using ST routines and a virtual switch.

You would use the virtual switch in a routine as a variable to indicate if the lights were turned off from another source.

The virtual switch (variable) would be a precondition in your main routine.


ya I do this with a virtual switch for one space, it shows if the room is currently occupied… so if the occupied virtual switch is off, motion will then turn the lights on and turn the virtual switch on. Then if I adjust the lights or turn them off while it shows the room occupied the motion automation will not fire because the virtual switch is on. I have a larger window of time without motion to turn off the virtual switch and show the room as not being occupied anymore.


This is shockingly simple. I do it this way:

Create a virtual switch called “Motion Inhibit.”

Create a SmartThings routine that turns on the light when sensing motion, but only if the “Motion Inhibit” switch is off, like this:

Create an Alexa Routine that turns on the Motion Inhibit switch and turns off the light.

Create/add to another routine the turning OFF of Motion Inhibit when you wake up, for example, so that it resumes normal operation.


This worked, thank you! It’ll be a little sloppy and time consuming replacing all 29 instances of my SmartApp for different rooms and accommodating for the additional features in my SmartApp using routines, however at least I know it is possible now.


Isn’t there a limit currently in place of 50 routines? I’m betting you might be one who hits this pretty quick. You might want to do this in Sharptools.
Never the less, this thread was very informative.

1 Like

I would definitely need more than 50 routines for this. What is SharpTools?

The limit on Routines is 200.


Ok. That is good to know. Was I maybe thinking about a limit on Edge Drivers? I know I’ve seen a 50 limit stated numerous times on something.

1 Like

Yes, the driver limit is 50, and it has been reported that v3 and Aeotec hubs have problems before you hit that limit.

Has a rules engine much more powerful than routines. It does have a cost for full features. But it’s very reasonable for what you can do. Very active developer. Very nice dashboard too.


Converting my Groovy App to routines would even put me at risk of reaching 200 routines. Just converting 1 of the 29 instances took 4 routines, one to turn on the lights with motion, one to turn it from lack of motion, another to make sure the virtual inhibitor turns on when the light is turned on from another source, and another to control the brightness based on the time of day.

Because of this I looked into SharpTools.io and it is great! Thanks for the tip! Even though it still requires a lot more rules and configurations than when I was using my SmartApp, it feels a lot cleaner than routines, especially since I can use variables instead of virtual switches. I also don’t have to worry about reaching that limit.