Page 1 of 1

Programatically disabling filter/emails

Posted: Wed May 16, 2012 3:09 pm
by frankster
I've got zoneminder setup to email every time it detects an event. When we're at home during the day it generates a lot of emails. So I have been trying to find a way to automatically disable these emails when I am in the house based on whether certain devices are attached to the wifi.

So to do this I either need to disable the configuration setting that enables sending emails or I need to disable the filter that the emails use. Has anyone done this before? My current line of thinking is that I could knock something up via Ruby::Mechanise or similar.

Re: Programatically disabling filter/emails

Posted: Thu Jun 21, 2012 11:46 am
by frankster
So I've made a programme which can detect if either my or my gf's smartphone is on the wifi network (by screenscraping my router), and then I made the script directly update the Filters table in the database to enable/disable sending emails for the filter.

Unfortunately, from my testing this morning, two minutes after I left the house I received about twenty alert emails relating to events over the previous 2 hours! So it seems as if an email sent flag gets stored on each event, then if the filter has emails enabled then it sends emails for any event that hasn't already had an email sent (though I've not checked the code so I could be wrong). If this is correct and you switched on email notifications for an old filter, you might suddenly get thousands of emails...could be a problem.

Maybe a better approach for me is to set up an email alias that forwards emails if we're out, and dumps the emails if we're in.

Re: Programatically disabling filter/emails

Posted: Thu Jun 21, 2012 8:53 pm
by Christo
Hi frankster,

I have just read your post and just wondered why you took the hardway to solve this issue?

I assume that there is a pattern for you being at home, so why not use the filter option to get E-mails when your from home?

This option works great, but if you still like to solve it the hardway.. search within previous post for a scrip such as Host Check.

Success!!!

Re: Programatically disabling filter/emails

Posted: Sun Jun 24, 2012 7:41 am
by Christo
Hello frankster,

Because a picture can tell so much more... I have added a screenshot of a filter I use to get the alerts (E-mails).

Regards, Christo

Re: Programatically disabling filter/emails

Posted: Sun Jun 24, 2012 6:10 pm
by knight-of-ni
Rather than have Zoneminder send the e-mail, have Zoneminder execute a script instead.
In the script, add the desired conditions.

You could continue to use a scrape to get the device's ip address or have your dhcp server auto-add a dns entry each time it shows up on your wifi. Either way, you could then put in the appropraite logic to send an e-mail only if a ping is not returned.

Re: Programatically disabling filter/emails

Posted: Wed Jun 27, 2012 12:27 pm
by frankster
Ah Christo now I see your picture I understand your previous post! but my comings and goings are not so predictable - thanks for the idea though.

knnniggett - good idea, I like the feature of email that includes a link to the event that triggered...I will see if this is possible via a script.