FlipFlop - I'm such an idiot!


#1

1) Give a description of the problem
This seems soooo simple. I simply want to leave room #1 as I go to room #2. I want to say “OK Google, FlipFlop” so that the lights in room #1 are turned off and room #2 are turned on or vise versa.

2) What is the expected behaviour?
If room #1 lights are on and room #2 lights are off then change both of those. If room #1 lights are off and room #2 lights are on then else both of those. Else…do nothing.

3) What is happening/not happening?
I create a ST Momentary Button Tile and the create a WebCore Piston that works fine for the first “IF” but can’t create the next “IF THEN” set of conditions and actions. I can’t second "Then If’ or “With Do” statements.

Here’s my question…WebCore does not allow me to create the “IF THEN” set of conditions “IF” and “Then” statements. What am I doing wrong? Why cant’ I create the second “THEN” statements at line 43.

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full
N/A since the Piston can not be created.


#2

I would approach this a bit differently… Maybe something like this:

temp

(notice the first IF is a trigger, and the second IF is a condition)


#3

Thanks…but not sure that I understand the difference. My first IF is the condition of a virtual switch (that I plan to active via Google Home). the second IF seems to “code” fine. However, the ELSEIF condition will not allow me to add details (WITH and DO). I try to add this second ELSE IF condition and WebCore will not allow me to do that…sorta like I screwed up and can’t do that.

By the way, I don’t have a second virtual switch (Dimmer 2 in your example). I’m trying to understand what you are suggesting in determine if it will work for me.


#4

By making the first line a trigger, it prevents the conditions from re-triggering the piston…


In my example, Dimmer 1 and Dimmer 2 can be any two bulbs.
(We are just toggling the switches to the opposite)

In your case, they can be White Bulb 2 and White Bulb 4


#5

Yes, I understand the invert (which is my goal). However, WebCore does not allow me to add any conditions to my first ELSE IF. It simply does not allow me to create anything for that ELSE IF. I’ve tried Chrome on laptop, Chrome on mobile, and Chrome on Igcogito on laptop. It will not allow me to create ANY ELSE IF at line 43.


#6

Sorry… I was trying to show a clean method without using ELSE…
(I generally avoid ELSE blocks whenever possible)


By the way, I tested this, and it worked flawlessly…

  • If the two bulbs matched, then nothing happens…
  • If the two bulbs do not match, they invert…

#7

Perhaps I don’t understand your suggestion, If condition #1 do this and if condition #2 do this (this is what I’m prevented from doing in Webcore)…else do nothing.


#8

My piston above basically says this:

When Momentary Button Tile is pressed, compare the switch on White Bulb 2 and White Bulb 4. If they are the same, do nothing. If they are different, then toggle both of them to the opposite.

Try pausing your piston, and importing mine.
It should work right out of the box.


#9

Here is the same piston with a few comments that might help:

temp


#10

I response…no, the two bulbs would not match. If bulb #1 is on and bulb #2 is off then do something, if bulb #1 if off and bulb #2 is on the do something else, otherwise (bulb #1 & bulb #2 is either both on or off) then do nothing. My question is related to the fact that WebCore does not allow me to create a set of ELSE IF actions. WebCore simply will not allow me to “Click” on Add Action and ignores this request.

I’ve also tried to copy/paste the actions of condition 1 (LINE 26 to LINE 35) to paste to LINE 43…but it will not allow me to do that.


#11

Ahhh. I did not know that you want DIFFERENT actions if (2 on/4 off) versus (2 off/4 on)…

Originally you said:

My piston above achieves this nicely…


#12

If you want different actions depending on which bulb is on, then here is a solid structure:

IF MomentaryButtonTile changes to on  <-- Trigger
Then
    IF WhiteBulb2 is on               <-- Condition
    Then
        IF WhiteBulb4 is off          <-- Condition
        Then 
            Do cool action #1  (2 was on, 4 was off)
        END IF
    ELSE
        IF WhiteBulb4 is on           <-- Condition
        Then
            Do cool action #2  (2 was off, 4 was on)
        END IF
END IF

(Be careful with the indents here)

If both bulbs are on (or both bulbs are off), then nothing happens…


#13

Nope, that’s still not what I want. There are 4 different possibilities (B1 and B2 are the both on, B1 and B2 are both off, B1 is off but B2 is on, and B1 is on but B2 is off). I only want actions if B1 and B2 are different.

By the way, the problem isn’t with my logic (at least I don’t think so). It’s the fact that WebCore will not allow me to create (or copy) code to the second condition at line 43.


#14

BOTH of my pistons above do this perfectly!!!

My last (hand written) piston gives you the bonus option of different commands depending on WHICH bulb was on…


#15

If you are having a hard time seeing all 4 possibilities in my last piston, here it is with extra info:

IF MomentaryButtonTile changes to on  <-- Trigger
Then
    IF WhiteBulb2 is on               <-- Condition
    Then
        IF WhiteBulb4 is off          <-- Condition
        Then 
            Log "2 was on, 4 was off = Do Action #1"
        ELSE (*)
            Log "2 was on, 4 was on = Do Nothing"
        END IF
    ELSE
        IF WhiteBulb4 is on           <-- Condition
        Then
            Log "2 was off, 4 was on = Do Action #2"
        ELSE (*)
            Log "2 was off, 4 was off = Do Nothing"
        END IF
END IF

The extra two ELSE blocks (starred) are not needed, but I added them so you can (hopefully) see all four variations.


#16

I tried what I think you are suggesting…but ended up with the same result. WebCore will not allow me to create a WITH/DO at line 51. Here it is:


#17

That is nothing like any of my pistons above…
(You have literally ignored everything I have said)

Honestly, I do not feel like investing any more of my free-time on this one… but I wish you the very best in all your endeavors…


#18

You’re right…I screwed up. However, correcting the code I end up the the same result in that I can not add actions at line 53.


#19

A question you might ask yourself is:

  • Are you determined to force your current piston to do what you want?
    or
  • Is your goal to get a reliable piston to do what you want?

I can only help with the second choice…


#20

I simply want it to work…it seems so simple but WebCore does allow the second ELSE IF with anything I try. I’m not trying to be difficult but what did I do wrong in my second posting…it seem to be exactly what you are suggesting.