PLEG Example - Detect Door Left Open with Repeated Notifications

@Camilo has asked how to send a notification if a door was left open and repeat until the door is closed.

This is a common scenario so I thought I would document the solution here.
NOTE: I use BOLD to describe names or values I use in this example. You can change at your discretion.
[hr]
A PLEG Instance called: Repeat Notification Example
The Attached pictures show the setup:
Inputs:
DoorOpen bound to the Door Sensor that triggers when it is opened
Conditions:
DoorLeftOpen = DoorOpen AND (DoorOpen; NOW > 5:00)
LeftOpenRepeat = DoorLeftOpen AND ((LeftOpenRepeat; DoorOpen) OR (LeftOpenRepeat; NOW > 5:00))
Notification:
When Repeat Notification Example has satisfied condition LeftOpenRepeat.

You can also attach actions to the above conditions if you want to do more than just send a notification.

In this example I am using a 5 minute (5:00) delay. This is in both conditions.
You can have a different delay for the first notification and the repeat notifications.
[hr]
How it works:

[ul][li]The condition DoorLeftOpen will trigger when the Door is Left Open for the specified interval.
It will only trigger once after the door is open. So this does not help with a repeated notification.[/li]
[li]The conditon LeftOpenRepeat will trigger immediately when the previous condition becomes true.
This is because the following is true:
DoorLeftOpen AND (LeftOpenRepeat; DoorOpen)
The second part is true because the Door was opened after the last time this condition was true.
So both conditions will trigger sequentially at the same time. We will hook our notification up to the LeftOpenRepeat condition.[/li]
[li]The use of NOW will cause these conditions to be evaluated every minute.
[list]
[li]The LeftOpenRepeat condition will then turn to false when NOW is evaluated within the next minute.
This is because during this period both of the following conditions are false
(LeftOpenRepeat; DoorOpen)
This is false because the Last occurrence of LeftOpenRepeat was after DoorOpen
(LeftOpenRepeat; NOW > 5:00)
This is false because it has not been 5 minutes since the last time LeftOpenRepeat was true.[/li]
[li]It will remain false until NOW is evaluated 5 minutes later and finds the DoorLeftOpen condition is still active. At that time the following will be true:
(LeftOpenRepeat; NOW > 5:00)
This will cause another notification of LeftOpenRepeat condition.
[/list]
And the cycle repeats as long as DoorOpen is left open.[/li][/ul]

[hr]
Some additional notes about the Notification Tab for the Repeat Notification Example device.

[ul][li]Note1: The first notification is actually the input triggers. Do not mess with this or it will delete your input triggers! This is only there if you have Input Triggers![/li]
[li]Note2: This is the actual Notification. I use the Vera Alerts Plugin to send this to my Android device. You can also have it email/sms you via MCV notifications[/li][/ul]

Thanks for this writeup - and for the plugins. This is exactly what I needed.
Two additional questions though:
-How do I tag this to a scene? Say I kick off a scene ‘Away from Home’ and I only want the notifications if the scene is active.
-Another use case is to monitor doors/windows when the A/C is on. So how do I tag this to when Thermostat is NOT idle?

I have small kids that leave doors open and a wife that forgets the garage door open. Monitoring and notification of open doors in specific scenarios is invaluable!

Thanks for your help I have been trying, but have not been able to get it working. Keep getting invalid token

Program Logic : DoorLeftOpen AND ((LeftOpenRepeat; DoorOpen) OR (LeftOpenRepeat; NOW > 5:00)): Invalid Value token: DOORLEFTOPEN

Thanks
Camilo

If you have an older version of the Plugin installed … you can’t reference another condition variable.

Running latest 2.1

Did you make sure the first condition DoorLeftOpen is defined and spelled correctly ?
Can you send a snap shot of your conditions tab.

hello
I use these reminders successfully by cons I would like a reminder to prowl for ios or android veralert which indicates lastrip because I have a fixed message that says gate open for 30 minutes each reminder
is it feasible to have 30 minutes and 1 hour and then 1:30 etc …
with variable lastrip can not be?

thank you again for this great plugin that aisni veralert is great too :wink:

If you use the Vera Alerts Plugin you can can use the following text template:

Device 53 last trip on {DateTime({device([53].service[urn:micasaverde-com:serviceId:SecuritySensor1].LastTrip)}, %A %B %d %Y %H:%M)}

This will be displayed as:

Device 53 last trip on Thursday March 14 2013 14:52

[quote=“RichardTSchaefer, post:8, topic:174490”]If you use the Vera Alerts Plugin you can can use the following text template:

Device 53 last trip on {DateTime({device([53].service[urn:micasaverde-com:serviceId:SecuritySensor1].LastTrip)}, %A %B %d %Y %H:%M)}

This will be displayed as:

Device 53 last trip on Thursday March 14 2013 14:52[/quote]

ok thank you I’ll try and prowl you have an idea?

You can use Vera Alerts to forward the Notifications to your prowl plugin.
The Vera Alerts template will expand the text template before forwarding.

[quote=“RichardTSchaefer, post:10, topic:174490”]You can use Vera Alerts to forward the Notifications to your prowl plugin.
The Vera Alerts template will expand the text template before forwarding.[/quote]

thank you Richard

you have an example of this is our prowl with push notification and it is valid for all notifications or just the one I want?

good day

i have configured the plugin forward with pushnotification but how i can sent to my iphone ?

i use my doorsensor as alarm too so when i set scene alarm on it while this door open loop is running for open door, would it confuse eachother ?

you have an example of this is our prowl with push notification and it is valid for all notifications or just the one I want?

i have configured the plugin forward with pushnotification but how i can sent to my iphone ?


This should be able to handle ANY notification in Vera.

  1. Make sure the forward works.
    In Vera Alerts Control Tab → Send-Alert
    Recipient: Forward
    Msg: A Test Message
    Send - This should get sent to your Prowl device if setup properly.
  2. Add a Notification or SendAlert action from Scene or PLEG Action.
  3. Goto VeraAlerts Tab → Notification Configuration
    Configure your userid to have a Vera Alerts Recipient of Forward.
    Save Configuration.

Anytime you change any Notification in Vera … Add/Delete/change destination … open the last tab … and save.

In that same tab you can override the default notification message using the template example I provided.

[quote=“RichardTSchaefer, post:13, topic:174490”]

you have an example of this is our prowl with push notification and it is valid for all notifications or just the one I want?

i have configured the plugin forward with pushnotification but how i can sent to my iphone ?


This should be able to handle ANY notification in Vera.

  1. Make sure the forward works.
    In Vera Alerts Control Tab → Send-Alert
    Recipient: Forward
    Msg: A Test Message
    Send - This should get sent to your Prowl device if setup properly.
  2. Add a Notification or SendAlert action from Scene or PLEG Action.
  3. Goto VeraAlerts Tab → Notification Configuration
    Configure your userid to have a Vera Alerts Recipient of Forward.
    Save Configuration.

Anytime you change any Notification in Vera … Add/Delete/change destination … open the last tab … and save.

In that same tab you can override the default notification message using the template example I provided.[/quote]

Very good job it’s wonderful

many thanks

just a little last thing
to change the name of the event in prowl with veraalert I can not do what is the syntax
thank you
i have
luup.call_action(“urn:richardgreen:serviceId:VeraAlert1”, “SendAlert”,
{Message = " {DateTime({device([59].service[urn:micasaverde-com:serviceId:SecuritySensor1].LastTrip)}, %A %B %d %Y %H:%M)}", Recipients = “Forward” , Event = “{Garage}”}, 126)

my config

Plugin Args: Event=“{Name}”,Description=“{Message}”,Priority=1,URL=“”

many thanks

I will make a change to my Plugin to pass on any extra args when I forward.

thank you very much
your work is fantastic

yes thank you for this example.
allthough i have the plugin installed, i have not made use of it yet. i can use this example for my refridgerator-door sensor so im gonna use it.
also considering using it for my rear window.
could also use it in reverse so it would notify if a door is left closed. (i hate closed doors)

I think I followed your guide to the tee but im still getting the same token error as well. Any Ideas?

Running PLEG 4.4/PLC 4.4/Program Logic Time Switch 4.4. Vera 1.5.622

In your first condition statement (DoorLeftOpen), remove the DoorLeftOpen = from the left. It should read:

DoorOpen AND (DoorOpen; Now > 5:00)

Thanks, I caught that and posted the wrong screenshot. With that fixed the message goes away but I receive the alert @ 5 mins but never a repeat follow up alert.