Page 1 of 1

Zoneminder send alarm events to XBMC

Posted: Mon Feb 04, 2013 3:51 am
by Dre
I would like to have zoneminder when detect a motion would send the image through URL to XBMC and will popup a window with image , camera name and time stamp, I would realy love to get that done

Re: Zoneminder send alarm events to XBMC

Posted: Wed Feb 06, 2013 3:36 pm
by mrd
I like this idea... I will look at what it takes to make it work maybe...

Re: Zoneminder send alarm events to XBMC

Posted: Wed Feb 06, 2013 7:50 pm
by jameswilson
Myth had or even has a similar feature. GUess you could pick up from there?

Re: Zoneminder send alarm events to XBMC

Posted: Thu Feb 07, 2013 1:41 am
by Dre
I don't think it is that hard , the problem for is I don't know how to code to send event pop ups to XBMC you can use XBMC Json-rpc

Re: Zoneminder send alarm events to XBMC

Posted: Thu Feb 07, 2013 9:07 pm
by Azelphur
I don't know the zoneminder side, but I do know the XBMC side.

I have a shell script that does exactly what you want, posts notifications to XBMC.

Unfortunately the forum won't let me post it as my post "looks too spamy" :(

If you're on IRC/Freenode, give me a nudge and I'll send you the script.

Edit: here's the script, managed to kinda work around the forum block. pastebin . com/cey1uzzj

Re: Zoneminder send alarm events to XBMC

Posted: Mon Feb 11, 2013 10:23 pm
by Dre
still trying to get this to work can someone point me in the write direction
dont know about python script or perl but i am willing to try

Re: Zoneminder send alarm events to XBMC

Posted: Mon Feb 11, 2013 10:59 pm
by mrd
What you need to do is pretty simple. You have two basic choices:

- You can use the the "Filter" functionality to execute a script like the one that Azelphur provided to do what you want, but you will need to add functionality to grab the image that triggered the event. For that you can look at the email modules to see how they do it in Perl.

- You can write a daemon to watch for events like the one described in the wiki:
How can I use ZoneMinder to trigger something else when there is an alarm?
You will also have to add an api call to get the image you want, but that should be pretty easy and someone has probably posted it here in the forums. Of course, you need to port the script that Azelphur sent to Perl as well, but that should be a pretty simple Google learning opportunity.

I like the idea of this and will eventually put it all together, but I'm neck deep in an Android app that I am trying to release in the next few weeks.

Re: Zoneminder send alarm events to XBMC

Posted: Sat Feb 23, 2013 2:46 am
by Dre
hey guys i was on line searching and found this , i think this a good way to start ... mc-update/

Re: Zoneminder send alarm events to XBMC

Posted: Wed Feb 27, 2013 1:30 am
by mrd
OK... I have something working...

It isn't perfect, but it is a start. There are 2 major issues with this approach:

1 - You need to specify the script as an 'Execute command on all matches' script in your ZM filter configuration. This works, but
it is not executed very quickly due to the way ZM handles filters. Ideally, you will probably want this to run as part of a daemon that
watches /var/log/messages so that it is triggered almost instantly, instead of 60 seconds after the event is finished. I can do that easily and
send you the script at some point.

2. Right now this will display the live video of your camera for 15 seconds full-screen and that is not ideal either so I will look at making it appear
as a small window, but that requires you to have to install an AddOn for XBMC and I was hoping to avoid that. It also stops any video that is
currently playing, but we can avoid that when I make it an overlay window.

Hopefully you have some Linux skill and the commands below make sense.
P.S. Make sure you have curl installed on your system.

See below:

root@system-z:/var/lib/zm/bin# pwd
root@system-z:/var/lib/zm/bin# ls -l
total 4
-rwxrwxrwx 1 www-data www-data 835 2013-02-26 20:17
root@system-z:/var/lib/zm/bin# chown -R www-data
root@system-z:/var/lib/zm/bin# chgrp -R www-data

root@system-z:/var/lib/zm/bin# cat

Code: Select all


#ZoneMinder Info
zm_monitor=`basename \`dirname $1\``

#XBMC Info

#Sleep time

curl -v -u ${xbmc_user}:${xbmc_password} -d \
"{ \"jsonrpc\": \"2.0\", \"method\": \"Player.Open\", \
\"params\": { \"item\": { \"file\": \
\"http://${zm_ip}/cgi-bin/nph-zms?mode=jpeg&monitor=${zm_monitor}&scale=100&user=${zm_user}&pass=${zm_password}\" }}, \
\"id\": 1 }" -H "Content-type:application/json" \
-X POST "http://${xbmc_ip}:8080/jsonrpc"

sleep $sleeptime

#Stops the player/picture:
curl -v -u ${xbmc_user}:${xbmc_password} -d \
"{\"jsonrpc\": \"2.0\", \"method\": \"Player.Stop\", \
\"params\": { \"playerid\": 1 }, \
\"id\": 1}" -H "Content-type:application/json" \
-X POST "http://${xbmc_ip}:8080/jsonrpc"

exit 0

Re: Zoneminder send alarm events to XBMC

Posted: Fri Mar 22, 2013 11:43 pm
by ssshake
Dre thanks for posting the link to my blog post. I'm very happy about that project.

MRD. I know you were hoping to avoid an addon/python script but I dont see how you can avoid the stopping of current video playing with your current set up. My script is pretty cool because it pops up over top of what's currently playing, has a time stamp and a message. Also it can be invoked by a key on my remote control for random viewings. Supports transparencies, and because of how it's been done the window size can be configured to any size.

I don't think its a big deal to import an xbmc script, the product is geared for addons after all. If you have multiple XBMC instances like me, you can specify in your config to use a network share for your scripts, so you dont have to install the script manually on each system.

I've only used zoneminder a few times and very little, one thing that sticks out is your solution uses a video stream (i'm guessing) where as mine does a refresh of the still image that the ip camera provides. However I'm sure you could take my existing script and use it for your needs.. or write one from scratch. Having said that is there any advantage to using a video stream? My still image approach refreshes quick enough to give a decent frame rate. Like your solution I'm still relying on an external source (linux box) to send a command to xbmc telling it to run the script.

Re: Zoneminder send alarm events to XBMC

Posted: Sat Mar 23, 2013 5:46 pm
by mrd
I completely agree with your comments and I plan to do more with an add-on similar to what yours does when I get some free time. I just wanted to give Dre something useful while he waits..:-)

I still think it is possible to do the pop-up window with out any add-on though, but it might just be easier to go the add-on route.