zmtrigger error

Forum for questions and support relating to the 1.28.x releases only.
Locked
doppiaemme
Posts: 3
Joined: Thu Nov 12, 2015 5:46 pm

zmtrigger error

Post by doppiaemme »

Hi,

I'm having an issue I can't troubleshoot when using zmtrigger.
This is the error I get when I try to send a random text to a monitor (I've added the %Q already in the timestamp label already).

9328 WAR Can't find monitor '1' for message '1|show||||text' zmtrigger.pl

Any idea?

thanks
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmtrigger error

Post by asker »

Not quite sure how you are accessing it - you need to provide more details of how you are connecting.

Do this simple test:

Code: Select all

telnet <server IP where ZM is running> 6802
Now once you are connected, simply type in

Code: Select all

1|show||||70 degrees
And if you have put in a %Q in your timestamp for the monitor Id, you will see it there like this:
Screen Shot 2015-11-12 at 4.16.21 PM.png
Screen Shot 2015-11-12 at 4.16.21 PM.png (110.96 KiB) Viewed 3893 times
Note: There are no quotation marks around the command and I assume monitor 1 (id=1, not name) exists
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
doppiaemme
Posts: 3
Joined: Thu Nov 12, 2015 5:46 pm

Re: zmtrigger error

Post by doppiaemme »

Hi asker

I've just found out the issue, silly one, the camera was in monitor mode while it seems to work only in Nodect mode.
But this opens up another issue, I can't do what I wanted.
My aim was to link ZM with the home automation system so that when I arm the alarm, it sends a command to ZM to start doing motion detection.
but in Nodect mode I cannot do this.
Any suggestion of a different way?
rockedge
Posts: 1173
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: zmtrigger error

Post by rockedge »

You can set up then save Run States that can be activated by calling zmpkg.pl.
set up all the motion detection then save as AlarmArmed. Then call from the command line

Code: Select all

zmpkg.pl AlarmArmed
Zoneminder will start into that Run State you saved turning on the Modect for the cameras you have selected. This is documented in
https://wiki.zoneminder.com/FAQ#How_can ... or_week.3F
Does your home automation utilize X10?
doppiaemme
Posts: 3
Joined: Thu Nov 12, 2015 5:46 pm

Re: zmtrigger error

Post by doppiaemme »

It seems I can't find this one FAQ in the page you linked (https://www.mediawiki.org/wiki/Manual:FAQ)...??

the system I use (homeseer) can work with several protocols, provided you have the right interface for it. I'm using Z-Wave but yes X10 is another popular one. I've read ZM integrates with X10 and XAP.
Is there a big advantage with using X10? I could do that but I'm not really excited as I would need an X10 interface on both sides, using probably either USB or serial, while everything else is IP etc etc.

What I need is also is to trigger the home automation system when there's a motion detection alarm.
rockedge
Posts: 1173
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: zmtrigger error

Post by rockedge »

I have X10 ActiveHome Active Eye Indoor/Outdoor Motion Sensors MS16A setup which do the motion detection instead of using the camera motion detection analysis, saving CPU cycles and work in the dark.Motion detected ZoneMinder begins recording the Event.

I am using a CM19a USB Transceiver to send/receive X10 to/from the ZoneMinder PC. I skipped trying to use the built in X10 and wrote a really small simple daemon in PERL that polls the CM19a driver then calls a PHP script when needed.There are many possibilities of achieving what your looking to do.

http://www.cuddon.net/2015/04/python-x1 ... tware.html


the PERL daemon:

Code: Select all

#!/usr/bin/perl -w

use strict;
use Proc::Daemon;
my $continue = 1;
Proc::Daemon::Init;
$SIG{TERM} = sub { $continue = 0 };

open(STDOUT, ">/var/log/cm19a/cm19a.log") or die $!;
   print localtime()." Started zmusb3\r\n";

#  my $url = 'http://192.168.1.3:8008/?house=A&unit=1&command=ON';

  my $url = 'http://localhost:8008/?command=getqueue';
  my $cmdurlon = 'http://localhost/zm/monckusb.php?extTrigger=ON';
  my $cmdurloff = 'http://localhost/zm/monckusb.php?extTrigger=OFF';
 
while($continue)
 
 {
    my $html = qx{curl --silent $url};
   if ($html !~ /Receive queue is empty/ ) {
        if ($html =~ /A1ON/) {
          my $htmlcmd = qx{curl --silent $cmdurlon};
        }
         if ($html =~ /A1OFF/) {
          my $htmlcmd = qx{curl --silent $cmdurloff};
         }
   
   print localtime()." $html\r";

}

}
   print localtime()." Stopped zmusb3\r\n";
this calls a small PHP script that then sends a command to zmTrigger.pl

Code: Select all

<?php
// monckusb.php

   $extTrigger = $_REQUEST['extTrigger'];
   $cfgServer = "localhost";
   $cfgPort = 6802;
#   $cfgTimeOut = 10;
if ($extTrigger == "ON") {
    $extTriggerx = "1|on|255|Motion Sensor|downstairs|";
}else{
	$extTriggerx = "1|off|0|Motion Sensor|downstairs|";
}
echo 
$conn_handle = fsockopen($cfgServer, $cfgPort);
 if(!$conn_handle) {
        echo "Connection failed ";
   exit();
    }else{
      //  echo "Connected <br>";
        fputs($conn_handle, $extTriggerx);
    }  
fclose($conn_handle);   
//   echo $extTrigger;

?>
this script is modified for tests but can give you an idea how to send/transmit a code from ZoneMinder to other devices or systems.

Code: Select all

#!/bin/bash
#
# Turn lights on when ZM starts recording an event and turn off when ZM stops.
# Or do whatever such as trigger sirens, blink lights, text-to-speech, etc.
#
# Monitor output from zmtrigger.pl. When ZM starts recording an event
# zmtrigger.pl outputs a line like this where the first parameter is the
# camera number.
# 2|on|1300323788|298
#
# When ZM stops recording an event zmtrigger.pl outputs a line like this.
# 2|off|1300323801|298
#
# The following table shows the 5 sample ZM cameras and corresponding 
# X10 commands to control lights. mochad is used in this example to turn 
# lights on/off but heyu or br or any other command line program.
#
# Location Cam  Command
# Garage    1   pl b2
# Kitchen   2   pl b1
# Test      3
# Living    4   pl b1
# Front Dr  5   pl b1
# 
LIGHT[1]="A4 LIGHT"
LIGHT[2]="A5 LIGHT"
LIGHT[3]="rf A6 LIGHT"
LIGHT[4]="rf b1"
LIGHT[5]="rf b1"
LIGHT[9]="A9 LIGHT"

# mochad listens on this host and port
#MOCHADHOST=192.168.1.254
#MOCHADPORT=1099

# zmtrigger.pl listens on this host and port
ZMHOST=192.168.0.14
#ZMHOST=localhost
ZMPORT=6802
CURL='/usr/bin/curl'
# RVMHTTP="http://localhost:8008/?house=A&unit=1&command=ON"
# OFFHTTP="http://localhost:8008/?house=A&unit=1&command=OFF"
RVMHTTP="http://192.168.0.14:8008/?house=A&unit=1&command=ON"
OFFHTTP="http://192.168.0.14:8008/?house=A&unit=1&command=OFF"
CURLARGS="-f -s -S -k"
# Connect TCP socket to ZoneMinder zmtrigger.pl
exec 6<>/dev/tcp/${ZMHOST}/${ZMPORT}

# Read ZM events from zmtrigger.pl
while read <&6
do
    # Show the line on standard output just for debugging.
    echo "${REPLY}" >&1
    case "${REPLY}" in
        *\|on\|*)
            CAM=${REPLY%%|*}        # extract camera number
            cmd=${LIGHT[${CAM}]}    # get the X10 command
            if [ "x${cmd}" != "x" ]
            then
