New Zoneminder Binding for Zoneminder versions >= 1.34.0

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.

Yeah, I think this is the case with all binding documentation, as it was ported to OH3 as is. Binding examples, therefore, continue to use textual examples for things, items, and rules.

yes, sincerely I do not like “pure” visual programming, mainly for the difficulty to document the system, and therefore for maintenance and new developments. I tried to use for documentation the json DB, but it is almost unreadable, and do you know any fast way to document my own OH3 implementation?

Unfortunately, no. This is why I still use text files. I need an easy way to version control and back up my config.

I used openSSL to generate my certificates on my Linux box. My Zoneminder box isn’t externally available so I can’t use LetsEncrypt certificates like I’d like.

I just noticed that ZM v1.36 has been released so upgraded but encountered a few errors and reverted to a backup until I have more time to devote to the upgrade.

@mhilbush , do you happen to know if the binding is compatible with ZM v1.36?

I don’t know, as I haven’t tried upgrading yet. I’d be surprised if there were breaking API changes, but you never know.

Did you happen to notice any errors in the logs?

I didn’t check the logs. It was a spur of the moment upgrade and when it didn’t go smoothly I rolled back without doing any investigation.

I’ll build a new Debian VM one evening this week, install ZM v1.36, add a single camera, add a new OH thing and see what happens. (I’m still on OH 2.5.)