Restrictions on when part of piston runs


#1

1) Give a description of the problem
Light turns off anytime I open door

2) What is the expected behavior?
Wish to have light turn off when opening door only after arriving. So if I come home turn porch light on, open door then turn light off, but if I’ve turned light on while at home and then open door do not turn porch light off.

3) What is happening/not happening?
Light turns off anytime door opens

4) Post a Green Snapshot of the pistonimage


#2

This should probably do it. Just sub this out for your bottom IF block. Adjust the time as you see fit. But the second condition will basically restrict the piston to only run within the first 2 minutes when you’ve come back home.


#3

This is another way to accomplish the same thing. This method has “fewer moving pieces in it” so to speak, so it should work more reliably. it uses a variable to set a condition on the second half of your piston.


#4

I went with the second option and it’s workibg great. I’m wondering if you can help me out with how it works. What exactly is the variable doing for the piston and how does it make it only turn light off that one time? Thanks for the help!


#5

A variable is just a container for a value. In this case I’m using a Boolean variable which can only contain a value of True or False. Think of it like a virtual light switch. It’s either ON (true) or OFF (false).

So when you come home, the piston now flips ON (sets to true) a virtual switch. Then we can test against the value that is stored in that variable (we can look to see if the light switch is ON or OFF) and use that as a condition in the piston. Which is another way of saying, only proceed with the next set of commands if the value stored in the variable is set the way we want it (in the case, set to True).

When you come home and the light turns back off we set the variable back to False. This then means that the bottom set of conditions can no longer BOTH be true. Since the variable is now set to False (the light switch is in the OFF position). And since the variable is false, the entire “and” condition becomes false. Which means that no matter how many times you open the door the bottom part of the piston no longer runs.


#6

I’m hoping you can help me out with something. You did a great job with this pistonbht there’s one thing I’d like to ask you about and if possible change something. I’ve noticed that this piston seems to only trigger once and won’t trigger again after that. For example if I drive past my home while meeting the conditions of being after sunset then my porch light turns on the way it’s programmed to do, but when I leave the geofenced area my goodbye routine turns the porch light off. The issue arises when I actually do come back home and the porch light doesn’t get turn on by the piston. It seems like it only fires once per night. Now I don’t know that’s the way it’s setup because it seems weird that it works fine the next day. I’m just wondering why sometimes the light doesn’t come on.


#7

3/1/2018, 7:02:33 PM +875ms
+10270ms ║Piston waited at a semaphore for 10075ms
3/1/2018, 7:02:18 PM +628ms
+10290ms ║Piston waited at a semaphore for 9822ms
3/1/2018, 7:02:18 PM +699ms
+10177ms ║Piston waited at a semaphore for 9590ms
3/1/2018, 10:59:08 AM +862ms
+224ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 10:58:27 AM +53ms
+200ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 10:56:39 AM +125ms
+9987ms ║Piston waited at a semaphore for 9819ms
+10032ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 10:56:38 AM +917ms
+195ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 10:42:26 AM +849ms
+10213ms ║Piston waited at a semaphore for 10029ms
+10258ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 10:42:27 AM +653ms
+192ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 10:42:26 AM +808ms
+196ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 10:42:09 AM +197ms
+10267ms ║Piston waited at a semaphore for 10093ms
+10307ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 10:42:10 AM +831ms
+197ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 10:42:09 AM +62ms
+221ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 10:15:05 AM +985ms
+214ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 10:14:49 AM +781ms
+232ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 10:14:49 AM +402ms
+199ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 10:14:48 AM +802ms
+338ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 10:03:24 AM +28ms
+224ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 10:03:21 AM +870ms
+199ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 10:03:21 AM +227ms
+237ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 9:57:11 AM +605ms
+187ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 6:32:21 AM +334ms
+353ms ║Piston execution aborted due to restrictions in effect
3/1/2018, 6:28:37 AM +274ms
+205ms ║Piston execution aborted due to restrictions in effect
2/28/2018, 7:07:55 PM +175ms
+10086ms ║Piston waited at a semaphore for 9909ms
2/28/2018, 5:30:20 PM +325ms
+241ms ║Piston execution aborted due to restrictions in effect
2/28/2018, 3:58:32 PM +960ms
+185ms ║Piston execution aborted due to restrictions in effect
2/28/2018, 3:29:06 PM +28ms
+191ms ║Piston execution aborted due to restrictions in effect
2/28/2018, 3:21:17 PM +381ms
+197ms ║Piston execution aborted due to restrictions in effect
2/28/2018, 3:13:42 PM +236ms
+368ms ║Piston execution aborted due to restrictions in effect
2/28/2018, 12:44:42 PM +414ms
+196ms ║Piston execution aborted due to restrictions in effect
2/28/2018, 12:23:44 PM +992ms
+194ms ║Piston execution aborted due to restrictions in effect
2/28/2018, 12:05:36 PM +996ms
+180ms ║Piston execution aborted due to restrictions in effect
2/28/2018, 8:37:21 AM +546ms
+243ms ║Piston execution aborted due to restrictions in effect
2/28/2018, 8:34:53 AM +694ms
+197ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 4:00:52 PM +855ms
+10233ms ║Piston waited at a semaphore for 10040ms
+10282ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 4:00:54 PM +789ms
+229ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 4:00:52 PM +840ms
+204ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 4:00:36 PM +853ms
+227ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 3:54:04 PM +201ms
+194ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 3:15:19 PM +937ms
+184ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 3:15:19 PM +570ms
+210ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 3:15:16 PM +382ms
+227ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 1:12:54 PM +376ms
+674ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 1:12:35 PM +906ms
+191ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 12:26:28 PM +574ms
+183ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 11:34:12 AM +8ms
+264ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 8:44:15 AM +72ms
+397ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 8:44:09 AM +311ms
+204ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 8:41:56 AM +65ms
+196ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 8:41:02 AM +748ms
+191ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 8:41:00 AM +940ms
+187ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 8:40:59 AM +859ms
+209ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 7:59:01 AM +994ms
+221ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 7:59:01 AM +738ms
+193ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 7:21:08 AM +787ms
+228ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 7:14:13 AM +890ms
+184ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 6:18:45 AM +249ms
+194ms ║Piston execution aborted due to restrictions in effect
2/27/2018, 6:16:28 AM +254ms
+226ms ║Piston execution aborted due to restrictions in effect


#8

Can you post a green snapshot of your piston so that I can see what we’re working with… That will help more than the logs at this stage.


#9


#10

So I take it that “Switch 8” is your front porch light as that’s the thing you’re turning on. If that’s the case then that should work without issue. The only Trigger involved there is your Presence sensor “changes to Home”. The variable does not even come in to play there.

There is one hole in this piston though…and it becomes apparent from your description of one possible use case. If you actually drive by your house, then the Boolean variable JustGotHome will be set to true even though you did not go in the house. So in that case it will not turn the light back off the next time you come back home. To get around that you’d need to add a block in this piston which would set the Boolean back to false when your presence is no longer detected at home.

But beyond all that…there’s something odd going on with this piston. You’ve only got 2 Triggers in it…but from the logs you posted it’s firing all the time (and getting blocked by the Time restriction). There’s so much activity that the piston is actually timing out. But I don’t see any events in the logs to actually indicate why it’s running. That seems very odd to me. I don’t know why you would get all those messages in the logs if the piston isn’t trying to run…but if it was trying to run there should be some reason why it’s trying to run (you came home or the door opened/closed).

The logs now baffle me a bit as to what is going on with this piston. But suffice to say, with all the activity that is happening with it there’s a good chance that sometimes it missing firing just because its overwhelmed.


#11

So what would you recommend that I do? I’m not asking you to do all the work for me but have no idea how to do the block part that you’d mentioned.


#12

It’s just another IF trigger.that you would add near the bottom of the piston (anywhere is fine, just don’t nest it inside any of the other IF blocks…put it out by itself).

IF Your presence sensor leaves home (however you construct that with the WC PS)
then
set variable JustGotHome = false

That way when you leave (or if you just drive by) the variable will go to False and be ready for when you come back.

That does not fix the semaphore problem though. I’m not sure what’s going on there.


#13

Like this…? I’m still not completely completely clear about the bolean variables but your suggestion does make sense. Thanks. I’ll let you know how it works at some point - only had issues with the previous piston a couple times a month, but drove me nuts when I wanted to show off what it does and didn’t work out.


#14

Yes. Like that.

Think of a boolean variable like a light switch (or an old fashioned light bulb for that matter). It has two states, on or off. Or in computereze, true or false. Which basically translates down to 1 or 0. The variable is just “storing the value” 0 or 1 for us so that we can compare it later to make decisions. Just like you could make decisions in the physical world if a light was on or off. If the light switch is on then it’s time to make the donuts. :slight_smile: A variable is just a container for a value. A boolean variable can only contain 1 or 0 (True or False).

If you just drove past the house, then the variable would be set to True because you never went in and opened the door (which was the action that flipped the variable back to false). This newest change resolves that potential issue.


#15

Mike I’ve finally gotten around to testing this piston and it works great! Thanks so much for your help!