Zoneminder binding

I have made a small POC on how to integrate Zoneminder into OH2. I have managed to integrate via the API that has beem released in Zoneminder. Right now I can start/stop a recording from OH (eg. turn on/off a switch), and I can follow status of my zoneminder monitors (enabled / disabled). Only thing I am missing before it fullfills my own needs is the capability to change mode for each monitor from OH (eg. Modect, Record,…). It doesn’t seem like a big issue to get there so I am planning to do that.
I don’t have any plans and/or needs to implement the Zoneminder Control API (eg. the possibility to move cameras), allthough it shouldn’t be impossible. I would be happy to share this binding if anybody has the interest,
Before I spend the effort on cleaning up the code I would like to know if anybody have the need for a ZoneMinder binding in OH2?


sure - that would be fantastic

Right now I use a hacky combination of bash scripts interfacing with the API to change modes, and a background awk task to monitor the zoneminder logs and alert openHAB when a movement detection alarm is triggered


I’m PRO.

Using zoneminder for several years now, and with OH, I’ve create some img url’s to see the ‘live’ video directly from my zoneminder. Just to keep everything as simple as possible (for me and my familymembers).

fe my sitemap entry:

Image url="http://ZMSERVER/cgi-bin/nph-zms?mode=single&monitor=13&scale=100&user=USR&pass=PWD" refresh=1000

I don’t use movement of camera’s and so. But things like live streaming, easy camerasnapshot in a rule (fe doorbell, movement…), Switching from camera motion… would be nice features.

So I certainly see advantages in a good link between openhab and zoneminder.

Any plans to support Motion Detect events? Honestly that is the only thing I need from ZoneMinder to integrate it with OH. I was some day going to do something by polling the Events API for changes or use @dan12345’s log reading approach but a binding would be better.

There is a PHP script on the OH 1.x wiki that watches the Zoneminder DB for motion events and reports them to OH. Something like that might work better.

Beyond that I only have the one camera for now and I put that stream on my sitemap using the Video tag and it always stays in motion detect mode so the other features aren’t something I’d use. But I’d be willing to test.

Motion Detect is also what I need, I already have a rudimentary implementation of that running. My plan is to implement both the possibility to start recording from OpenHAB and also to monitor recording / event status in OpenHAB.

The video stuff will be lower priority.
Seems like there is some interest for this binding…

If anyone is interested in my log reading approach, I have the following included in the crontab for my PC running zoneminder:

@reboot tail -F /var/log/syslog | awk '/FireEscape.*into alarm state/ { system("wget  http://user:password@openhab:8080/CMD?CamAlarm=ON -P /tmp") }  /FireEscape.*Left alarm state/ { system("wget http://user:password@openhab:8080/CMD?CamAlarm=OFF -P /tmp") }'

Where “FireEscape” is the name of my zoneminder camera, “openhab” is the url for my openHAB PC, and user/password the openhab user/password

This script then turns openHAB switch CamAlarm ON when motion is detected and Zoneminder goes into an alarm state, and switches it OFF when Zoneminder leaves the alarm state.

All seems hacky and unsatisfactory but has been working without a hitch for months.

In my book “working without a hitch for months” overcomes “hacky and unsatisfactory” every time. :slight_smile:

The only reason I didn’t to this myself was because I didn’t realize that these events were being logged at all to syslog until I was very recently debugging something else and had to shut ZM down because of all the events it was logging.

While I wait for the OP’s binding I’ll probably use your script to add capability. Thanks for posting!

Delighted to be able to repay you in a tiny way for all the benefit I’ve had from your work on openHAB!

1 Like

Hey guys, off-topic but have you looked at motion instead? I have been using it for a few years and it has a very useful API. I can easily arm/disarm motion detection by a simple HTTP binding in openHAB. You can also configure a script to be called anytime there is motion detected, which I have calling a very simply python script to send an update to the openHAB REST API - i.e. motion detection.

Finally, motion has a little HTTP server which you can use for snapshots and streaming display in openHAB. This means you don’t need any direct access to the cameras (they can live on an isolated VLAN for example) and all authentication is defined in one place.

Just thought I would mention it as something worth looking at possibly?

My perhaps erroneous assumption was that motion was primarily intended to work with a camera connected to the host it was running on and not intended to process IP video streams from multiple IP cameras not connected to the motion host machine.

