New Zoneminder Binding for Zoneminder versions >= 1.34.0

Using the binding, is there a way to change the Function of a Monitor? Such as going from Modect to Monitor?

The function channel lets you do that.

1 Like

I’ve tried this and it’s not working.

BackGarden_ZM_Function.postUpdate("Monitor")

try with
.sendCommand(“Monitor”)

1 Like

Items:
Group:Switch:OR(ON, OFF) gZoneminderMonitorAlarm
Group:Number gZoneminderSelect “[MAP(zoneminder.map):%s]”

Rules:

rule “Select Mode”
when Item gZoneminderSelect received command
then
if(receivedCommand == 0) {
ZoneminderMonitorWohnzimmerFunction.sendCommand(“None”)
— a nother Monitor.Funktion.sendCommand()
}
if(receivedCommand == 1) {
ZoneminderMonitorWohnzimmerFunction.sendCommand(“Monitor”)
— a nother Monitor.Funktion.sendCommand()

    }
    if(receivedCommand == 2) {
        ZoneminderMonitorWohnzimmerFunction.sendCommand("Modect")
		--- a nother Monitor.Funktion.sendCommand()

    }
    if(receivedCommand == 3) {
        ZoneminderMonitorWohnzimmerFunction.sendCommand("Record")
		--- a nother Monitor.Funktion.sendCommand()

    }
    if(receivedCommand == 4) {
        ZoneminderMonitorWohnzimmerFunction.sendCommand("Mocord"
		--- a nother Monitor.Funktion.sendCommand()

    }
    if(receivedCommand == 5) {
        ZoneminderMonitorWohnzimmerFunction.sendCommand("Nodect")
		--- a nother Monitor.Funktion.sendCommand()

    }

end

1 Like

Thanks @liketofly and @mhilbush,

I also needed to update the rights of the ZM user account I was using. Had it set to the very basics. Need EDIT on Monitors.

Hi, I use the zoneminder binding with server version {“version”:“1.34.26”,“apiversion”:“2.0”} and openhab 3.1.0.

When I view the “openhab basic ui” in a webbrowser, the total page is reloaded every x seconds depending on the seconds set in “Refresh Interval” under “Bridge Configuration” in the zoneminder server thing.

I expect this setting is to refresh the status of the zoneminder:monitor channels but when it is set to 5 seconds, the complete webpage is reloaded every 5 seconds and this results that you jump to the top of the basic ui page every time. :confused: The page will reload every minute, if I increase the value to 1 minute, but it will slow down the status updates. :roll_eyes:

I see this behaviour in IE-edge and Firefox. In the openhab android and iOS app I do not see this behaviour. To add to the observation, this strange behaviour only occurs in the first +/-5 minutes when I start the page.

Only a few channels are currently used for my basic ui:

// Server
String      NVR1_VideoMonitorId "Selecteer Camera [%s]"     { channel="zoneminder:server:1d6024c138:videoMonitorId" }
String      NVR1_VideoUrl       "Video Url [%s]"            { channel="zoneminder:server:1d6024c138:videoUrl" }
// Monitor
Switch      CAM2_Enable       "CAM2 record" <camera>        { channel="zoneminder:monitor:1d6024c138:2:enable" }
Number      CAM2_DayEvents    "Day Events [%.0f]"           { channel="zoneminder:monitor:1d6024c138:2:dayEvents" }

Does anyone else see this behaviour?

Correct, and that’s exactly what the binding does. In fact, that’s all the binding can do with respect to updating anything.

I can’t begin to understand what the browser does, and I gave up trying to figure out browser behavior many years ago.

Hi Mark, thanks for the quick reply. Good to know it is not something simple I forgot. Luckily I do not depend on the web gui and most often use the mobile phone app.

I am really happy with this binding and hope to enjoy it for years to come.

I suppose you could try unlinking the ZoneMinder channels one by one until you find the one that’s causing the browser to refresh the page. Other than that I don’t have much else to suggest. If you figure it out, it would be good to post back here.

Also, I wonder if it also happens with Chrome.

Could you post the sitemap widgets that reference the above items?

This is what I configured and as you see I do not use alle Items so I commented them out to minemise the chance on failures.

Items:

// Server
// String      NVR1_ImageMonitorId "Image Monitor Id [%s]"      { channel="zoneminder:server:1d6024c138:imageMonitorId" }
// String      NVR1_ImageUrl       "Image Url [%s]"             { channel="zoneminder:server:1d6024c138:imageUrl" }
String      NVR1_VideoMonitorId "Select Camera [%s]"      { channel="zoneminder:server:1d6024c138:videoMonitorId" }
String      NVR1_VideoUrl       "Video Url [%s]"             { channel="zoneminder:server:1d6024c138:videoUrl" }

// Monitor
Switch      CAM1_Enable       "CAM1 record" <camera>        { channel="zoneminder:monitor:1d6024c138:1:enable" }
Number      CAM1_DayEvents    "Day Events [%.0f]"            { channel="zoneminder:monitor:1d6024c138:1:dayEvents" }

Switch      CAM2_Enable       "CAM2 record" <camera>        { channel="zoneminder:monitor:1d6024c138:2:enable" }
Number      CAM2_DayEvents    "Day Events [%.0f]"            { channel="zoneminder:monitor:1d6024c138:2:dayEvents" }
// String      CAM2_EventId      "Event Id [%s]"                { channel="zoneminder:monitor:1d6024c138:2:eventId" }


Sidemap:

Frame label="Camera's" {
    Selection item=NVR1_VideoMonitorId
    Video item=NVR1_VideoUrl url="" encoding="mjpeg"
    Switch item=CAM1_Enable label="CAM1 record"
    Text item=CAM1_DayEvents label="CAM1 Day Events [%.0f]"
    Switch item=CAM2_Enable label="CAM2 record"
    Text item=CAM2_DayEvents label="CAM2 Day Events [%.0f]"
    }

One by one I commented out the sidemap lines and now i know the issue is caused by the selection function. If I remove it the reloading does not occur.

    Selection item=NVR1_VideoMonitorId

Thanks for looking at this.

Is there an alternative way available for making the selection?

PS, Chrome browser has the same issue. :no_mouth:

Unfortunately, no.

But, I think I see what’s happening. Every refreshInterval seconds (in your case 5 seconds) the binding gets the list of monitors from the ZoneMinder server. One thing the binding does with the monitor list is to update the state options associated with the imageMonitorId and videoMonitorId channels. It does this because it’s possible that a monitor was added or deleted to the ZoneMinder server. I guess it’s possible that updating the state options causes the browser to reload the page; otherwise, the browser would have no way of knowing the new state options. Perhaps @lolodomo can confirm whether updating the state options of a channel causes the browser to refresh/reload the Basic UI page.

I suppose the binding could only update the state options if they’ve changed from the previous monitor list. I’ll have to look at that.

That sounds feasible. Thanks for the update.

Yes, the page in Basic UI is reliadrd on case it contains an item with dynamic states. Of course, it requires a proper implementation by the binding.

So, instead of updating the state options all the time, if I update them only if different from the existing state options, then the Basic UI page won’t reload?

If so, is there a way to get the current state options (BaseDynamicStateDescriptionProvider .getStateDescription().getOptions()) or should I just cache the settings. Probably more efficient to cache the settings…

@FireHAB I have a version that only updates the state options when they’ve changed. Would you like to try that version?

Yes, no problem, how can I get this update and check it is the correct version? My server lives on Ubuntu 20.04 and I use openhab 3.1.0.

I found your update on GitHub but it is 3.2.0 can this version run in 3.1.0?

(No big issue if it corrupts my server, I make a snapshot.)

It’s located here: https://github.com/mhilbush/openhab-binding-releases/blob/master/zoneminder/org.openhab.binding.zoneminder-3.2.0-SNAPSHOT.jar?raw=true

It’s built for version 3.2, but it should work on 3.1.

First you need to uninstall the existing version of the binding. Then drop this version into the addons folder. That’s all you should need to do.

All settings remained with the update :sunglasses: and I did test the basic ui.
The reloading issue is gone. Everything else seems normal. Great job and many thanks!
I leave this version running and update if I notice any side effects.