Vacation Lighting Piston


#1

1) Give a description of the problem
The piston is working great, just not sure its going to turn the lights off at the end of the IF statement? I found this piston on the forum and slightly modified it for my use, thanks to the creator.

2) What is the expected behavior?

3) What is happening/not happening?
(PUT YOUR INFO HERE)

**4) Post a Green Snapshot of the piston!


(PASTE YOUR LOGS HERE BETWEEN THE MARKS THEN HIGHLIGHT ALL OF THE LOGS SND CLICK ON THE </> ICON TO FORMAT THEM)

REMOVE BELOW AFTER READING


#2

I don’t believe this is going to do what you want it to do. Of greatest concern is the “Every 5 minutes” part.

Essentially when the conditions are met, this piston will indeed run every 5 minutes. And it will generate random times and turn the lights on and off randomly. But because it’s running every 5 minutes the net result might be that the lights just look like they are ON and they stay ON all night.

I don’t think the Every 5 minutes is the right way to kick something like this off.

What’s the real goal here?


#3

Just want to randomly toggle lights when in vacation mode and between those set times. Saw this on the forum and that person reported it working good. I’m up for suggestion though.


#4

That “every 5 minutes” part is just…odd to me. I see no value in doing that whatsoever.

I helped create this piston below which will determine a random time between sunset and an hour before midnight and turn on the lights for a few minutes. Adjust as you see fit.


#5

Thanks for your help, I’ll check it out.


#6

This works flawlessly.
Delete switches 3 and 4. These disable things.


#7

Here’s how I do it for a truly random result… Radom waits and random toggles for each individual light.

Lights turn off at end of time restriction or if alarm is disarmed.

Last block checks to see if random events have accidentally turned everything off (not very realistic) and turns on my hallway light if that is the case, so at least one light is on all the time.


#8

So if I wanted to modify yours @Robin for a vacation mode, I can change your SHM status to a vacation mode, change your dimmers to my lights and really only need the first IF/THEN/ELSE and don’t really need your second IF block?

Does your first IF block turn off the light/switch by the “random toggle” command?


#9

The first IF block random toggles so yes, it will turn off as well as on, it’s just random in regards to choosing on or off.

The second IF block is just there to reset lights to off when SHM is disarmed.

The ‘on events’ at the end ensures at least one light (I chose the hallway light - dimmer 9) is always on, so if a random toggle turns off the last light, dimmer 9 will turn on… a black house is an empty house.


#10

This is great, but is there any way to group lights together? Most of my fixtures have multiple bulbs so I want them to toggle together.


#11

You should be able to group lights within each ‘with’ statement and have them all toggle together.

Or you could throw the smart bulbs in the bin and get proper switches lol


#12

They are grouped together in the with statement, but the random toggle acts on each light independently.

I do have some, but there are many reasons NOT to use a wall switch.

  1. I am mostly using Hue bulbs and Sylvania Smart+ adjustable color temp bulbs since I want that adjustability. So at best the switch is a waste of money and an added complexity in writing pistons and simply would not work with default SmartThings automations.

  2. Some of my wiring does not have a neutral so would require re-wiring.

  3. Even the best dimmer switches do not always work well. There are a lot of compatibility issues with LED bulbs even those that say they are dimmable.

  4. The switches are often much more expensive than bulbs, so for lights that are only being used for automated task and you never use a physical switch why waste money. I can get a quality Zigbee bulb for $12. A good switch and dimmable bulb is $50+. And that’s assuming you already have the proper wiring or wiring for a switch at all.


Execute Routine at 8 PM +/- 15 minutes
#13

I found a solution.


#14

Robin, doesn’t your program have the potential to leave a light on all night long? If the last Random Toggle for a device before 10:30 pm turns a light on, won’t it will stay on all night until the program resumes the following day at sunset?

I used some of Brandon Pines similar code in dct7c (below) to toggle lights on and off. I “overlaid” this WC logic on top of ST Smart Lighting which turns on some living room lights an hour before sunset. WC starts toggling after the lights have been turned by ST, so I know the first toggle turns them off. A second toggle will turn them on, so it is possible that a light will be on at the end of the execution time window.

To prevent a light from staying on all night, I added a “cleanup” chunk of code at the end (after the expiration of the last possible wait period) that walks through all the WC random controlled devices and turns them all off about a minute apart. It’s just a little bit of insurance to avoid lights on all night long.

dct7c


#15

The ‘else’ section from line 56 is there to prevent lights being on all night.


#16

I see that now - outside the random timing window, turn them off. Thanks. Missed that before.


#17

I tried to import your posted vacation lighting piston eqs6 but it I receive an error. Is this piston no longer available?

Michelle


#18

Works for me… so the backup is alive in the cloud… was worried for a second as @ady624 dumped 26GB of data last week (fuel streams).

What process are you using to import?


#19

I tried again to create from backup code using a laptop vs my ipad and the piston loaded. Seems to be an issue using my ipad. First time that happened to me. Thanks for confirming it worked.


#20

My take on this. Cleaner code!