Are there any loops?


#1

Can anyone look at this piston and tell me if this is the only thing controlling these devices is there a chance that a loop will form (meaning turn on, turn off, turn on, etc…)

I just want the light switches to turn either turn back on if they were turned off or visa versa.

Thanks!

Here’s a screenshot:


#2

Pretty sure you can reduce the size of this piston considerably. Maybe try making use of $currenteventdevice.
For example:
IF any of Dimmer 1, Dimmer 2, Dimmer 3, etc… changes to ON
AND ($sceneactive) is true
THEN with $currentEventDevice
DO

I’m not sure about your original question regarding the loop yet. I’d first consolidate this piston into more efficient and readable code. It’d be much easier to troubleshoot.
I’ll try and import your piston and take a shot at consolidating it.


#3

How about something like this?


#4

By the way, the whole thing looks like a loop. When something gets switched off, it turns right back on after 5 seconds. Then when it turns on, it turns right back off after 5 seconds.

What exactly are you trying to do here?


#5

If you look closely, there are no overlaps. I have two categories, lights that are on and lights that are off. For the ones that are off, I want them to stay off and if someone turns it on, it should turn it back off. For the ones that are on its the exact opposite.


#6

Very smart!
Just to clarify, if I have some that I want to keep on and some that I want to keep off I would need to separate pistons, correct?


#7

Not 2 separate pistons at all… Just create another “device” variable for lights you want to keep on, and a “device” variable for lights to keep off. Then adjust each IF statement to reference each variable.


#8

Just to clarify my goals. I’m trying to set up a piston that enforces the current scene.

For example:
“Movie Scene” activates when I turn on Netflix. The scene turns off the den lights, closes the windows, and turns on a little night lamp near the controls box. If someone were to walk in and turn on the den light I want the piston to automatically turn it off.


#9


Store the lights in separate variables, then I adjusted each IF statement to represent those.
Let me know if that makes sense.


#10

Will this work if any of the “{dimmer_off}” switches? Or will it require all of them?


#11

It’ll work for any of them:


#12

Ok great, this is much easier to work with, thanks!


#13

Back to the original question, you agree that there are no loops? Someone told me he thinks there are (but I don’t see why)


#14

As long as different devices are represented in each IF statement, there shouldn’t be any loops.
If the piston works for you, please mark my post #9 as “solution”


#15

Will do!


#16

Would it be safer to do “physical interaction” as opposed to “any interaction”?

Meaning if, by accident, there is some other piston or routine that will turn on/off the light, it will ignore it.

P.S. I did hear from somewhere that ST isn’t reliable in detecting the differences, do you know anything about that? Because if its true then it wont make a difference.


#17

don’t bother changing it to “physical interaction”. From everything I’m reading, it depends on the DTH and even then, most devices can’t report the difference between the two.

Do a search on this forum for “physical interaction”…
Here’s a post


#18

Ok thanks


#19

Interesting question, it’s not so applicable to here but more in general. I added in a 5 second wait time just to give the system a chance to process the commands. However sometimes I use a 10 min timer (i.e. 10 mins after I wake up start making coffee). Let’s say I had a piston that sets the the “sceneActive” variable true from 5 AM - 6AM and if its executed there’s a 10 min timer. If I cause the piston to execute at 5:55 AM, which means it should do whatever at 6:05 AM, would that work? Or because “sceneActive” is now false it won’t?


#20

I’m not quite sure I follow you, but I can tell you that the two IF statements WILL NEVER execute if “sceneActive” is False. According to your piston, “sceneActive” is only True between Sunset on Friday - 01:29AM on Saturday.
I would try to avoid setting “sceneActive” in any other pistons. It’ll only confuse you in the long run and you may wonder why lights start behaving erratically.