Zoneminder plugin for Kodi/XBMC

Forum for questions and support relating to the 1.28.x releases only.
Jamo
Posts: 15
Joined: Tue Aug 13, 2013 6:25 am

Zoneminder plugin for Kodi/XBMC

Post by Jamo » Fri Dec 04, 2015 6:25 am

Hi all

Wasn't sure which board to post in so chose this one since the plugin works with 1.28.1.

This may be of interest to those using the Kodi (http://kodi.tv/) media centre (formerly known as XBMC).

Basically, this plugin allows viewing of camera feeds through Kodi via the zoneminder streamer. This is really helpful if you have a TV or display that is driven by Kodi because it allows a quick check of your camera feeds without leaving the room - especially if you have this set up in your main entertainment area as I do. I can have the gate camera feed running on the TV as guests arrive and easily open and close the gate for them remotely without having to leave the entertainment area. Also potentially useful if you're watching a movie or something and hear a noise or want to check your camera feeds for anything suspicious.

Integrated within kodi, it means you can switch to the camera feed without having to change source on the TV, change to a different remote or anything like that.

plugin was originally written by Mark Honeychurch but stopped working a while back (probably with zoneminder changes) so I've implemented a couple of hacks which seem to have it up and running again (at least for me) under Kodi version 14 and connecting to zoneminder 1.28.1 with auth.

If anyone wants to try it - grab the zip from https://github.com/jamoZA/plugin.video.zoneminder and install to kodi. Incidentally, the zip fails in Isengard (kodi 15) at the moment due to some funnies in Isengard which make the addon.xml file report incorrect structure. Will try to resolve that in due course.

At the moment all the plugin does is provide a video stream from the cameras which, of course, is not leveraging zoneminder's awesome capabilities... but kodi does not at present have any CCTV integration that I'm aware of so this is a good start. Also, you don't have to set up your cameras in Kodi - you do it in zoneminder - one place, which is cool... and the plugin just gets the info from there.

Future plans to enhance the plugin would be
  • Montage view
  • Pop-up windowed stream that doesn't interrupt other playing media
  • Motion event review
  • Notifications on motion detect - eg. pop-up text notification "motion on garage camera" and/or snapshot of frame
James

User avatar
knight-of-ni
Posts: 2079
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Zoneminder plugin for Kodi/XBMC

Post by knight-of-ni » Fri Dec 04, 2015 2:34 pm

Good work. We can always use the help. I don't use Kodi myself, but I'm sure others will find this very helpful.

Something we are going to announce very soon is the future removal of the XML skin and all the features associated with it. The next release, ZoneMinder 1.29.0, will be the last release which contains the XML skin. I'm not absolutely certain that means zmstreamer will go away as well, but I would say it is likely, since I seem to recall zmtreamer is tied into the xml skin.

We have an API now, currently in our development releases, which should be used for this sort of thing moving forward:
http://zoneminder.readthedocs.org/en/latest/api.html
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/

User avatar
iconnor
Posts: 470
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Zoneminder plugin for Kodi/XBMC

Post by iconnor » Fri Dec 04, 2015 4:27 pm

I'll have to give this a go at some point. I use Kodi.

DVB Hardware
Posts: 75
Joined: Thu Jan 01, 2015 5:12 pm

Re: Zoneminder plugin for Kodi/XBMC

Post by DVB Hardware » Fri Dec 04, 2015 5:50 pm

I'll give the new Kodi plugin a try. I have the old ZM version installed in my media center.
Running ZM 1.28.109 on another box
Linux Mint 18.3 Mariadb StorageAreas

DVB stands for Digital VIdeo Broadcasting , retired satellite downlink supplier

DVB Hardware
Posts: 75
Joined: Thu Jan 01, 2015 5:12 pm

Re: Zoneminder plugin for Kodi/XBMC

Post by DVB Hardware » Fri Dec 04, 2015 8:43 pm

Says above does not work with 15

How about Kodi 16.0 beta 2 ?

is the cgi path still the same ? is settings
Linux Mint 18.3 Mariadb StorageAreas

DVB stands for Digital VIdeo Broadcasting , retired satellite downlink supplier

j3tpropelled
Posts: 2
Joined: Mon Dec 21, 2015 9:06 pm

Re: Zoneminder plugin for Kodi/XBMC

Post by j3tpropelled » Mon Dec 21, 2015 9:26 pm

Hi,

I've installed on Kodi 15.2 and works fine. Need to change the cgi-bin in the settings to zm/cgi-bin in order to get it working but otherwise works fine.

Looking forward to future developments.

Cheers

j3tpropelled
Posts: 2
Joined: Mon Dec 21, 2015 9:06 pm

Re: Zoneminder plugin for Kodi/XBMC

Post by j3tpropelled » Mon Dec 21, 2015 9:36 pm

It's working fine altough I am seeing the below errors in the kodi.log

21:29:52 4585914.500000 T:2747315232 ERROR: Grabbing URL: http://<ip address of my zm install>/zm/?skin=classic
21:29:52 4585914.500000 T:2747315232 ERROR: Requesting page: http://<ip address of my zm install>/zm/?skin=classic
21:29:52 4585915.500000 T:2747315232 ERROR: Requesting page: http://<ip address of my zm install>/zm//index.php

Cheers

sipi
Posts: 111
Joined: Wed Feb 14, 2007 5:18 pm

Re: Zoneminder plugin for Kodi/XBMC

Post by sipi » Mon Dec 28, 2015 10:05 pm

Great work! I installed it and I very like it...

Feature request: can you enable more zm server connection in next upgrade?

When you can add the Montage view?

Thanks and congratulation.
sipi

spargopolis
Posts: 8
Joined: Mon Nov 30, 2015 10:52 am
Location: Ottawa, Canada

Re: Zoneminder plugin for Kodi/XBMC

Post by spargopolis » Fri Jan 01, 2016 9:49 pm

I've updated Jamo's plugin to add a menuitem which displays the number of recorded events (if any) for each camera. Selecting the menu item displays a list of the events with timestamp and duration info. Selecting one of the events displays the recorded event video.

You can try it @
https://github.com/spargopolis/plugin.video.zoneminder

I tested it on Ubuntu 14.04 and RPi2 running Kodi 15.2.

As a word of caution, I'm using plain authentication, but I'm a little concerned I may have inadvertently broken the hashed-auth capability, since I couldn't get it to work. However I switched back to Jamo's version and had the same problem, so perhaps it's a problem particular to my setup as opposed to the plugin itself.

That said give it a try. Let me know if you have any problems/comments.

P.S. The "error" logs being seen by j3propelled were in not actually errors. I have mapped these logs to stdout instead of stderr.

orsty3001
Posts: 46
Joined: Tue Jan 26, 2010 5:55 pm

Re: Zoneminder plugin for Kodi/XBMC

Post by orsty3001 » Thu Jan 28, 2016 11:44 pm

It doesn't seem to let me log in. It just tells me to set up authentication every time I try to run it.

Jamo
Posts: 15
Joined: Tue Aug 13, 2013 6:25 am

Re: Zoneminder plugin for Kodi/XBMC

Post by Jamo » Wed Feb 10, 2016 7:52 am

After inadvertently upgrading zoneminder to 1.29 due to an ubuntu update, I found the existing plugin not working due to some changes in the event listing files so I've updated the plugin to fix this.

Hopefully it is backward compatible to 1.28.x (I've tried to make it so).

In addition, I've added an "HTTPS" setting for anyone who connects to zm server with SSL.

As noted below, I also had to change my "cgi-bin" setting to "zm/cgi-bin" for it to work with my 1.29 version.

You can get my updated version at

https://github.com/jamoZA/plugin.video. ... master.zip

spargopolis has done great work adding events listings and playback. There is also a "montage" view listing but I think that is still in development?

orsty3001: Are you using authentication for your ZM server? I have only tested with standard user/password authentication. If you look at the kodi log file while you're trying to open the plugin it should show you the URL it's trying to get. If you copy and paste that into your browser, see if it is working - that may be a clue to the problem.

knnniggett - Next version I will try to start using the api instead of the ugly screen scraping. Thanks for the link. I don't know exactly what you mean by zmstreamer....you mean cgi-bin/nph-zms? Hopefully not.... because that's how we're streaming the video to kodi.... but maybe there's another way?

thermionic
Posts: 16
Joined: Wed Mar 16, 2016 9:54 pm

Re: Zoneminder plugin for Kodi/XBMC

Post by thermionic » Wed Mar 30, 2016 1:52 pm

kodibuntu running kodi 16 (on Ubuntu 14.04 x64)

Zm is running 1.29 on Ubuntu 14.04 x64 over HTTPS

I downloaded the zip from github, copied it to kodi and installed the plugin from the zip, configured hostname, use HTTPS, username and password, left paths as is (and also tried prefixing cgi-bin with xm/cgi-bin).

Attempting to use it, kodi errors onscreen with "ZoneMinder error check the log for more information"

The kodi log shows the below

Code: Select all

13:38:02 T:140385260709632   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <class 'urllib2.HTTPError'>
                                            Error Contents: HTTP Error 404: Not Found
                                            Traceback (most recent call last):
                                              File "/home/local/.kodi/addons/plugin.video.zoneminder-master/default.py", line 462, in <module>
                                                listCameras (addonHandle)
                                              File "/home/local/.kodi/addons/plugin.video.zoneminder-master/default.py", line 217, in listCameras
                                                doc, cookie = getHtmlPage (url, cookie)
                                              File "/home/local/.kodi/addons/plugin.video.zoneminder-master/default.py", line 74, in getHtmlPage
                                                response = urllib2.urlopen(req)
                                              File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
                                                return _opener.open(url, data, timeout)
                                              File "/usr/lib/python2.7/urllib2.py", line 410, in open
                                                response = meth(req, response)
                                              File "/usr/lib/python2.7/urllib2.py", line 523, in http_response
                                                'http', request, response, code, msg, hdrs)
                                              File "/usr/lib/python2.7/urllib2.py", line 442, in error
                                                result = self._call_chain(*args)
                                              File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
                                                result = func(*args)
                                              File "/usr/lib/python2.7/urllib2.py", line 629, in http_error_302
                                                return self.parent.open(new, timeout=req.timeout)
                                              File "/usr/lib/python2.7/urllib2.py", line 410, in open
                                                response = meth(req, response)
                                              File "/usr/lib/python2.7/urllib2.py", line 523, in http_response
                                                'http', request, response, code, msg, hdrs)
                                              File "/usr/lib/python2.7/urllib2.py", line 448, in error
                                                return self._call_chain(*args)
                                              File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
                                                result = func(*args)
                                              File "/usr/lib/python2.7/urllib2.py", line 531, in http_error_default
                                                raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
                                            HTTPError: HTTP Error 404: Not Found
                                            -->End of Python script error report<--