#               echo "${cmd} on" >/dev/tcp/${MOCHADHOST}/${MOCHADPORT}
                echo "${cmd} on"
                raw="$($CURL $CURLARGS $RVMHTTP)"
                echo $raw
            fi
            ;;
        *\|off\|*)
            CAM=${REPLY%%|*}        # extract camera number
            cmd=${LIGHT[${CAM}]}    # get the X10 command
            if [ "x${cmd}" != "x" ]
            then
#                echo "${cmd} off" >/dev/tcp/${MOCHADHOST}/${MOCHADPORT}
                 echo "${cmd} off" 
                 raw="$($CURL $CURLARGS $OFFHTTP)"
                 echo $raw
            fi
            ;;
    esac
done  
SteveGilvarry
Posts: 494
Joined: Sun Jun 29, 2014 1:12 pm
Location: Melbourne, AU

Re: zmtrigger error

Post by SteveGilvarry »

Like rockedge said lots of ways to do it using ZoneMinder Perl API you could do all you need.
1. Trigger Home Automation when you have motion detection. https://wiki.zoneminder.com/FAQ#How_can ... n_alarm.3F

2. I think zmMonitorEnable and zmMonitorDisable is the normal way people enable and disable cameras. Sorry don't have a script for you.
https://github.com/ZoneMinder/ZoneMinde ... pm.in#L654

And rockedge you could trigger from your perl also, unless your php is doing something else.
Production Zoneminder 1.37.x (Living dangerously)
Random Selection of Cameras (Dahua and Hikvision)
Locked