Random away lighting timer light grouping


#1

1) Give a description of the problem
Random away lighting timer. Would like the lights in the same room to go on/off at the same time, but at random. i.e. all lights are randomly triggered as-is. Would like to “group” the lights in each room so they are treated as a single switch so the rooms (containing one to many lights) as a whole (all lights w/in the room) are randomly lit, not the individual lights. If I group lights in a variable, per room, the statement still triggers the individual lights, not the grouping.

Is there a better way to write the statement? Do I need to add a virtual switch, that controls multiple lights, into the mix?

As always, the help is appreciated. Thank you-

2) What is the expected behavior?
For example if the master bedroom is randomly toggled on, both bedside lamps always turn on/off together. Not one or the other at random.

3) What is happening/not happening?
Please look at the Random Toggle function in the middle of the code.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
(PASTE YOUR LOGS HERE BETWEEN THE MARKS THEN HIGHLIGHT ALL OF THE LOGS SND CLICK ON THE </> ICON TO FORMAT THEM)


#2

Not what you asked, but should this AND be an OR? The way this seems to read, if all of your lights are off, then this won’t fire. Nor will it fire if all of them are on.

As for your main question… I tried putting a group of lights into a device variable but that didn’t help matters…

I’m not sure if there’s a built in way with a single command to get that done.

But you can make a light follow what another light is doing.

Just set the switch = to the other devices switch.

In other words setup a relationship between the leader light and the follower. So when you randomly toggle a leader light, just set the switch for the followers to be equal to the leader. You don’t have to worry about all the logic of which one just turned on or off, just set the switch equal to the leaders switch. WC will work out for you when it needs to send the commands…and when it will just ignore them (command optimization ON is the default).

So just after your device loop add something like this:

With follower bulb 1, follower bulb 2, follower bulb 3
set switch = leader bulb A’s switch

With follower bulb 5
set switch = leader bulb B’s switch

…and so on…


#3

Thanks. I will take a look at the “OR” statement… It has been working, but I think there as been a random mix of devices in both the on and off state when it initiates.

As far as the follower switch, are you saying to add this logic directly below the “random toggle” command?

Thanks!


#4

In their own WITH block…but yeah, after the random light has been toggled (After line #58 in the piston you posted).

And technically the light check at the top that I highlighted should be within parenthesis.

Location mode is away
and
Time is…
and
(Any of these lights
OR
Any of these lights)


#5

Thank you, I was able to get the with blocks in.

As far as the OR statement for the light check. I’m sure i’m doing something wrong. When I click the and statement I want to change to or, it wants to edit all of the conditions w/in the group and it changes all of the and’s to or’s. How do I just change the single and statement to an or statement? To add the parenthesis, is that the “negation” command?

Thanks again!


#6

Probably the easiest way at this point is to Add a new condition and specify that you want to make it a Group.

Then (if it let’s you) drag the other two into the Group and then once they are in the Group, you’ll be able to change the AND into an OR.

Otherwise, make a new group and then just recreate those two conditions inside the group and delete the ones outside the group. Sometimes the IDE is funny about moving conditions…so you’ll have to play around and see what it will let you do.


#7

It worked. Thanks!