New Zoneminder Binding for Zoneminder versions >= 1.34.0

I am late to the zoneminder binding. I have a zoneminder system with 12 cameras, I just have not tied to openHAB. Implemented the binding with zero problems as I migrated to OH3, all works perfectly. THANKS!!

I am now playing with the new UI and want to use the zoneminder video URL in a oh-video-card on my overview display. Has anyone gotten this to work? I can easily get an image via the image card, just not having luck with video.

1 Like

Never mind, I used an “image” card with the mjpeg URL and it works like a champ!!

Merry Christmas all.

1 Like

I just got zoneminder setup and will try out this binding as soon as i finished my upgrade to openhab 3.0.

I do have a question to all the other zoneminder users here, did someone of you had the same issue already like described below:
I have a controllable PTZ ip camera and mostly use 2 different presets (views) with it. How do I set up “alarm” zones for each of them, so they are only active depending on what preset is currently used?

I’m experiencing an odd behavior with the Event ID channel. In some monitors, the returned values are not the latest ones but from events occurred hours ago. These “problem” monitors, which I have checked so far, are all Mocord type.

My Nodect and Modect monitors seem to return correct values although I have not checked all of them.

My configurations are: zm 1.34.22, org.openhab.binding.zm-2.5.9-SNAPSHOT.jar, and openHAB 2.5.10-1

Do you experience the same issue?

Thank you and Happy New Year.

@oh_newbie I’ve not seen the issue, but I don’t use Mocord.

You could try enabling TRACE mode in the binding to see what’s being returned by the Zoneminder API as the “most recent” event for those Mocord monitors.

Alternatively, you could put this URL in your browser (using the IP of your zoneminder host and replacing the monitor id of 7 with the one that’s not correct). This is the URL the binding uses to get the most recent event.

http://your.zoneminder.host/zm/api/events/index/MonitorId:7.json?sort=StartTime&direction=desc&limit=1

@mhilbush. Many thanks for your suggestions. I tried both the TRACE and URL methods and they returned the correct values. However, my corresponding items did not get the updates. Here is how I declare one of my items:

String zm_hallway_Event_ID   "[%s]" {channel="zm:monitor:21:eventId"}

Again, so far only Mocord monitors are experiencing this issue. Below is an example of my kitchen camera which has 2 monitors: #17 which is a mocord and #18, a nodect. You can see Monitor 17 got no id update but 18 got its.

2021-01-02 09:42:58.001 [DEBUG] [zm.internal.handler.ZmMonitorHandler] - Monitor 17: Updating: id=17, name=Kitchen, function=Mocord, enabled=true, status=Connected, alarm=true, state=TAPE, events=(7,148,1023,2457,2457)
2021-01-02 09:42:58.025 [DEBUG] [zm.internal.handler.ZmMonitorHandler] - Monitor 18: Updating: id=18, name=Kitchen-HD, function=Nodect, enabled=true, status=Connected, alarm=false, state=IDLE, events=(5,50,344,940,940)
2021-01-02 09:42:58.037 [TRACE] [zm.internal.handler.ZmMonitorHandler] - Monitor 18: Id:160060, Frames:53, AlarmFrames:3, Length:10.4

@mhilbush
Additional information. Below are the api returns of Monitor 17 (Mocord) and 18 (Nodect). The significant differences between them are the “Name” and “EndTime”.
For Monitor 17, they are “New Event” and null, respectively.
For Monitor 18, they are “Event- 160060” and "2021-01-02 09:31:53"

I wonder if the null EndTime might have caused parsing issue?

Monitor 17 return

{
  "events": [
    {
      "Event": {
        "Id": "160084",
        "MonitorId": "17",
        "StorageId": "0",
        "SecondaryStorageId": "0",
        "Name": "New Event",
        "Cause": "Continuous",
        "StartTime": "2021-01-02 09:42:57",
        "EndTime": null,
        "Width": "640",
        "Height": "480",
        "Length": "0.00",
        "Frames": "1",
        "AlarmFrames": "0",
        "DefaultVideo": "",
        "SaveJPEGs": "3",
        "TotScore": "0",
        "AvgScore": "0",
        "MaxScore": "0",
        "Archived": "0",
        "Videoed": "0",
        "Uploaded": "0",
        "Emailed": "0",
        "Messaged": "0",
        "Executed": "0",
        "Notes": "",
        "StateId": "1",
        "Orientation": "ROTATE_0",
        "DiskSpace": null,
        "Scheme": "Medium",
        "Locked": false,
        "MaxScoreFrameId": "18623790",
        "FileSystemPath": "\/mnt\/virtual\/zoneminder\/events\/17\/2021-01-02\/160084"
      }
    }
  ],
  "pagination": {
    "page": 1,
    "current": 1,
    "count": 2457,
    "prevPage": false,
    "nextPage": true,
    "pageCount": 2457,
    "order": {
      "Event.StartTime": "desc"
    },
    "limit": 1,
    "options": {
      "limit": 1,
      "order": {
        "Event.StartTime": "desc"
      },
      "sort": "StartTime",
      "direction": "desc"
    },
    "paramType": "querystring",
    "queryScope": null
  }
}

