Programatically disabling filter/emails

Forum for questions and support relating to the 1.25.x releases only.
Locked
frankster
Posts: 8
Joined: Mon Apr 30, 2012 8:03 am

Programatically disabling filter/emails

Post 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.
frankster
Posts: 8
Joined: Mon Apr 30, 2012 8:03 am

Re: Programatically disabling filter/emails

Post 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.
Christo
Posts: 89
Joined: Wed Feb 01, 2012 9:48 pm

Re: Programatically disabling filter/emails

Post 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!!!
Christo
Posts: 89
Joined: Wed Feb 01, 2012 9:48 pm

Re: Programatically disabling filter/emails

Post 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
Attachments
Motion Filter Weekdays.jpg
Motion Filter Weekdays.jpg (120.28 KiB) Viewed 3124 times
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Programatically disabling filter/emails

Post 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.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
frankster
Posts: 8
Joined: Mon Apr 30, 2012 8:03 am

Re: Programatically disabling filter/emails

Post 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.
Locked