13:38:02 T:140387137439744   ERROR: GetDirectory - Error getting plugin://plugin.video.zoneminder/
13:38:02 T:140387137439744   ERROR: CGUIMediaWindow::GetDirectory(plugin://plugin.video.zoneminder/) failed
Is there anything else I can provide to help debug this issue ?

Cheers

Jamo
Posts: 15
Joined: Tue Aug 13, 2013 6:25 am

Re: Zoneminder plugin for Kodi/XBMC

Post by Jamo » Thu Mar 31, 2016 5:40 am

It seems the script is not able to grab the html pages it requires. Whether this is due to some issue with HTTPS or just a path / network issue we'll have to figure out. I don't have my zm running on HTTPS so I haven't tested it and I'm not sure anyone has? If anyone has this running with HTTPS please let us know!

Do you find the following notices or similar in the log? The script is supposed to log the URLs it's trying to get and I'd imagine that yours would be similar except for the https rather than http prefix?

Code: Select all

07:17:29 T:140604763965184  NOTICE: ListCameras grabbing URL: http://192.168.10.31/zm/?skin=classic&username=****&password=****
07:17:29 T:140604763965184  NOTICE: Requesting page: http://192.168.10.31/zm/?skin=classic&username=****&password=****&action=
07:17:29 T:140604763965184  NOTICE: Requesting page: http://192.168.10.31/zm//index.php
If you do find these, confirm you can reach these urls with your browser.

The other issue may be something to do with HTTPS libraries but let's hope not... if so, we can post on the kodi forum to try to get assistance.

thermionic
Posts: 16
Joined: Wed Mar 16, 2016 9:54 pm

Re: Zoneminder plugin for Kodi/XBMC

Post by thermionic » Thu Mar 31, 2016 10:16 am

I'm not seeing anything like that, the log fragment above is repeated each time I try and launch the addon.

the settings.xml current looks like the below, with the username, password and server values replaced with dummy data

Code: Select all

<settings>
    <setting id="auth" value="true" />
    <setting id="bitrate" value="10" />
    <setting id="cgiurl" value="zm/cgi-bin" />
    <setting id="fps" value="25" />
    <setting id="hash" value="false" />
    <setting id="https" value="true" />
    <setting id="ip" value="false" />
    <setting id="layout" value="Default" />
    <setting id="otherip" value="" />
    <setting id="password" value="password" />
    <setting id="scale" value="1/2" />
    <setting id="secret" value="This is my hash secret" />
    <setting id="server" value="host.domain.dn" />
    <setting id="thisip" value="true" />
    <setting id="username" value="username" />
    <setting id="zmurl" value="zm" />
</settings>
I'm wondering if the issue is the paths

I am able to connect using ZmNinja on IOS and Android over HTTPS, and of course using a browser

Jamo
Posts: 15
Joined: Tue Aug 13, 2013 6:25 am

Re: Zoneminder plugin for Kodi/XBMC

Post by Jamo » Thu Mar 31, 2016 11:51 am

I don't understand it - the log should at least contain the line

Code: Select all

07:17:29 T:140604763965184  NOTICE: ListCameras grabbing URL: http://192.168.10.31/zm/?skin=classic&username=****&password=****
of course with your host address replacing mine (192.168.10.31) and your username/password substituted.

As this is part of the ListCameras routine which is where your error is being thrown... but before the page is requested (the line throwing the error). That would at least tell us what URL it is not able to get. Otherwise, I have no idea.... I would suggest putting in a debug line to show the data that is being passed to the urllib2.Request() call but that is already there and should be giving us the line above!

Obviously you've tried pinging your zm server from your kodi box to ensure your host string resolves correctly?

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests