Run piston every hour and notify if open for second time


#1

I need to know the best way to run a piston every hour if after 8am.
I was thinking:

Piston Do Every Hour
If Time after 8am
Then DO X
Wait 1 hour
Execute piston Piston Do Every Hour

Then for a mailbox, I want to know how many times it was open during the day.
So if mailbox opens for first time today, PUSH notification, "You have mail"
If it opens again, PUSH notification, “Someone got the mail”


#2

What do you have on your mailbox? Rather than doing a hourly check, you could do real time since it sounds like you have an open/closed sensor on it.

Define Variables

Date (integer)
Openings (integer)

IF
Mail box changes to open
THEN
IF Date is different than $day
AND Time is between 8am and whatever cutoff time you want
THEN
Set variable Openings = 1 (resets the count to 1 whenever if it’s the first time it was opened today)
Set variable Date = $day
Push Message (set message contents as an expression) Openings = 1 ? “You’ve Got Mail” : “Someone got the mail”
Else
Set variable Count = {Count} +1
Push Message (set message contents as an expression) Openings >2 ? “Someone got the mail… again” : “Someone got the mail”


#3

Thanks.
Having a hard time replicating it though. I think my variables were getting messed but you gave me an idea.
Does the piston below work?
Also, the piston running every hour is something different. I need a switch to turn on every hour, how would I do that?


#4

Try this one for your mailbox. I’ll write up a timer example next.


#5

And here is a timer. Just open the timer condition and choose the hours you want it to execute.

If you need it to be at the top of the hour (x:00) we can do it that way but the one below may or may not. It should.


#7

Than you -

I made a change to do something else. I didn’t know that Timer section existed.


#8

No problem! Does the mailbox one make sense?


#9

Yes - I got that loaded up today. Thanks again