Monitor 18 return

{
  "events": [
    {
      "Event": {
        "Id": "160060",
        "MonitorId": "18",
        "StorageId": "0",
        "SecondaryStorageId": "0",
        "Name": "Event- 160060",
        "Cause": "Linked",
        "StartTime": "2021-01-02 09:31:43",
        "EndTime": "2021-01-02 09:31:53",
        "Width": "1920",
        "Height": "1080",
        "Length": "10.40",
        "Frames": "53",
        "AlarmFrames": "3",
        "DefaultVideo": "160060-video.mp4",
        "SaveJPEGs": "0",
        "TotScore": "150",
        "AvgScore": "50",
        "MaxScore": "50",
        "Archived": "0",
        "Videoed": "0",
        "Uploaded": "0",
        "Emailed": "0",
        "Messaged": "0",
        "Executed": "0",
        "Notes": "Linked: Kitchen",
        "StateId": "1",
        "Orientation": "ROTATE_0",
        "DiskSpace": "6410705",
        "Scheme": "Medium",
        "Locked": false,
        "MaxScoreFrameId": "18621102",
        "FileSystemPath": "\/mnt\/virtual\/zoneminder\/events\/18\/2021-01-02\/160060"
      }
    }
  ],
  "pagination": {
    "page": 1,
    "current": 1,
    "count": 940,
    "prevPage": false,
    "nextPage": true,
    "pageCount": 940,
    "order": {
      "Event.StartTime": "desc"
    },
    "limit": 1,
    "options": {
      "limit": 1,
      "order": {
        "Event.StartTime": "desc"
      },
      "sort": "StartTime",
      "direction": "desc"
    },
    "paramType": "querystring",
    "queryScope": null
  }
}

Thanks for the analysis. I’ll have a look.

The current query gets the most recent event, even if the most recent event is in progress. My preference would be to adjust the query to get only the most recent completed event, but I don’t know if the Zoneminder API supports that.

So, it looks like this query gets the most recent completed event. This was the intention of what I was trying to do in the code, but it didn’t work correctly. Do you want to give a try in your browser to see if that’s what you expect.

http://your.zoneminder.host/zm/api/events/index/MonitorId:7/Name!=:New%20Event.json?sort=StartTime&direction=desc&limit=1

Thanks for your help Mark @mhilbush. Here are the results

Using the new Event url

http://your.zoneminder.host/zm/api/events/index/MonitorId:17/Name!=:New%20Event.json?sort=StartTime&direction=desc&limit=1

I did get the most recent completed event

{
  "events": [
    {
      "Event": {
        "Id": "163649",
        "MonitorId": "17",
        "StorageId": "0",
        "SecondaryStorageId": "0",
        "Name": "Event- 163649",
        "Cause": "Continuous",
        "StartTime": "2021-01-03 16:12:51",
        "EndTime": "2021-01-03 16:22:51",
        "Width": "640",
        "Height": "480",
        "Length": "600.03",
        "Frames": "2986",
        "AlarmFrames": "111",
        "DefaultVideo": "",
        "SaveJPEGs": "3",
        "TotScore": "2250",
        "AvgScore": "20",
        "MaxScore": "107",
        "Archived": "0",
        "Videoed": "0",
        "Uploaded": "0",
        "Emailed": "0",
        "Messaged": "0",
        "Executed": "0",
        "Notes": "Motion: Doors",
        "StateId": "1",
        "Orientation": "ROTATE_0",
        "DiskSpace": "158171941",
        "Scheme": "Medium",
        "Locked": false,
        "MaxScoreFrameId": "19028801",
        "FileSystemPath": "\/mnt\/virtual\/zoneminder\/events\/17\/2021-01-03\/163649"
      }
    }
  ],
  "pagination": {
    "page": 1,
    "current": 1,
    "count": 2464,
    "prevPage": false,
    "nextPage": true,
    "pageCount": 2464,
    "order": {
      "Event.StartTime": "desc"
    },
    "limit": 1,
    "options": {
      "limit": 1,
      "order": {
        "Event.StartTime": "desc"
      },
      "sort": "StartTime",
      "direction": "desc"
    },
    "paramType": "querystring",
    "queryScope": null
  }
}

compared to the last event url

http://your.zoneminder.host/zm/api/events/index/MonitorId:17.json?sort=StartTime&direction=desc&limit=1

I got

{
  "events": [
    {
      "Event": {
        "Id": "163673",
        "MonitorId": "17",
        "StorageId": "0",
        "SecondaryStorageId": "0",
        "Name": "New Event",
        "Cause": "Continuous",
        "StartTime": "2021-01-03 16:22:51",
        "EndTime": null,
        "Width": "640",
        "Height": "480",
        "Length": "39.79",
        "Frames": "200",
        "AlarmFrames": "0",
        "DefaultVideo": "",
        "SaveJPEGs": "3",
        "TotScore": "0",
        "AvgScore": "0",
        "MaxScore": "0",
        "Archived": "0",
        "Videoed": "0",
        "Uploaded": "0",
        "Emailed": "0",
        "Messaged": "0",
        "Executed": "0",
        "Notes": "",
        "StateId": "1",
        "Orientation": "ROTATE_0",
        "DiskSpace": null,
        "Scheme": "Medium",
        "Locked": false,
        "MaxScoreFrameId": "19031208",
        "FileSystemPath": "\/mnt\/virtual\/zoneminder\/events\/17\/2021-01-03\/163673"
      }
    }
  ],
  "pagination": {
    "page": 1,
    "current": 1,
    "count": 2466,
    "prevPage": false,
    "nextPage": true,
    "pageCount": 2466,
    "order": {
      "Event.StartTime": "desc"
    },
    "limit": 1,
    "options": {
      "limit": 1,
      "order": {
        "Event.StartTime": "desc"
      },
      "sort": "StartTime",
      "direction": "desc"
    },
    "paramType": "querystring",
    "queryScope": null
  }
}

You can see the StartTime (of the last event) == EndTime (of the most recent completed event)

Thanks for confirming. I already pushed a fix for this against the 3.0 code base.

If there’s a 2.5.x release planned, I can push the fix for that release. But I don’t think there’s anything planned at the moment.

1 Like

@mhilbush Many thanks for your support of this great binding.

Is anyone using SSL to access Zoneminder behind a reverse proxy (Apache, NGINX, etc)? If so, what kind of certificate are you using (self-signed or otherwise)? I’m trying to resolve an issue with using self-signed certificates (which currently don’t work unless you muck with the JVM’s trust store). I would like to make sure my changes for handling self-signed certs don’t break anyone who is not using a self-signed cert.

Thanks in advance!

Hi all,
for a couple of years I did not use zoneminder binding, now I tried to use it again with a fresh installation (zm 1.34.22) on my stable OH 2.5.10, zoneminder binding 2.5.10.
I cannot put online the zoneminder server with error “Cannot access ZoneMinder Server. Check provided usercredentials”, I started to read the posts concerning this error, but after two hours of reading I was definitely confused about what to do (I tried to disable the authorization in zm, but I received another error).
So is there a simple solution to this issue without complex workarounds?
Thanks for your help.

Hi. Similar issues here.
I’m using the zoneminder docker image v1.34.23 with no (simple) possibility to stick to http.
I tried with and without auth but I always get “Can’t get version information”
ZM settings are fine btw…

Binding version is latest 2.5.x and I’m running 2.5.12.

Docker link: Docker Hub

If you’re using org.openhab.binding.zoneminder in 2.5.x, it is known to not work with 1.34.x.

Similar to what?

Sorry, I thought I replied to bruno

Similar to his issues - failure after creating the server item with ssl enabled.
I use the latest 2.5.x binding from the new binding repository - not the one shipped with OH 2.5.12.

I managed to work around the issue by using a different docker image that doesn’t have SSL enabled.
Didn’t work at first, but is now working fine after I turned on auth.

So I suppose there is some issue with SSL only istallations.

Yes, as described above, there are issues with self-signed certs.

Thanks Mark, anyway I am trying to use OH3 (after an unsuccessful attempt to avoid zoneminder with ipcamera binding), but I have some trouble because the binding description in the documentation refers to the old-style textual approach, while nothing is said about the new visual approach. However more or less I am able to manage the features of my interest.