Update of ZoneMinder bindings

Have you deleted old discovered things?
In my setup I have seen some errors being thrown in the initialisation phase, but just until it is initialised.
Are you sure that the binding is only installed once? openHAB can be a bit touchy if the binding is there multiple times. I have seen openHAB trying to reload older versions even if I asked it to uninstall them.

If all above fails, Delete all zoneminder Server Bridges and ZoneMidner Minditor things. Then try to create a server and wait until it comes online. From there you should be able to discover monitors.

I deleted all old artifacts I could identify by

find / -name "*zoneminder*"

I removed all old things using paper UI (forced remove).
Then I put the 2.3-SNAPSHOT jar into /usr/share/openhab2/addons and restarted the OH server process.

When it came back I waited a little - nothing was discovered automatically. So I did an manual addition for ZoneMinder Server thing and configured it. It stays offline and in the thing details it states “OFFLINE-CONFIGURATION_ERROR”.

This state does not change anymore - even if manually change thing a parameter manually. The change only triggers an error message like in my last post.

Have you tried to start oh from commandline and see whatever list | grep Zone gives?

Btw you should also be abe to download to newer version from the market place.

The grep is

2018-01-10 16:04:00.489 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (e5e9ce71)]: Starting ZoneMinder Server Bridge Handler (Bridge='null')                                                                                                  
2018-01-10 16:04:00.552 [INFO ] [andler.ZoneMinderServerBridgeHandler] - BRIDGE: ZoneMinder Server Bridge Handler Initialized                                                                                                                            
2018-01-10 16:04:04.412 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE]: 'ZoneMinderServerBridgeHandler' general configuration error occurred. Failed to initialize. Exception='Provided credentials not valid'

I will try it again from marketplace later 


Reading my own reply and your answer I can see that I wasn’t clear enough

I am interesting in how many instances of ZoneMinder Binding that there might be installed, as well as actual version. Those answers can be found in karaf console.
Mine looks like:
openhab> list | grep ZoneMinder
330 │ Active │ 80 │ 2.3.0.201801092347 │ ZoneMinder Binding

You can find some information on how to access the console from here
https://docs.openhab.org/administration/console.html

Chers
Martin

Yesterday evening I have pushed a new version to the marketplace.I am half done changing the visible things (eg. adding channels, changing settings):
I have added a setting to configure refresh rate of Still Images, that is a checkbox with three values: Disabled, Low priority, Normal priority.
Disabled will simple cause still image channel to have state “Undefined”. The priorities will be defined in the bridge. New settings will arrive here and the two existing prioritiy settings will disappear):It is possible to disable the still-image refresh. But the priorities is ignored by now.
This would be the approach to all channels that could potentially put some load on the ZoneMinder server, Disk usage is also such a channel.

I also did some POC regarding the PTZ case. The preferred way is to create a new Thing called something like “PTZ Control”. Most of the channels will be dynamically created, which seems to work quite well.For presets we first see the ZoneMinder Control setting hasPreset. If it is true then the channels will be created based on the actual settings. There still is a few things to investigate, so changes might arrive. By now it allthough seems as a possible direction.

I tired the new version from marketplace and installed using PaperUI.
Very curious!

First - the configuration error remains.

Log:

2018-01-11 11:08:47.818 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (8c870aad)]: Starting ZoneMinder Server Bridge Handler (Bridge='null')                                                                                                  
2018-01-11 11:08:47.860 [INFO ] [andler.ZoneMinderServerBridgeHandler] - BRIDGE: ZoneMinder Server Bridge Handler Initialized                                                                                                                            
2018-01-11 11:08:52.871 [WARN ] [ome.core.thing.internal.ThingManager] - Initializing handler for thing 'zoneminder:server:8c870aad' takes more than 5000ms.                                                                                             
2018-01-11 11:08:53.953 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE]: 'ZoneMinderServerBridgeHandler' general configuration error occurred. Failed to initialize. Exception='Provided credentials not valid'

Karaf console:

openhab> list | grep Zone                                                                                                                                                                                                                                
247 │ Active   │  80 │ 2.3.0.201801102329     │ ZoneMinder Binding

Then I double-checked the apache config on the ZM-Server and the credentials. I noted, that my ZM server would support HTTPS too.
So I switched once to HTTPS in PaperUI. The logged error changed:

2018-01-11 11:15:47.732 [INFO ] [andler.ZoneMinderServerBridgeHandler] - BRIDGE: ZoneMinder Server Bridge Handler Initialized                                                                                                                            
2018-01-11 11:15:50.772 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE]: 'ZoneMinderServerBridgeHandler' general configuration error occurred. Failed to initialize. Exception='null'

I switched back to HTTP and the magic did happen: Bridge online :vulcan_salute:

I will shortly report on the performance impact.

I have also noticed that changing config values sometimes seems to help, when it is stuck OFFLINE. That needs some deeper investigation. Think that will come whenever stability is somewhat improved.

The changing of config values seems to follow a pattern. First change produces:

2018-01-11 13:39:25.322 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE]: 'ZoneMinderServerBridgeHandler' failed to initialize. Exception='null'

Second change “repairs” that error.

In my ZM setup I have a “test” monitor configured which is set to “diabled” in normal operation. In my opinion this monitor should not be discovered. Even if I set this to “ignored” in PaperUI inbox, this monitors discovery is logged every few minutes.
As workaround I switched off auto-discovery.

The load added to the ZM server is significantly lower compared to the last binding version when ZM is idle (no alarms). If alarm occurs the ZM server goes into some kind of race condition. This happens at the default refresh rate of 10 sec. I will now lower the rate to 30 sec.

There are some issues with the discovery process. Regarding your suggestion that it should not be discovered I tend to disagree. When reading the ZoneMinder documentation here, regarding Enabled it says:

Enabled
The enabled field indicates whether the monitor should be started in an active mode or in a more passive state. You will nearly always want to check this box, the only exceptions being when you want the camera to be enabled or disabled by external triggers or scripts. If not enabled then the monitor will not create any events in response to motion or any other triggers.
I agree that ignored things should not be found over and over and once more :slightly_frowning_face:

Great that this has reduced load. Though you won’t see any changes when lowering the rate when in an Alarm state, since it goes into a more frequent update (not controllable). That one needs attention as well


Thanks for your comments :slight_smile:

You’re right - so the only issue would be the re-discovery on an ignored monitor.

Alarm state produces tons of exceptions like this:

2018-01-11 18:04:37.602 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [MONITOR]: Method 'refreshThing()' for Bridge failed for thing='zoneminder:monitor:8c870aad:monitor-1' - Exception: 
java.lang.NullPointerException: null
	at name.eskildsen.zoneminder.common.ZoneMinderMonitorStatusEnum.getEnum(ZoneMinderMonitorStatusEnum.java:28) [247:org.openhab.binding.zoneminder:2.3.0.201801102329]
	at name.eskildsen.zoneminder.api.monitor.ZoneMinderMonitorStatus.getStatus(ZoneMinderMonitorStatus.java:15) [247:org.openhab.binding.zoneminder:2.3.0.201801102329]
	at name.eskildsen.zoneminder.internal.ZoneMinderMonitorProxy.getMonitorDetailedStatus(ZoneMinderMonitorProxy.java:367) [247:org.openhab.binding.zoneminder:2.3.0.201801102329]
	at org.openhab.binding.zoneminder.handler.ZoneMinderThingMonitorHandler.onFetchData(ZoneMinderThingMonitorHandler.java:836) [247:org.openhab.binding.zoneminder:2.3.0.201801102329]
	at org.openhab.binding.zoneminder.handler.ZoneMinderBaseThingHandler.refreshThing(ZoneMinderBaseThingHandler.java:189) [247:org.openhab.binding.zoneminder:2.3.0.201801102329]
	at org.openhab.binding.zoneminder.handler.ZoneMinderServerBridgeHandler$3.run(ZoneMinderServerBridgeHandler.java:242) [247:org.openhab.binding.zoneminder:2.3.0.201801102329]

Btw - do you maintain this project anywhere on github ? So we could probably better sort out the issues by using tickets 
 :slight_smile:
And many thanks to you for tackling these problems :smiley:

Yes, the project is a fork from the openHAB addons project. One problem is that the changes is in a rather early state, and using tickets doesn’t give much sense. besides from that I also has a little merge problem from the mainbranch, so I have tons of code not checked in :worried::face_with_hand_over_mouth::dizzy_face:
The plan right now is bring things to a situation where it is running stable. Then I will fix the merge problem (I suspect that the easiest way is to delete my fork and just create a new one).

Btw, by inspecting the code I can see a potential of reducing load when a monitor is in alarm state. For each refresh cycle the following calls are made:

http://<zm-server>/zm/api/monitors/1.json
http://<zm-server>/zm/api/monitors/daemonStatus/id:1/daemon:zmc.json
http://<zm-server>/zm/api/monitors/daemonStatus/id:1/daemon:zma.json
http://<zm-server>/zm/api/monitors/daemonStatus/id:1/daemon:zmf.json

Where the first query is the more important, the three others doen’t need to be called frequently.
In alarm state the datafetch is done each 1 second, where standard is ten seconds. As it is now it would sum up to 40 http requests for a 10 seconds cycle. That would be reduced to 13 requests :slight_smile:

Ok - so lets proceed this way.

Sounds good! :grinning:
I noticed that especially zmc is subject to lots of restarts on a system with limited resources.
From my view it would be good if - only during the stabilizing phase - these special NPE’s would not log a stacktrace. The log gets really difficult to read. :frowning: Maybe as an “expert” config option or - more dirty and less work - a system property ?

The issue right now is that my log approach has changed radically, so something might be logged twice, something not at all. No wonder you think it gets cluttered. The NPE’e shouldn’t be there at all :rage:

Understood - keep going. :vulcan_salute:

1 Like

I have pushed a new build to the market place.In my setup it seems to behave very well (running for 7 hours). Error handling is allthough somewhat incomplete, What have changed:

  • Data fetch has been stabilized,
  • Request to ZoneMinder Server has been reduced in alarm state
  • Initialization has improved

Regarding the latter, it seems that it just starts and goes ONLINE (at least in my environment)

If you dare try it, you should carefully delete both Server Thing and Monitor Things and then create a server manually and discover the monitors.

I removed all things, uninstalled and re-installed the bindig, checked the version:

248 │ Active   │  80 │ 2.3.0.201801112350     │ ZoneMinder Binding

Findings are:

  • “Failed to initialize”-error when bridge thing is added first (only hostname and credentials provided), an additional config parameter change fixed that.
  • “getChannelByteArrayAsRawType()” errors shortly after the monitor things where initialized. Without stacktraces. :clap:
  • Set 2 monitors to “ignored” in inbox (no function and disabled in ZM) - permanent re-discovery logged.
  • Server thing background discovery switch-off: Config exception, additional config param change needed to repair.

I have reduced my ZM setup to 3 active monitors so that there is more load headroom for alarming. Idle load of this setup is 1.5.
The refresh is now 15 sec. I will report load behaviour later.

Hmm. didn’t expect that


That is still image failing, I guess there might be missing some check if it is connected

I haven’t done anything regarding discovery. I am not sure if it is an openHAB issue or ZoneMinder Binding issue. Do you have knowledge of Bindings that respect ignored things?

Cool, looking forward.

Next step is to clean up code (remove old code, add try/catches, improve errorhandling where missing, streamline logging).

I have found a few possible performance improvements. (eg. whenever an alarm is active events is fetched to identify correct event text, right now a bunch a events is fetched, I have found away to get latest event only.)

I’ve just cross checked that with an other binding (tradfri). If I set a thing to ignored in inbox the log remains silent even if I force rediscovery.

First impression is that 15 sec refresh adds load of about 0.5. Thats still a lot in my opinion. I let it run for 2 or three more hours, then reduce the refresh to 30 sec.

I can confirm that alarm handling is MUCH better now. The 3 monitors are all outdoor cams, so sometimes “false positive” alarms occur due to light changes. Had one today and it did’nt raise the load significantly. Got 6 “forceAlarm” events, which corresponds to your findings.
The interesting time comes around 3 o’clock when my boy comes home from school 
 :wink: