Closed door notification

MyDoorOpener custom/homebrew "Arduino" backend enhancements sharing and discussions.

Closed door notification

Postby rpuas » Wed Oct 16, 2013 3:31 am

After finally connecting & configuring a magnetic switch for my door, I was able to configure the push notifications.
I find the Open & Watchguard notifications very useful, but I found that I needed a closed notification as well.
So I copied the code for the Open notification and modified it to return a Close notification.

In keeping with the existing format, I added a define to the Notifications section.....

//*******************************************************************
// Notifications
//*******************************************************************

// if defined, will fire a notification when any door/device stays open more than the specified number of minutes
#define NOTIFICATIONS_WATCHDOG_MINUTES 20

// if defined, will fire a notification every time and as soon as any door/device gets opened
#define NOTIFICATIONS_OPEN

// if defined, will fire a notification every time and as soon as any door/device gets closed
#define NOTIFICATIONS_CLOSED


...and added the modified Closed notification handler right after the Open notification handler...

if (!openDetected)
{
notificationSent = false;
delay(500);
}
}

#endif

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
#if defined(NOTIFICATIONS_CLOSED)

//----------------------------------------------------------------------------------------------------
void closedNotificationsHandler()
{
static boolean notificationSent = false;
boolean closeDetected = false;

for (int i = 0; i < sizeof(statusPins); ++i)
{
if (!isOpen(statusPins[i]))
{
#if defined(NOTIFICATIONS_SERIAL_DEBUGGING)
Serial.print(F("*** closed notification handler - detected a closed device/door @ pin #"));
Serial.print(statusPins[i]);
Serial.println(F(" ***"));
#endif

if (!notificationSent)
{
#if defined(NOTIFICATIONS_SERIAL_DEBUGGING)
Serial.println(F("*** closed notification handler - sending notification ***"));
#endif

char subject[] = "Closed Notification";
char body[] = "The garage door has just been closed.";

#if defined(PUSH_NOTIFICATIONS)
notifyViaPush(subject, body);
#endif

#if defined(SMS_NOTIFICATIONS)
notifyViaSms(subject, body);
#endif

#if defined(SMTP_NOTIFICATIONS)
notifyViaEmail(subject, body);
#endif

notificationSent = true;
}
else
{
#if defined(NOTIFICATIONS_SERIAL_DEBUGGING)
Serial.println(F("*** closed notification handler - NOT sending notification ***"));
#endif
}

closeDetected = true;
break;
}
}

// if all door/devices are open, reset notificationSent semaphore so that further notifications
// can be sent. This is done to avoid flooding recipient with notifications for a same event occurrence.

if (!closeDetected)
{
notificationSent = false;
delay(500);
}
}

#endif

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

void setup()
{


Note that I changed the char subject [] to "Closed Notification", and did the same for "Open Notification" & "Watchguard Notification" in the corresponding handlers. Makes it easier to read through notifications on Prowl app.

Finally, I added a call to the Closed Notification handler in the loop...

void loop()
{
char buffer[200];
int len = sizeof(buffer);

webserver.processConnection(buffer, &len);

#if defined(NOTIFICATIONS_WATCHDOG_MINUTES)
watchDogNotificationsHandler();
#endif

#if defined(NOTIFICATIONS_OPEN)
openNotificationsHandler();
#endif

#if defined(NOTIFICATIONS_CLOSED)
closedNotificationsHandler();
#endif

}
rpuas
 
Posts: 4
Joined: Sat Sep 28, 2013 6:17 pm

Re: Closed door notification

Postby support » Wed Oct 16, 2013 9:58 pm

Thanks for sharing!
support
Site Admin
 
Posts: 384
Joined: Thu Aug 22, 2013 7:30 pm

Re: Closed door notification

Postby dave » Sat Aug 23, 2014 10:21 pm

Thank you so much! I have been wanting to have this function for ages!!
dave
 
Posts: 1
Joined: Sat Aug 23, 2014 6:23 pm

Re: Closed door notification

Postby V8mgb » Sun Nov 30, 2014 12:09 am

I was just thinking of adding this feature and came across your post. A little careful cut and paste is all it took. Thanks, works great!
V8mgb
 
Posts: 3
Joined: Sat Nov 29, 2014 4:34 pm

Re: Closed door notification

Postby aurelutz2007 » Sat Nov 21, 2015 8:59 am

I got it also working, but not the way I wanted...
For the moment I have one gate and one garage, each with a magnetic sensor attached and I wanted to have the open/close notification independent working (get a message for gate open/close and for garage open/close).

Now is just fire an open notification when gate or garage was opened, but not for both on the same time.
And the close notification is sent only if both garage and gate were opened. If I only open the garage for example, I get open notification, but when closing it I'm getting no notification.

Can someone help me with that?
aurelutz2007
 
Posts: 22
Joined: Mon Feb 24, 2014 1:06 pm


Return to Arduino Backend Enhancements



cron