Mailbox piston, Need another set of eyes to help me


#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?


#21

Post the green snapshots only. For your piston, change the variable value to ‘nothing selected’. Right now each time the piston triggers it will be set to 0.


#22

I originally had that… Doesn’t run at all when I select “nothing selected“ for mail variable… When I set the value to 0, it runs but overwrite/save the variable.


#23

You might get more joy by defining your variable as a boolean and using true and false values. A variable that isn’t initialised will evaluate as false which should then get your piston going.

You can, of course, manually set the variable outside the piston but that’s not ideal as you’d have to do it every time you restarted it. I just mention that as an aside.


#24

Re-did it. Do I still leave the variable as nothing selected for initial value? Or do I set it to value and false?


#25

When you give a variable an initial value it is used every time the piston runs which isn’t what you want. You want the Mail variable to keep its value until you change it.

I should also point out that if you have kept the original structure the piston will detect motion, set the Mail variable in the first if block, and then promptly change it back again in the second one as changes to active is still true.

You really want to run either the first or second if block. So you might want to create a nested structure

If motion changes
Then
  If Mail is false
        ...
  Else
        ...
  End If
End If

I do note you have the break commands which might seem like they’d avoid the above problem. However as far as I know those will just break out of the current if block so they effectively do nothing. Using exit might be more fruitful if you prefer that structure.