Page 1 of 1

Alarm Audio Per Zone on Server

Posted: Sat Apr 12, 2008 2:45 pm
by roach
An alarm audio that sounds on the server rather than through the web interface as it currently is.

Ability to assign a different alarm audio file to each camera. Ability to have no sound on some cameras and sound on others. All server side.

Posted: Sun Apr 13, 2008 8:37 pm
by zoneminder
Good suggestions here. We have discussed using something like 'beep' on the server but many machines just don't have audio hardware, even to make a beep, on any more, or don't support the interface. If you have hardware that does then using a trigger script (a la zmtrigger) to listen out for alarms and make the noises is relatively simple to set up.

Posted: Thu Jun 19, 2008 9:16 pm
by ktheking
Hence the reason why a microcontroller for ZM is needed. (still nothing there :oops: ,didn't get it running yet)

Posted: Sun Jun 22, 2008 10:22 am
by robi
Most mobos have onboard soundcards, and every mobo has pc speaker, for bios beeps.

Posted: Mon May 04, 2009 3:26 pm
by ma6inista
Why don't you just use the script below and make your PC speaker beeps on every alarm?

Code: Select all

#!/usr/bin/perl -w

use strict;

use ZoneMinder;

$| = 1;

zmDbgInit( "myscript", level=>0, to_log=>0, to_syslog=>0, to_term=>1 );

my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS );

my $sql = "select M.*, max(E.Id) as LastEventId from Monitors as M left join Events as E on M.Id = E.MonitorId where M.Function != 'None' group by 
(M.Id)";
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );

my $res = $sth->execute() or die( "Can't execute '$sql': ".$sth->errstr() );
my @monitors;
while ( my $monitor = $sth->fetchrow_hashref() )
{
    push( @monitors, $monitor );
}

while( 1 )
{
    foreach my $monitor ( @monitors )
    {
        next if ( !zmShmVerify( $monitor ) );

        if ( my $last_event_id = zmHasAlarmed( $monitor, $monitor->{LastEventId} ) )
        {
            $monitor->{LastEventId} = $last_event_id;
            print( "Monitor ".$monitor->{Name}." has alarmed\n" );
            print ( `echo -e "\a" > /dev/console` );
            sleep( 5 );
            
            
        }
    }
    sleep( 5 );
}
It worked for me for a while until I moved the server to another room. Then I used "smbclient" to send a popup message to my Windows desktop by adding this

Code: Select all

 print ( `echo '$monitor->{Name} has alarmed' | smbclient -M office_desktop` );
Works like a charm, the server still beeps in the computer room and I get a pop up message on my office machine for every alarm.

Posted: Sun Jan 30, 2011 5:40 pm
by insippo
where you to save this script? I have debian lenny for zoneminder

Posted: Thu Feb 17, 2011 8:12 pm
by wkulecz
insippo wrote:where you to save this script? I have debian lenny for zoneminder
My question too.

Also what defines zmHasAlarmed? One alarm frame?

In a Mdetect event I often see only 10% of the frames are alarm frames so I filter on number of alarm frames before sending an Email of the event, is the zmHasAlarmed tied to one per event or if the event has multiple bursts of alarm frames would I get multiple zmHasAlarmed true? Is the sleep(5) a kludge around this issue?

I'd like this to be a minimum number of alarm frames before declaring it an "event" worthy of barking at me.

What if I set to_term=>1 to be 0 instead and remove the print statements, would this make it a daemon scrip running in the background?

Its nice to have a perl "API" but without a bit of useful documentation (examples are the *best* documentation) its asking a lot to know enough perl to figure out what the API is doing before being able to use it.