Zoneminder binding

I have corrected a couple of minor issues:

  1. improved handling in data refresh task
  2. Improved logging

https://github.com/openhab/openhab2-addons/files/712402/org.openhab.binding.zoneminder-2.0.0-SNAPSHOT.zip

Thanks - that worked great for a few minutes (and the improved logging is appreciated). However after about five minutes one of my cameras seems to lose its connection to the binding, with a stream of errors:

2017-01-19 11:49:44.151 [ERROR] [andler.ZoneMinderServerBridgeHandler] - BRIDGE [zm]: Method 'refreshThing()' for Bridge zoneminder:server:zm failed for thing='zoneminder:monitor:zm:monitor-4' - Exception='-1'

PaperUI shows monitor-4 as online, and the debug logs don’t give a clue as to what’s causing this:

2017-01-19 11:50:46.614 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: ThingAvailability: Thing 'zoneminder:monitor:zm:monitor-4' has Bridge 'null' defined (Check PASSED)
2017-01-19 11:50:46.614 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: ThingAvailability: Thing 'zoneminder:monitor:zm:monitor-4' has valid configuration (Check PASSED)
2017-01-19 11:50:46.614 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: ThingAvailability: ZoneMinder Id for Thing 'zoneminder:monitor:zm:monitor-4' defined (Check PASSED)
2017-01-19 11:50:55.501 [DEBUG] [r.handler.ZoneMinderBaseThingHandler] - refreshThing(): Bridge 'zoneminder:server:zm' Found for Thing 'zoneminder:monitor:zm:monitor-4'!
2017-01-19 11:50:55.546 [ERROR] [andler.ZoneMinderServerBridgeHandler] - BRIDGE [zm]: Method 'refreshThing()' for Bridge zoneminder:server:zm failed for thing='zoneminder:monitor:zm:monitor-4' - Exception='null'

monitor-4 has the same settings as my other monitors; the only difference is that monitor 4 is a wifi camera (although zoneminder doesn’t suggest its connnection has been lost).

I’ve tried stopping and restarting openHAB; I’ve also tried removing the monitor-4 Thing and re-adding it; neither makes a difference

Any help appreciated. Clearly the binding is very close to working perfectly; the various problems from the previous version have gone, and the longstanding issue with 5 second disconnects has gone too. So thank you!

Dan

I have tested with two cameras, and have seen a strange behaviour, which I am digging into. I have seen that specific calls fail at some more or less random interval. After introducing more logging I have confirmed that it is either call to obtain server load or server disk usage, The logging that I have introduced (in my build) indicates that ZoneMinder is returning af ResponseCode 401 (Unauthorized). Obviously that is strange, since it only occurs every 5 . 15 minutes, and thos calls is performed more frequently. Hopefully I can come on top of that behaviour, at least it is my clear goal that this must be solved before I ask Kai to start the final code reveiw.
Right now I am trying different things in my setup, so I don’t think an official build would be helpfull.

I really appreciate your help in testing!
Martin

no problem - very happy to help

so it was stable for a few days with only monitor-4 failing. I’ve now updated openhab to RC1 and monitor-5 is failing too. So, as you say, strange behaviour!

I have tried quite a bit ion my setup and I have found some problems in my initial approach

I have some findings that I am trying to handle, I have finally got a version (prototype) running stable over night, since yesterday. Right now I am aworking on a version that I can release.

cool - look forward to it!

I have just created a new build in my setup, if that still runs smooth tomorrow I will post it on GitHub. One of the problems that I have seen is that the Binding seems to put load on the ZoneMinder Server (at least mine), this seems (based on 10 minutes observations) much better in what I am running now.

This jar has been running overnight without issues in my setup.
https://github.com/openhab/openhab2-addons/files/722822/org.openhab.binding.zoneminder-2.0.0-SNAPSHOT.zip

Remember to uninstall (eg. bundle:uninstall from karaf) any previous version to avoid problems. Feel free to comment - good or bad :slight_smile:

many thanks for the updated binding. Installs fine. Autodiscovery doesn’t seem to work, but added Things manually no problem. However unfortunately a few seconds later I started getting the repeating errors for monitor-4 again


Dan

I think I disabled autodiscovery for the Server, since there is no obvious method to identify the server other than brute force. However monitors should be auto discovered.

Can you provide a logfile with DEBUG logging enabled? I would also be interested in what your setup is (camera types)
I just checked mine and since yesterday evening I haven’t seen a single ERROR in my log. However that doesn’t help you very much


  • What is the first error you see? Would be great with a DEBUG log
  • How many monitors do you have?
  • Are they configured somehow differently (maybe because of different hardware) ?
  • Are you using zone configuration in ZoneMinder?
    I am just looking for anything that could make your setup different from mine. Mine is two Raspberry Pi’s with a Pi Noir
    camera attached.

Many thanks. I understand autodiscovery is disabled for the Server. It used to work perfectly for the monitors, but now doesn’t (and so I added them manually into a Things file).

My monitor-4 is a wifi camera, and the others aren’t, but otherwise their configuration is the same.

Debug log from the point I add monitor-4 is as follows (for clarity, I’ve deleted log references to the other monitors):

2017-01-24 17:43:42.762 [INFO ] [andler.ZoneMinderThingMonitorHandler] - MONITOR: Starting ZoneMinder Server Thing Handler (Thing='zoneminder:monitor:zm:monitor-4')
2017-01-24 17:43:42.763 [INFO ] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: ZoneMinder Monitor Handler Initialized
2017-01-24 17:43:42.763 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4:    Monitor Id:         4
2017-01-24 17:43:42.764 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: Channel 'zoneminder:monitor:zm:monitor-4:force-alarm' in monitor '4' received command='REFRESH'
2017-01-24 17:43:42.764 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: Setting channel 'zoneminder:monitor:zm:monitor-4:force-alarm' to 'UNDEF'
2017-01-24 17:43:42.765 [ERROR] [ore.thing.internal.ThingRegistryImpl] - Could not inform the ThingTracker 'org.eclipse.smarthome.core.thing.internal.ThingManager@1a840430' about the 'THING_UPDATED' event!
java.lang.NullPointerException
	at org.eclipse.smarthome.core.thing.internal.ThingManager.thingUpdated(ThingManager.java:542)[106:org.eclipse.smarthome.core.thing:0.9.0.b3]
	at org.eclipse.smarthome.core.thing.internal.ThingRegistryImpl.notifyTrackers(ThingRegistryImpl.java:227)[106:org.eclipse.smarthome.core.thing:0.9.0.b3]
	at org.eclipse.smarthome.core.thing.internal.ThingRegistryImpl.notifyListenersAboutUpdatedElement(ThingRegistryImpl.java:150)[106:org.eclipse.smarthome.core.thing:0.9.0.b3]
	at org.eclipse.smarthome.core.thing.internal.ThingRegistryImpl.notifyListenersAboutUpdatedElement(ThingRegistryImpl.java:1)[106:org.eclipse.smarthome.core.thing:0.9.0.b3]
	at org.eclipse.smarthome.core.common.registry.AbstractRegistry.updated(AbstractRegistry.java:167)[99:org.eclipse.smarthome.core:0.9.0.b3]
	at org.eclipse.smarthome.core.common.registry.AbstractProvider.notifyListeners(AbstractProvider.java:57)[99:org.eclipse.smarthome.core:0.9.0.b3]
	at org.eclipse.smarthome.core.common.registry.AbstractProvider.notifyListenersAboutUpdatedElement(AbstractProvider.java:82)[99:org.eclipse.smarthome.core:0.9.0.b3]
	at org.eclipse.smarthome.model.thing.internal.GenericThingProvider.access$4(GenericThingProvider.java:1)[134:org.eclipse.smarthome.model.thing:0.9.0.b3]
	at org.eclipse.smarthome.model.thing.internal.GenericThingProvider$21.accept(GenericThingProvider.java:1044)[134:org.eclipse.smarthome.model.thing:0.9.0.b3]
	at org.eclipse.smarthome.model.thing.internal.GenericThingProvider$21.accept(GenericThingProvider.java:1)[134:org.eclipse.smarthome.model.thing:0.9.0.b3]
	at java.util.ArrayList.forEach(ArrayList.java:1249)[:1.8.0_121]
	at org.eclipse.smarthome.model.thing.internal.GenericThingProvider.createThingsFromModelForThingHandlerFactory(GenericThingProvider.java:1054)[134:org.eclipse.smarthome.model.thing:0.9.0.b3]
	at org.eclipse.smarthome.model.thing.internal.GenericThingProvider.access$1(GenericThingProvider.java:1008)[134:org.eclipse.smarthome.model.thing:0.9.0.b3]
	at org.eclipse.smarthome.model.thing.internal.GenericThingProvider$1$1.accept(GenericThingProvider.java:236)[134:org.eclipse.smarthome.model.thing:0.9.0.b3]
	at org.eclipse.smarthome.model.thing.internal.GenericThingProvider$1$1.accept(GenericThingProvider.java:1)[134:org.eclipse.smarthome.model.thing:0.9.0.b3]
	at java.util.concurrent.ConcurrentHashMap$KeySetView.forEach(ConcurrentHashMap.java:4649)[:1.8.0_121]
	at org.eclipse.smarthome.model.thing.internal.GenericThingProvider$1.apply(GenericThingProvider.java:239)[134:org.eclipse.smarthome.model.thing:0.9.0.b3]
	at org.eclipse.smarthome.model.thing.internal.GenericThingProvider$1.apply(GenericThingProvider.java:1)[134:org.eclipse.smarthome.model.thing:0.9.0.b3]
	at org.eclipse.smarthome.config.core.BundleProcessorVetoManager.applyActionFor(BundleProcessorVetoManager.java:121)[95:org.eclipse.smarthome.config.core:0.9.0.b3]
	at org.eclipse.smarthome.model.thing.internal.GenericThingProvider$6.accept(GenericThingProvider.java:320)[134:org.eclipse.smarthome.model.thing:0.9.0.b3]
	at org.eclipse.smarthome.model.thing.internal.GenericThingProvider$6.accept(GenericThingProvider.java:1)[134:org.eclipse.smarthome.model.thing:0.9.0.b3]
	at java.lang.Iterable.forEach(Iterable.java:75)[:1.8.0_121]
	at org.eclipse.smarthome.model.thing.internal.GenericThingProvider.createThingsFromModel(GenericThingProvider.java:323)[134:org.eclipse.smarthome.model.thing:0.9.0.b3]
	at org.eclipse.smarthome.model.thing.internal.GenericThingProvider.modelChanged(GenericThingProvider.java:901)[134:org.eclipse.smarthome.model.thing:0.9.0.b3]
	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:207)[123:org.eclipse.smarthome.model.core:0.9.0.b3]
	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:120)[123:org.eclipse.smarthome.model.core:0.9.0.b3]
	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:270)[123:org.eclipse.smarthome.model.core:0.9.0.b3]
	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.access$1(FolderObserver.java:264)[123:org.eclipse.smarthome.model.core:0.9.0.b3]
	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver$WatchQueueReader.processWatchEvent(FolderObserver.java:145)[123:org.eclipse.smarthome.model.core:0.9.0.b3]
	at org.eclipse.smarthome.core.service.AbstractWatchQueueReader.run(AbstractWatchQueueReader.java:122)[99:org.eclipse.smarthome.core:0.9.0.b3]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
2017-01-24 17:43:43.336 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: ThingAvailability: Thing 'zoneminder:monitor:zm:monitor-4' has Bridge 'null' defined (Check PASSED)
2017-01-24 17:43:43.336 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: ThingAvailability: Bridge 'null' is ONLINE (Check PASSED)
2017-01-24 17:43:43.336 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: ThingAvailability: Thing 'zoneminder:monitor:zm:monitor-4' has valid configuration (Check PASSED)
2017-01-24 17:43:43.336 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: ThingAvailability: ZoneMinder Id for Thing 'zoneminder:monitor:zm:monitor-4' defined (Check PASSED)
2017-01-24 17:44:00.481 [DEBUG] [r.handler.ZoneMinderBaseThingHandler] - MONITOR-4: Performing refresh
2017-01-24 17:44:00.481 [DEBUG] [r.handler.ZoneMinderBaseThingHandler] - MONITOR-4: getZoneMinderBridgeHandler(): Bridge for 'zoneminder:monitor:zm:monitor-4' - 'zoneminder:server:zm'
2017-01-24 17:44:00.481 [DEBUG] [r.handler.ZoneMinderBaseThingHandler] - MONITOR-4: refreshThing(): Refreshing Thing - zoneminder:monitor:zm:monitor-4
2017-01-24 17:44:00.481 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: Setting channel 'zoneminder:monitor:zm:monitor-4:enabled' to 'UNDEF'
2017-01-24 17:44:00.481 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: Setting channel 'zoneminder:monitor:zm:monitor-4:force-alarm' to 'UNDEF'
2017-01-24 17:44:00.482 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: Setting channel 'zoneminder:monitor:zm:monitor-4:alarm' to 'UNDEF'
2017-01-24 17:44:00.482 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: Setting channel 'zoneminder:monitor:zm:monitor-4:recording' to 'UNDEF'
2017-01-24 17:44:00.482 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: Setting channel 'zoneminder:monitor:zm:monitor-4:detailed-status' to 'UNDEF'
2017-01-24 17:44:00.482 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: Setting channel 'zoneminder:monitor:zm:monitor-4:function' to 'UNDEF'
2017-01-24 17:44:00.482 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: Setting channel 'zoneminder:monitor:zm:monitor-4:event-cause' to 'UNDEF'
2017-01-24 17:44:00.482 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: Setting channel 'zoneminder:monitor:zm:monitor-4:capture-daemon' to 'UNDEF'
2017-01-24 17:44:00.483 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: Setting channel 'zoneminder:monitor:zm:monitor-4:analysis-daemon' to 'UNDEF'
2017-01-24 17:44:00.483 [DEBUG] [andler.ZoneMinderThingMonitorHandler] - MONITOR-4: Setting channel 'zoneminder:monitor:zm:monitor-4:frame-daemon' to 'UNDEF'
2017-01-24 17:44:00.483 [DEBUG] [r.handler.ZoneMinderBaseThingHandler] - MONITOR-4: refreshThing(): Thing Refreshed - zoneminder:monitor:zm:monitor-4
2017-01-24 17:44:11.327 [DEBUG] [r.handler.ZoneMinderBaseThingHandler] - MONITOR-4: Performing refresh
2017-01-24 17:44:11.327 [DEBUG] [r.handler.ZoneMinderBaseThingHandler] - MONITOR-4: refreshThing(): Bridge 'zoneminder:monitor:zm:monitor-4' Found for Thing 'zoneminder:monitor:zm:monitor-4'!
2017-01-24 17:44:11.672 [ERROR] [andler.ZoneMinderServerBridgeHandler] - BRIDGE [zm]: Method 'refreshThing()' for Bridge zoneminder:server:zm failed for thing='zoneminder:monitor:zm:monitor-4' - Exception='null'

thank you!

Dan

I had hoped too see some log comments from an old build of the binding. But it looks like you are running on a recent build. :slight_smile: The first ERROR line is new to me (haven’t seen that before.

It is obviously a bug that monitors aren’t detected. I think that would be a place to start, then we are at least sure that your monitor configuration is correct :slight_smile:

I will look into it later tonight

I am quite sure that the problem reported above has been corrected in this build:
https://github.com/openhab/openhab2-addons/files/728192/org.openhab.binding.zoneminder-2.1.0-SNAPSHOT.zip

This build does address some bugs during initialisation, which will likely cause one or more monitors not to be initialised correct. Furthermore the discovery service has been rewritten, now it works like the ZWave Binding, eg. you will have to create a Bridge Thing, and then the monitors will be automatically discovered.

Definitely getting there!

Autodiscovery now works perfectly (although I had to reset openHAB after adding the monitors, as otherwise they didn’t seem to function).

The binding then worked perfectly initially . After a minute or so I again began getting the errors for monitor-4. I tried forcing an alarm on monitor-4 with openHAB and, to my surprise, this worked, with zoneminder registering the alarm. More surprisingly, the errors on monitor-4 then stopped. All now seems well.

I’ll keep an eye and let you know if anything changes.

Hi Mr_Eskildsen,

thanks for the binding and the effort you spend in it!

I have problems getting it up and running.
Installation went fine (“Active”) but whatever I use for configuration, I can’t get past “OFFLINE - COMMUNICATION_ERROR Cannot access ZoneMinder Server. Check provided usercredentials”.

My zoneminder is running fine (1.30)
I doublechecked user credentials
The api is accessible (when logged in with the same credentials)
Telnet port 6802 is up and responding, controlling zm via commands is running

So for now, I don’t know, where to look further on.
It would be very nice, if you could give me a hint, what to check


What you describe could have some other reasons, though the message doesn’t telt you.
Make sure the host points to your zoneminder server. Also be aware That https is not testet carefully. I knowhow there is problems when running older java and letsencrypt. If you are running https try to disable that.
If none of the suggestions works, please provide a debug log. I have updated the Wiki page with all the suggestions that I can think off

At some point this morning it stopped working, with

2017-01-26 07:54:29.756 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [WATCHDOG]: Server run(): Exception: {}

then attempting to force an alarm gets this error:

2017-01-26 08:03:30.651 [ERROR] [andler.ZoneMinderThingMonitorHandler] - [MONITOR-5]: handleCommand: Command='ON' failed for channel='force-alarm' Exception='null'

To me it looks like a discónnection problem. What is wondering me is that it should definitely try to reconnect. I assume all values in your sitemap changes to ‘UNDEF’ ?

Hi there, host should be ok, https is not used yet
I cut out a lot of logging and hope that I caught relevant part


2017-01-26 10:01:42.996 [DEBUG] [.smarthome.config.core.Configuration] - Setting value (String) 192.168.1.250 to field ‘hostname’ in configuration class org.openhab.binding.zoneminder.internal.config.ZoneMinderBridgeServerConfig
2017-01-26 10:01:42.996 [DEBUG] [.smarthome.config.core.Configuration] - Setting value (Integer) 0 to field ‘http_port’ in configuration class org.openhab.binding.zoneminder.internal.config.ZoneMinderBridgeServerConfig
2017-01-26 10:01:42.996 [DEBUG] [.smarthome.config.core.Configuration] - Setting value (Integer) 6802 to field ‘telnet_port’ in configuration class org.openhab.binding.zoneminder.internal.config.ZoneMinderBridgeServerConfig
2017-01-26 10:01:42.996 [DEBUG] [.smarthome.config.core.Configuration] - Setting value (String) http to field ‘protocol’ in configuration class org.openhab.binding.zoneminder.internal.config.ZoneMinderBridgeServerConfig
2017-01-26 10:01:42.996 [DEBUG] [.smarthome.config.core.Configuration] - Setting value (String) /zm to field ‘urlpath’ in configuration class org.openhab.binding.zoneminder.internal.config.ZoneMinderBridgeServerConfig
2017-01-26 10:01:42.996 [DEBUG] [.smarthome.config.core.Configuration] - Setting value (String) admin to field ‘user’ in configuration class org.openhab.binding.zoneminder.internal.config.ZoneMinderBridgeServerConfig
2017-01-26 10:01:42.996 [DEBUG] [.smarthome.config.core.Configuration] - Setting value (String) xyz to field ‘password’ in configuration class org.openhab.binding.zoneminder.internal.config.ZoneMinderBridgeServerConfig
2017-01-26 10:01:42.996 [DEBUG] [.smarthome.config.core.Configuration] - Setting value (Integer) 10 to field ‘refresh_interval’ in configuration class org.openhab.binding.zoneminder.internal.config.ZoneMinderBridgeServerConfig
2017-01-26 10:01:42.996 [DEBUG] [.smarthome.config.core.Configuration] - Setting value (Integer) 0 to field ‘refresh_interval_disk_usage’ in configuration class org.openhab.binding.zoneminder.internal.config.ZoneMinderBridgeServerConfig
2017-01-26 10:01:42.996 [DEBUG] [.smarthome.config.core.Configuration] - Setting value (Boolean) true to field ‘autodiscover_things’ in configuration class org.openhab.binding.zoneminder.internal.config.ZoneMinderBridgeServerConfig
2017-01-26 10:01:42.996 [DEBUG] [.www.protocol.http.HttpURLConnection] - sun.net.www.MessageHeader@1fe0e5b8 pairs: {GET /zm/index.php HTTP/1.1: null}{User-Agent: Mozilla/5.0}{Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8}{Accept-Language: en-US,en;q=0.5}{Cache-Control: no-cache}{Pragma: no-cache}{Host: 192.168.1.250}{Connection: keep-alive}
2017-01-26 10:01:43.011 [DEBUG] [.www.protocol.http.HttpURLConnection] - sun.net.www.MessageHeader@545aaf15 pairs: {null: HTTP/1.1 200 OK}{Date: Thu, 26 Jan 2017 09:02:16 GMT}{Server: Apache/2.4.7 (Ubuntu)}{X-Powered-By: PHP/5.5.9-1ubuntu4.20}{Set-Cookie: ZMSESSID=5v7b98spm41sf7ihf9bq9j2co4; path=/}{Expires: Thu, 19 Nov 1981 08:52:00 GMT}{Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0}{Pragma: no-cache}{Set-Cookie: zmSkin=classic; expires=Sat, 05-Dec-2026 09:02:16 GMT; Max-Age=311040000}{Set-Cookie: zmCSS=flat; expires=Sat, 05-Dec-2026 09:02:16 GMT; Max-Age=311040000}{Vary: Accept-Encoding}{Content-Length: 2570}{Keep-Alive: timeout=5, max=100}{Connection: Keep-Alive}{Content-Type: text/html; charset=utf-8}
2017-01-26 10:01:43.011 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - BRIDGE [c6554e88]: setBridgeConnection(): Set Bridge to OFFLINE
2017-01-26 10:01:43.011 [INFO ] [smarthome.event.ThingStatusInfoEvent] - ‘zoneminder:server:c6554e88’ updated: OFFLINE (COMMUNICATION_ERROR): Cannot access ZoneMinder Server. Check provided usercredentials

Thanks in advance!