If I’m wrong I might look into it, though I might stay with ZM because I like the DVR aspects of it. Not only do I want to be notified when there is motion detected, I also want to automatically record the motion and have an easy way to review the recorded video which ZM excels at. I just wish it were easier to install into a Docker image so I can be the one responsible for keeping it up to date.

My primary reason for having the cameras is to watch my main doors and record package thieves or attempted breaking and entering. Anything else is extra.

motion certainly supports IP connected cameras. I have a openvz container running motion (with a single CPU + 2GB RAM) and it is monitoring 4 IP cameras.

It will also automatically save snapshots and video snippets when motion is detected. I have it configured to save to my FreeNAS server.

I even have it setup to publish motion snapshots to a private Slack channel so I can quickly view motion events anywhere in the world from my phone.

So you use an external service to support review of the video events. Motion doesn’t support this out of the box I am guessing. I can live with that but it does make it a little less attractive to go through the effort of switching in the near term for me at least.

Thanks for the recommendation!

Correct - the motion HTTP server is very basic - just allows viewing of the live streams and setting config (i.e. enable/disable motion detection). There is nothing for viewing historical snapshots or video events.

I don’t have any external service for reviewing video events, I just look at my Slack channel for snapshots and scan the NAS camera store when I get home to view the videos. I could upload the video events to Slack I guess but some of them can be quite large (motion will keep recording until there is no motion detected for ‘n’ seconds).

I looked at motion but decided against it on the basis that (1) it looks complicated to setup; (2) not a complete solution (as above); (3) it doesn’t seemed to be maintained anymore.

Check out motioneye.

That’s what I use. I have motioneye installed on a linux box. Then I have a raspberry pi security camera running motioneyeos. MotionEye can connect to cameras powered by motiond or via mjpeg.

Here is the feature list

web-based, mobile/tablet-friendly user interface
compatible with most USB cameras as well as with the Raspberry PI camera module
support for IP (network) cameras
motion detection with email notifications and working schedule
JPEG files for still images, AVI files for videos
timelapse movies
uploading media files to Google Drive and Dropbox

I have use this, and even have some external traffic cams entered in to it. I have motion detection setup and it runs a script when motion is detected. This activates the openhab switch for “motion-porch” and also sends a message to my kodi system. Wait!!! I wrote all this up!!!

I tried MotionEye and thought it was fantastic until I discovered that there’s no API or any other way of getting openHAB to control MotionEye, e.g. turning cameras on and off, starting/stopping recording. That’s how I ended up with zoneminder.

I can see that. Makes sense.

My problem with zoneminder is the layout seems so dated. But I could be wrong, maybe it’s been further developed since I used it.

I have been looking in to some physical CCTV systems that will allow playback of individual cameras over RTSP and then be able to tap in to those for doing some presence detection. But streaming video is second nature since that’s my day job of 24/7 live video delivery to the net.

yes - the interface could politely be described as “functional”. It does look a bit less 1995 if you select the “flat” CSS style option (although oddly you have to do this separately for each browser).

I hope not to take the the topic off target, but I think alot of lesser inexperienced users like myself with Linux, OH, etc would love to have a nice fully functioning camera setup. But in getting that started has been a choice of camera’s and hardware.

From my limited reading, both MotionEye and ZoneMinder seem great choices. But what is the recommended camera choice?

Also… Do you feel it would be best to install MotionEye on a separate VM machine or on the same OH2 machine? I have always thought keeping things separate is a better choice in case one VM goes down, you can still have some access to things?

Just a little update on how things are going.

I have managed to get things to compile and even run in a recent fork of OpenHAB sourcecode. The previous version was written before some of the major changes on the framework (eg. karaf). I really didn’t know what the impact of these things was. I seems to be very little (or none) :slight_smile:

Status right now is that I can regulary read values from the ZoneMinder API. I still need to port the mechanishm where I listen for events in ZoneMinder (this is done via the telnet port). This shouldn’t be more complicated, than just moving my code and do a clean up :slight_smile:

I still need to handle errors (right know that part is non-existing). I guess that I should need something between a couple days or a week, depending on how things is progressing.

When I have a version that is a bit more stable than the version I am working on now, I would be happy to share the Binding to anybody who would like to test. Especially somebody who has setup ZoneMinder in another way than default. (Eg. using another path than /zm on the webserver. etc.)

1 Like