FlipFlop - I'm such an idiot!


#21

There are numerous things that I would change with every piston you posted here… Instead of trying to fix each and every issue, I took the time to share a clean/concise piston that does everything you asked for, with no hassles.

My recommendation would be to PAUSE your current piston, and try creating a new piston based on my code

If you are still in need, I can convert that text into an piston (that you can import) in about 40 hours from now…


#22

You keep reposting the same image (code ‘ivpn’) so can’t tell you are doing anything @WCmore is suggesting. I tried loading you code and there are links to add statements after every condition statement so I don’t understand where you are having a problem. You might have to capture a screen shot while you are in editing mode. I don’t see how what you are saying can actually happen in webcore.


#23

I’d say, stay away from ELSE statement until you get a really good grip on Webcore, even then still stay away:)))
Like @WCmore I have way over 100 active pistons and more paused pistons, with a very complex St home system, not a single ELSE usage in my pistons…


#24

I went back and looked at this again with fresh morning eyes and now got everything working as expected. I appreciate your help and patience.


#25

Excellent!

Perhaps you can share your piston so others can benefit from it?


#26

Sure…see below:


#27

I would be very surprised if that piston does not loop… but I am glad it is working for you…


#28

I agree, I am very surprised that this does not loop might be as its in the else statement … however do still keep an eye on the logs and make sure its not constantly running.


#29

I’m curious, and still learning, why do you think it would constantly loop? Switch #1 is a Momentary Switch and serves as the trigger for this piston only when it is pushed on.


#30

Quick Answer:

I don’t think it will constantly loop, but each event will likely loop more than once…
(you can verify by turning Logging to FULL)


Long Answer:

You have zero triggers in this piston… so all conditions are treated as triggers.
(the lightning bolts in the left margin)

This means, when any of the 3 devices changes (in either direction)

  • Switch 1’s switch (on or off)
  • White Bulb 2’s switch (on or off)
  • White Bulb 4’s switch (on or off)

… the piston will run thru the entire code top to bottom, and execute anything not blocked by conditions.

All of this, paired with the knowledge that Momentary Switches takes a few moments to turn itself off, and the hub takes a moment to register the change… and you can see why I avoid this type of logic…


…but again, if it works for you, great…

Personally, I would never code like this:

IF DeviceA changes
    Then Change DeviceB
END IF

IF DeviceB changes
    Then Change DeviceA
END IF

#31

agreed

I got myself in a right mess trying to make sure that physical (smart) switch was always left on and that the smart bulb connected to that switch was always set to the desired state.

Basically trying to let people use the switch as an on off switch if they want, or because its a colour bulb I wanted then I could control the colour of the room programmatically.

This lead to my brain hurting a lot, and much failure, looping round in circles, and when I did eventually get it working the bulb would turn on/off/on/off before it eventually found the state it should be in. Eventually (with some prodding from a certain very knowledgable person) I gave up trying :blush: