Alert when door sensor is tripped, then wait 2 minutes before alerting again


#1

I’ve attempted to follow other examples, however I’m just not getting there.

I’m not really up on the type of variables used in Webcore but I tried.

It appears to me, with Trace on, that the Piston gets to the 2 minute wait. However, as soon as it triggers again it cancels the wait and cycles again.

Am I using the wrong variable?


#2

There are many ways to do this. I would not use a variable here. I would code this as follows…

    IF Contact Sensor 2's contact changes to open
    Then
      With Presence Sensor 1
        Do
          Send PUSH notification "Back Door is Open"
      END With
      With Location          (Set TCP to NEVER here)
        Wait 2 minutes
      END With
      With Presence Sensor 1
        Do
          Send PUSH notification "Back Door is Open"
      END With
    END IF

If you do not want to be notified the second time (if the contact sensor is closed), then it will have to be coded differently.


#3

I’m a complete newbie here, you’ve lost me.

Is the “With Location” and the second “With Presence Sensor 1” new IF statements?

What is TCP?

I only want to be notified when the door is opened, not closed. Repeat notification should only occur after a 2 minute timeout. I want to be alerted when someone comes in, however if the wife goes in and our carrying groceries the repeat notifications will drive me nutz!

Thanks,

Dave


#4

Sorry for throwing you in the deep end. :slight_smile:
Load this piston using the code “simy” and take a look at it in edit mode.

WAIT statements can be quite confusing/frustrating in webcore. Many of us here struggle with them, myself included. If the status of your trigger device (your Contact Sensor 2) changes at all (ie from open to closed) during the 2 minutes WAIT, then the piston halts there and starts execution from the beginning again. That can sometimes work in your favor. In order to keep that from happening, the TCP (Task Cancellation Policy) must be set to NEVER. Search the webcore forum on TCP for lots more information.

The piston I have suggested above will send a PUSH notification if the porch door is opened. It will wait 2 minutes. Then it will check and see if the porch door is still open. If so, it will send a PUSH notification a second time.


#5

Nope. Alerts every time I open the door.

Other examples use variables instead of a timer, I just don’t know what type of variable to use?

Dave


#6

Make sure to enable Drag & Drop to see the TCP setting on the WAIT.

Try this one…


#7

Still alerts every time.


#8

Try setting the TCP to NEVER on the very first IF.


#9

Still alerts. I clicked on the first IF and set it to Never.

Let me repeat my goal just to make sure I was clear.

The door will open and most likely immediately close. I want an alert.
If the door opens and closes withing a 2 minute period I do not want an alert.
After 2 minutes start the process over again.

Thanks,


#10

Yes, I just tested my last piston and it did not work. Sorry. Give me a minute…


#11

A couple issues. You don’t want to set the value of the boolean in the define statement at top as that sets it every time the piston runs. That is why it alerts every time. Try this one:


#12

As others mentioned there are many ways to do this, I prefer not to use waits. Here is how I would do it. I think this should work.


#13

Sorry to jump in…

I can offer you 2 pistons solution… may not be the best way but try it.

@Boolean : dooropen

Piston 1 - DOOR OPEN
IF door sensor changes to OPEN 
AND
IF @dooropen is true
Then 
Send message *door opened*

Other piston is:

IF @dooropen changes to TRUE
Wait 2 minutes
Set @dooropen to FALSE

#14

@guxdude, @Terminal, @ike2018 Thanks for bailing me out guys. I just could not get the logic correct here. However, can someone explain why the following did not work?

With TCP set at the WAIT, I THOUGHT that the piston would pause until the WAIT was over, even if the contact changed state. But it appears that the piston ran from the top each time the door was open, even if it were less than 2 minutes.


#15

did you have TCP set to NEVER


#17

Yes. At the WAIT.


#18

It used to be that way I guess… But maybe some pros can explain this, it is different now.


#19

In this case, I believe the wait sets up another execution in 2 minutes and TCP makes sure that will run but it does not stop the piston from running again in the interim.


#20

That would suggest that you could have multiples of the same piston running in a stack, so to speak.


#21

Would seem that way. In pistons like my arrival piston, I add a ‘cancel all pending tasks’ to make sure things don’t stack up.