Vacation Mode / Randomize Lights?

I will try it !..You rock my friend, thanks,…this is great !.

1 Like

Mariano, I have a specific use case and this SmartApp does exactly what I need except for one tweak I need.
How can I build a delay before the next On event? So if the device is on and finishes the random time and turn off, I want to have a delay of at least 1 hour before the device turns on again. I does not have to be a specific duration, just at least one hour.
I have been looking at your code for a bit today and it appears you use newTime as the random calculation for both on-time and off-time.

I have only 1 switch I want to control so random device selection would not impact me.

Would it be possible to add a delay before dimmer.on in the following?

if (dimmer.currentValue(“switch”) == “off”) {
} else {

Thank you for the app and your attention!

I do not know if I have understood it correctly, but if you choose the minimum time 60 minutes and the maximum time 61 minutes, you would enter and pay each interval between 60 and 61 minutes.
I don’t know if this would be worth it.

Sorry that I wasn’t clear. I want to have the time the switch is on be low. Something between 5 and 10 minutes. And then I want the off time to be (something between 5 and 10 minutes + 60 minutes).
So I just want to add 60 minutes to the timeCalculate when the next on delay is calculated.

I was looking at your code but could not figure it out because you calculate the random time first and then when the delay is over you pass it to the dimmer device in an if statement (if on turn off / if off turn on). I tried adding an additional runIn in the if statement but it is ignored for some reason.
runIn(60*60 , dimmer.on())

Thank you!

@Mariano_Colmenarejo I think that @fstr is looking for something like Fan Circulation Schedule you implemented in Zigbee Thermostat or combination of both Random and Scheduled
Random Min Time
Random Max Time
Random Off Time

1 Like

That does not work, it will even give a fatal error when executed, it already makes a call to a method that does not exist, dimmer.on ().

I have made a version in github with the modification, it is called Random Lights Modified, I will put the name you want when creating the controller.

Note that groovy-based apps will disappear when groovy disappears.

Try it and after some days I will delete de file

So simple! Thank you very much! I will give it a try.

Actually, it is running into the same problem I had when trying to update the code myself;
When it calculates the first delay (before the first run), the dimmer is not defined yet so it cannot know the state of a dimmer that is not defined.

error java.lang.NullPointerException: Cannot invoke method currentValue() on null object @line 344 (timeCalculate

What about No worries while away in SmartThings Labs?

I already have it, but I want to improve it.
I’ll let you know when it’s done


It is already modified,

I have left the lines changed with // in case you want to see it.
I added a variable that adds an increment o the calculated random time.
When switch changes to Off, Increment = 3600 and when it changes to On, Increment = 0.

The other did not work, because it was calculating the new time before the switch change state was received from the cloud.

This solution will only work as long as it works groovy.

If the switch you use is zigbee and it can be added to an existing edge driver, this could be done in the same driver and it would work locally and in the future

Thank you!
It’s a shame about Groovy, but at least for now I have a solution until I figure out the next.

1 Like

Hi @Mariano_Colmenarejo I have copied the device handler and code and published them to me. I have turned on developer mode on my SmartThings app, but I still do not see anything under Automation > Smart Apps, except what was there before. Any ideas?

In Automations, click on the + in the upper right of the screen and select Add Routine, then tap on the Discover tab near the top… scroll down to find custom smartapps

1 Like

What I did was to go back to the IDE web page and I found that my app and DH had disappeared. I recreated them and published them and this time when I tried to add a routine, I found the new smart app at the bottom.

1 Like

Hi @Mariano_Colmenarejo Thanks for the awesome smartapp. But I cant figure out how to proceed with the virtual switch. Is that switch only for show when automation is running?

I need to stay the smartapp OFF and turn ON only when I need to the random lights start, if the condition of automation are meet.
But I’m trying to create a virtual switch to turn ON or OFF the smartapp, its possible? Because I cant add a smartapp in Google Home, but Virtual Switch I can.

Another problem, is that if I turn ON the smartapp after the start period set int the configuration of smartapp, its not work, I need to turn ON the smartapp and turn ON the virtual switch after that to respect the automation. But if I turn ON the smartapp before the start period set in the configuration, everything is done well.

HI @musashi

Just remind you that groovy is scheduled to stop working on September 30 and this app too

This is an alternative for new edge drivers

This switch is for activate or deactivate the function manual or eith autoamtions or escenes.
You don need programan times in the app, only active or deactive with automations

Pdf guide

In this post is all instructions

Oh ok @Mariano_Colmenarejo, I don’t knew that it will stop working.

Alternatively, I don’t understand this new alternative, how can I apply that on my wifi pieces linked in my smartthings, like I made with your smartapp? I checked the link you post but can’t understand how.


with this virtual device you can activate a random secuence.
Then you could do automations to imitate this random secuence in one or several devices.

You could create Two or three virtual devices to made two or three differents random secuences

Similar to this to imitate status change of other device

Ok @Mariano_Colmenarejo but how can I install this Virtual Switches Mc? In your channel link? There´s nothing to do when I enter in your channel.