Help with keeping a piston from continuing


#1

1) Give a description of the problem
Alarm chimes each time a door is opened all day long. It should only chime once, and that’s only if a door isn’t shut when I run the “bedtime” piston.

2) What is the expected behaviour?
When the piston is run by turning on the “bedtime” switch (it’s a SmartThings Virtual switch. I say "Hey Google, turn on Bedtime) and the front and back doors are shut, then a bunch of lights turn off, the deadbolts lock, and the alarm sets “armed-stay”.

If the piston is run by turning on the “bedtime” switch but either the front or back doors are not shut, the alarm should chime once (to let me know to go shut the door that’s not shut).

3) What is happening/not happening?
The piston works as it should, however anytime a door is opened, the alarm chimes. All day long.

**4) Post a Green Snapshot of the piston!

And while I’m thinking about it - when I shut the opened door - will the piston resume, or will I have to run it again? I may need a delay before it locks the deadbolt - otherwise the deadbolt could lock before the door is fully shut (because the sensor may see it as shut when it still has a half inch to go).


#2

Am I correct in assuming that “Switch 2” is the Simulated Switch that Google turns on when you say the phrase? (I won’t use Virtual Switches… Only Simulated Switches. That change alone may solve your problem)


Line 20 is conditions (not triggers) so they should not be triggering the piston. All I can think of is the Virtual switch is causing issues. I would change that to a Simulated Switch via this method.

I also think line 18 should trigger at “ANY” instead of “physically”, since very few devices distinguish between the two.


Pro Tip:
The only subscribed device here is Switch 2’s switch. This means that whether the switch turns on or off, the piston will execute. This also means that your ELSE may execute even when turning the switch off.


#3

I’m working on making a Simulated Switch. Can you tell me the difference between Virtual Switch and Simulated? I’ll only use Simulated from here forward.

So - you listed a few issues - you can see what I’m trying to do. Is there a better way to do this/write this piston? I have the Sim Switch “Bedtime” in SmartThings because I only want to do this piston as a Google Voice command.


#4

It looks good, except for the two things mentioned in my previous post.
(although I usually avoid using ELSE)


#5

What would you use instead of ELSE, in this case?


#6

I typically only use ELSE if there is only a single trigger and/or condition attached to it. You currently have three. (Switch 2’s switch, Sensor 1’s contact & Sensor 3’s contact) This means if any of them are false, the ELSE block will execute.

I am a fan of dropping the ELSE, and creating a new IF/THEN block below (and outside of) the current IF.

(after changing to a SimSwitch and changing line 18 to “ANY” instead of programmatically)


#7

I would simplify the logic a bit

If Simulated Switch changes to on
then
    If All of Contact Sensor 1's and Contact Sensor 3's contact are closed
    then
        with Switch 6..., Turn off;
        with Lock 1..., Lock;
    end if;
    If Any of Contact Sensor 1's or Contact Sensor 3's contact are open
    then
        with Keypad 1, chime();
    end if;
end if;

Theoretically you could replace that last if with an Else, but I tend to avoid Else’s because any contrary condition executes their block. It’s harder to follow the logic.


#8

Thanks @qoheleth, that is a great example!

Notice how he moved the contact sensor check inside the other IF. This means they are not checked until after Switch 2 changes to on.


#9

GASP Genius! Nice solution! I’ll implement it and run it tonight - let you know how it goes tomorrow! :slight_smile:


#10

To keep me honest - here’s the new one. I think I did it right! Switch 2 is the Simulated Switch.


#11

Looking at this more - one thing concerns me, but I may be wrong.

If any of the door contacts is open - will the deadbolts still lock and the lights still turn off? I don’t want that to happen, but I’m not experienced enough to tell if it will.


#12

Your last IF (lines 38-46) should be directly below the IF above it. (not inside it like you currently have)

You can easily drag & drop it to the right location.


#13

Ok good, I will.

Will the chime stop when I save the piston, and then not chime ever again until I switch bedtime and a door is open? ‘Cause that thing is getting to me, going off each time I take the dog out! :slight_smile:


#14

It should. As long as there are no other pistons still programmed to chime.
(I often pause old pistons when testing out new variations)


#15

LOL It’s driving the dogs just as nuts!

Ok, this is is:


#16

You just posted the identical image as before. (no changes)


#17

Whups! Fixed! But the damn chime is still chiming. Going to have to shut down all of my pistons, and then do one by one.


#18

I think I see why it’s chiming. The “If Any of Contact Sensor … is open” needs to be inside of the big If (If Switch 2’s…) but not inside the second-level if (If All of Contact Sensor…). (Just move it to right above the end if that it’s below right now.)


#19

LOL OY! Ok, here it is:


#20

Ugh. I don’t know what’s going on now. I paused all of my pistons that even remotely mention alarm or door contacts… And it still chimes. This is new. I need to delve into this much further, clearly…