Translating a Latching Piston from CoRE


#1

I tried searching but couldn’t find anything kind of like this so here we go:

1) Give a description of the problem
I am trying to translate a Latching Piston that I had in CoRE, how it worked that the off condtion would only trigger if the trigger was true. I am trying to have that happen in WebCoRE but so far have been unsuccessful

2) What is the expected behavior?
That If the on condition does not execute (because it isn’t true), that the preceding off statement will not execute

3) What is happening/not happening?
The off condition is executing even though the on condition did not happen

**4) Post a Green Snapshot of the piston


#2

Why not something like this?

Execute
every day at 5 minutes past sunset
  IF
    Switch 4's switch is on
  THEN
  WITH
    Outlet 2 & Switch 5
  DO
    Turn on
    Set variable switch4IsOn = 2
  ELSE
    Set variable switch4IsOn = 1
  END WITH
END IF

every day at 10:55 PM
  IF
    Variable switch4IsOn = 2
  THEN
  WITH
    Outlet 2 & Switch 5
  DO
    Turn off
  END WITH
END IF

#3

If Switch 4 is something that can be toggled by other means, then simply have webCoRE monitor that switch, and whenever it goes on:
Set variable @switch4IsOn = 2

Whenever it goes off:
Set variable @switch4IsOn = 1

And then back in the piston you are working on, you can remove the Set variable lines.

(Notice in this version, the variable is @global, so it can be called from your other piston)


#4

Thank your your reply.

Is this the best way to recreate the old latching piston? It is a really good way to recreate it but I would like to stay way from variables as much a possible.


#5

I don’t know your level with webCoRE, but variables are sweet in coding for smart homes, and real easy to master. Definitely worth it in my opinion.

If (for some reason) you really want to avoid variables then I guess you could do the same with a Simulated switch acting like a variable. (but some people complain that Simulated switches take up space in the ST app)

My vote still goes with using a variable.

(Although, to be fair, if I plan on using Alexa to set that switch (variable), then I use a Simulated switch since Alexa can toggle that directly by voice)