Mailbox piston, Need another set of eyes to help me


#1

1) Give a description of the problem
This is a very basic piston, it should work and some of it does. Just not ALL of it. Its probably obvious and I’m looking right at the problem and not seeing it.

2) What is the expected behavior?
When the mailbox door opens the piston sees the changed and sends the SMS, It then should wait 5 minutes and set the boolean variable to set up for the next event.

3) What is happening/not happening?
It triggers, sends SMS, sets up for wake event 5 minutes later, wakes but NEVER sets the variable?

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
Here is a snapshot of the execution. I know not how it says to do it was just easier.

I’m sure it is something simple. Sometimes a new set of eyes see the obvious.

Thanks in advance because I know someone will see what I’m doing wrong and correct me.


#2

I would move line 28 up one line (set variable before the wait).

Otherwise, if someone gets the mail within 4 minutes, the results will not be what you want.

I think you want to keep line 37 where it is though, since that one is resetting itself for the next day. (Although, I would remove the pause on line 36, since it serves no purpose)

Actually, on closer examination, I would be very tempted get rid of both pauses. I don’t think they are needed, unless you have some complex plan with this piston in the future.


#3

This is how I’d build it… not tested :slight_smile:


#4

I like this @eibyer, but he won’t get notifications when a household member retrieves the mail with your piston.


#5

The pause “in theory” was to allow the mail person to close the door. Then set the variable. I was afraid it would set the variable then move on and send the mail picked up if I didn’t give time for the contact to close again .
Probably not true, just explaining my thinking for the pauses.


#6

I saw something similar to this.
I like the idea but doesn’t really fit my use case.

I was thinking mail.person drops off mail.
We get notified
Some time later in the day someone grabs the mail.
We get informed again.

Not so much back to back events.


#7

I am trying to avoid use the contact changing to closed or is closed as a trigger.

My thoughts being what if mail person doesn’t close door tight.

I think it should work like it is? Just not sure why it didn’t set the variable.
Maybe when I get home I’ll create a virtual switch and use that as the binary vice a variable?


#8

That makes perfect sense. I imported your code above, and made a few tweaks.
I am pretty sure this will run well.

A couple of caveats:

(1) I would make sure your household knows to close it properly after gathering up the mail. Otherwise, it won’t work the following day. (I used to keep a motion detector on the back wall (instead of a contact sensor) to circumvent this issue)

(2) If there is ever a day with a full mailbox where nobody gathers it up, then it will not trigger the next day… (although it will reset itself if the mail person closes it properly on the following day)

(3) If you happen to gather the mail in under 2 minutes, it will not reset itself either.
(I would lower that 2 min delay to something like 45 seconds at most)


#9

Thanks, I’ll give it a look and test when I get home tonight.


#10

I programmed this in. Well let it run and see how it does. Hopefully these variables will get set. I’m going to modify my original to use a virtual switch as the Boolean control and see how that works too.


#11

Okay just to report back,

I tried the above code and it also had issues setting the variables after the wait time.
So I then created a virtual switch and used that instead of a variable. The piston would NOT set the switch to on after a wait period.

I then tried several other variations of code , none would work and I could not get Webcore to return after the wait and set a variable. Or turn on a switch or whatever. I’m sure there is an obvious reason but I don’t know what it is.

I have come up with a work around that I use in another piston I am running to set time and trigger something at that time. So below is the image of the latest piston that I am testing. It appears to work in my test but will have to let it run on it’s own some to see if it consistently works.

If this indeed works I’ll come back and mark this as complete.

Thanks everyone for your help and trying to find a solution.

I still don’t understand why Webcore would not return from a 5 minute wait and set a variable or turn on a switch?


#12

Had a similar issue with motion lights. It’s because your trigger is “contact changed to open” after the mailman closes the mailbox it changes to closed, this makes your piston false. You get the notification before the piston is negated. Turn on logging on the piston and you will see a message saying scheduled actions canceled.


#13

This would accomplish what your wanting I believe. First time the sensor is opened, you’ll get a notification. Next opening, or at midnight, it’ll reset.


#14

Here accomplishes everything yours did, including the reminder at 9:30.


#15

Thank you for the explanation.

I thought there was a setting to prevent this, so the puston would continue. I can’t seem to find it.

Again thanks


#16

Task cancellation policy. Click your IF statement, then the gear icon at the bottom. Didn’t help in my situation and don’t believe it will in yours. Someone correct me if I’m wrong here, but I believe it is for a nested IF statement. So if the parent is false, the nested still completes. Since you have no nested IF, TCP won’t help. At least that was my results when my piston was behaving exactly as yours is.


#17

Thanks again for the great explanation, and where it’s located.
I do appreciate your replies. I’ll have a look later but I’m sure your right.


#18

Here’s a related explanation that shows why your original piston wasn’t working. Hope this is helpful!


#19

Thank you


#20

I tried this piston with a motion sensor. It fires on the first statement. But it doesn’t set the variable from 0 to 1 to check the 2nd statement. Anyone have any ideas why it’s not able to set the variable?