ZoneMinder Binding in Marketplace (Beta)

Deleted all my Server and Monitor things, then installed the new binding (downloaded it and placed it in addons folder, as I don’t use Paper UI to install bindings).

Added my server thing and I see this.

2018-02-25 10:01:43.960 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='constructor' Starting ZoneMinder Server Bridge Handler (Bridge='null')
2018-02-25 10:01:43.971 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: ZoneMinder Server Bridge Handler Initialized
2018-02-25 10:01:49.883 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='updateBridgeStatus' Bridge status changed from 'OFFLINE' to 'ONLINE'
2018-02-25 10:01:50.689 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: Properties synchronised, Thing id: zm
2018-02-25 10:02:00.605 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [WATCHDOG]: Server run(): StackTrace: File='ZoneMinderDiscoveryService.java', Line='103', Method='discoverMonitors', Exception: null
2018-02-25 10:02:11.923 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [WATCHDOG]: Server run(): StackTrace: File='ZoneMinderDiscoveryService.java', Line='103', Method='discoverMonitors', Exception: null
2018-02-25 10:02:23.242 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [WATCHDOG]: Server run(): StackTrace: File='ZoneMinderDiscoveryService.java', Line='103', Method='discoverMonitors', Exception: null

Seems reproducible, since deleting and adding server thing consistently produces the same result.

Stop/start of the binding produced this. Really weird because I don’t have any Monitor things.

2018-02-25 10:06:06.136 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='dispose' Stopping Discovery service
2018-02-25 10:06:06.138 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='dispose' Stopping WatchDog task
2018-02-25 10:06:06.138 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='dispose' Stopping refresh data task
2018-02-25 10:06:13.149 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='constructor' Starting ZoneMinder Server Bridge Handler (Bridge='null')
2018-02-25 10:06:13.150 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: ZoneMinder Server Bridge Handler Initialized
2018-02-25 10:06:19.064 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='updateBridgeStatus' Bridge status changed from 'OFFLINE' to 'ONLINE'
2018-02-25 10:06:25.918 [WARN ] [andler.ZoneMinderThingMonitorHandler] - [MONITOR-5]: context='onTrippedForceAlarm' Skipping event 'name.eskildsen.zoneminder.api.telnet.ZoneMinderTriggerEvent@7a053b53', because Thing is 'OFFLINE'
2018-02-25 10:06:25.918 [WARN ] [andler.ZoneMinderThingMonitorHandler] - [MONITOR-5]: context='onTrippedForceAlarm' Skipping event 'name.eskildsen.zoneminder.api.telnet.ZoneMinderTriggerEvent@5ed575ee', because Thing is 'OFFLINE'
2018-02-25 10:06:29.791 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [WATCHDOG]: Server run(): StackTrace: File='ZoneMinderDiscoveryService.java', Line='103', Method='discoverMonitors', Exception: null
2018-02-25 10:06:41.108 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [WATCHDOG]: Server run(): StackTrace: File='ZoneMinderDiscoveryService.java', Line='103', Method='discoverMonitors', Exception: null
2018-02-25 10:06:52.427 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [WATCHDOG]: Server run(): StackTrace: File='ZoneMinderDiscoveryService.java', Line='103', Method='discoverMonitors', Exception: null
2018-02-25 10:07:03.747 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [WATCHDOG]: Server run(): StackTrace: File='ZoneMinderDiscoveryService.java', Line='103', Method='discoverMonitors', Exception: null
2018-02-25 10:07:15.065 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [WATCHDOG]: Server run(): StackTrace: File='ZoneMinderDiscoveryService.java', Line='103', Method='discoverMonitors', Exception: null
2018-02-25 10:07:26.382 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [WATCHDOG]: Server run(): StackTrace: File='ZoneMinderDiscoveryService.java', Line='103', Method='discoverMonitors', Exception: null
2018-02-25 10:07:37.702 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [WATCHDOG]: Server run(): StackTrace: File='ZoneMinderDiscoveryService.java', Line='103', Method='discoverMonitors', Exception: null
2018-02-25 10:07:49.020 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [WATCHDOG]: Server run(): StackTrace: File='ZoneMinderDiscoveryService.java', Line='103', Method='discoverMonitors', Exception: null

Stopped the binding, and looking at threads, I see five of these. I would expect to see none with the binding stopped.

"Thread-1185" Id=68943 in RUNNABLE (running in native)
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
    at java.net.SocketInputStream.read(SocketInputStream.java:171)
    at java.net.SocketInputStream.read(SocketInputStream.java:141)
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
      - locked java.io.InputStreamReader@4ccd7f9f
    at java.io.InputStreamReader.read(InputStreamReader.java:184)
    at java.io.BufferedReader.fill(BufferedReader.java:161)
    at java.io.BufferedReader.readLine(BufferedReader.java:324)
      - locked java.io.InputStreamReader@4ccd7f9f
    at java.io.BufferedReader.readLine(BufferedReader.java:389)
    at name.eskildsen.zoneminder.socket.SocketReader.poll(SocketReader.java:75)
    at name.eskildsen.zoneminder.event.ZoneMinderEventManager$TCPListener.run(ZoneMinderEventManager.java:196)
    at java.lang.Thread.run(Thread.java:748)

Even after uninstalling the binding (by removing it from addons), the threads are still hanging around.

There are 5 of these threads, which happens to coincide with the number of Monitor things I had (before I deleted them). Is there a possibility that the monitor threads are not being canceled when Monitor things are deleted?

I’m on build 1218, BTW.

Hmmmm, looks quite strange.

Are you installing the Binding in the addons folder? I have seen weird things in my setup, where it seems like the old Binding doesn’t get uninstalled right away.

Yes. I only ever install bindings using addons.cfg (if the binding is part of the official OH distro) and using the addons directory for all other bindings. I don’t use Paper UI to install/uninstall any bindings.

The system where I’m running zoneminder rarely gets restarted. I’ll run some tests on my test system, which has never had zoneminder installed. That way, if I need to restart OH to clear out threads, I can do that as often as necessary. I’ll let you know what I find out.

Here’s what I did on my test system (which has never had zoneminder).

  • added the binding to the addons directory
  • set log level to DEBUG
  • stopped the binding
  • started the binding (did this and the above to capture the log from the binding starting
  • added a server thing
  • note I do not have zoneminder authentication enabled

The result was this.

2018-02-25 11:25:10.736 [DEBUG] [org.openhab.binding.zoneminder      ] - BundleEvent STOPPING - org.openhab.binding.zoneminder
2018-02-25 11:25:10.739 [DEBUG] [org.openhab.binding.zoneminder      ] - ServiceEvent UNREGISTERING - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={component.name=binding.zoneminder, component.id=347, service.id=737, service.bundleid=238, service.scope=bundle} - org.openhab.binding.zoneminder
2018-02-25 11:25:10.747 [DEBUG] [org.openhab.binding.zoneminder      ] - BundleEvent STOPPED - org.openhab.binding.zoneminder
2018-02-25 11:25:18.915 [DEBUG] [org.openhab.binding.zoneminder      ] - BundleEvent STARTING - org.openhab.binding.zoneminder
2018-02-25 11:25:18.916 [DEBUG] [org.openhab.binding.zoneminder      ] - BundleEvent STARTED - org.openhab.binding.zoneminder
2018-02-25 11:25:18.919 [DEBUG] [org.openhab.binding.zoneminder      ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={component.name=binding.zoneminder, component.id=348, service.id=738, service.bundleid=238, service.scope=bundle} - org.openhab.binding.zoneminder
2018-02-25 11:26:07.216 [DEBUG] [er.internal.ZoneMinderHandlerFactory] - [FACTORY]: creating handler for bridge thing 'org.eclipse.smarthome.core.thing.internal.BridgeImpl@d5593558'
2018-02-25 11:26:07.219 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='constructor' Starting ZoneMinder Server Bridge Handler (Bridge='null')
2018-02-25 11:26:07.223 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: ZoneMinder Server Bridge Handler Initialized
2018-02-25 11:26:07.223 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]:    HostName:           zoneminder
2018-02-25 11:26:07.224 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]:    Protocol:           http
2018-02-25 11:26:07.224 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]:    Port HTTP(S)        80
2018-02-25 11:26:07.224 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]:    Port Telnet         6802
2018-02-25 11:26:07.224 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]:    Portal Path         /zm
2018-02-25 11:26:07.224 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]:    API Path            /zm/api
2018-02-25 11:26:07.224 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]:    Refresh interval:   10
2018-02-25 11:26:07.224 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]:    Low  prio. refresh: 60
2018-02-25 11:26:07.224 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]:    Autodiscovery:      true
2018-02-25 11:26:07.224 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: Starting ZoneMinder Bridge Monitor Task. Command='org.openhab.binding.zoneminder.handler.ZoneMinderServerBridgeHandler$1@5c3e1fdc'
2018-02-25 11:26:12.225 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='verifyBindingConfiguration' state='OFFLINE' check='PASSED'
2018-02-25 11:26:12.298 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='validateConfig' previousState='OFFLINE' Socket connection to ZM Website (PASSED)
2018-02-25 11:26:13.018 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='validateConnection' - ZoneMinderFactory.CreateConnection() called (Protocol='http', Host='zoneminder', HttpPort='80', SocketPort='6802', Path='/zm', API='/zm/api')
2018-02-25 11:26:13.018 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='validateConnection' previousState='OFFLINE' ZoneMinder Connection check (PASSED)
2018-02-25 11:26:13.322 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='validateZoneMinderServerConfig' check='PASSED' - ZoneMinder
2018-02-25 11:26:13.323 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='updateBridgeStatus' Bridge status changed from 'OFFLINE' to 'ONLINE'
2018-02-25 11:26:13.324 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: [zm]: onConnected(): Bridge Connected!
2018-02-25 11:26:13.525 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='onBridgeConnected'    Api Enabled :            true
2018-02-25 11:26:13.525 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='onBridgeConnected'    Authentication Enabled : false
2018-02-25 11:26:13.525 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='onBridgeConnected'    AuthHash Allowed :       false
2018-02-25 11:26:13.526 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='onBridgeConnected'    Portal URI:              http://zoneminder:80/zm
2018-02-25 11:26:13.526 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='onBridgeConnected'    API URI:                 http://zoneminder:80/zm/api
2018-02-25 11:26:13.526 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='onBridgeConnected'    ZMS URI:                 /zm/cgi-bin/nph-zms
2018-02-25 11:26:13.526 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: context='onBridgeConnected'    FrameServer:             false
2018-02-25 11:26:13.527 [DEBUG] [discovery.ZoneMinderDiscoveryService] - [DISCOVERY]: Activating ZoneMinder discovery service for zoneminder:server:zm
2018-02-25 11:26:13.528 [DEBUG] [org.openhab.binding.zoneminder      ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.DiscoveryService}={service.id=739, service.bundleid=238, service.scope=singleton} - org.openhab.binding.zoneminder
2018-02-25 11:26:14.131 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: Properties synchronised, Thing id: zm
2018-02-25 11:26:14.132 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: Starting ZoneMinder Bridge Monitor Task. Command='org.openhab.binding.zoneminder.handler.ZoneMinderServerBridgeHandler$2@78f2cad1'
2018-02-25 11:26:14.132 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]:  context='initializeAvaliabilityStatus' Successfully established session to ZoneMinder Server.
2018-02-25 11:26:15.234 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: URL='http://zoneminder/zm/api/host/getLoad.json' ResponseCode='200' ResponseMessage='OK'
2018-02-25 11:26:24.338 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: URL='http://zoneminder/zm/api/host/getLoad.json' ResponseCode='200' ResponseMessage='OK'
2018-02-25 11:26:24.545 [DEBUG] [discovery.ZoneMinderDiscoveryService] - [DISCOVERY]: Performing background discovery scan for zoneminder:server:zm
2018-02-25 11:26:24.650 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [WATCHDOG]: Server run(): StackTrace: File='ZoneMinderDiscoveryService.java', Line='103', Method='discoverMonitors', Exception: null
2018-02-25 11:26:34.441 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: URL='http://zoneminder/zm/api/host/getLoad.json' ResponseCode='200' ResponseMessage='OK'
2018-02-25 11:26:36.564 [DEBUG] [discovery.ZoneMinderDiscoveryService] - [DISCOVERY]: Performing background discovery scan for zoneminder:server:zm
2018-02-25 11:26:36.665 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [WATCHDOG]: Server run(): StackTrace: File='ZoneMinderDiscoveryService.java', Line='103', Method='discoverMonitors', Exception: null
2018-02-25 11:26:44.545 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (zm)]: URL='http://zoneminder/zm/api/host/getLoad.json' ResponseCode='200' ResponseMessage='OK'
2018-02-25 11:26:48.578 [DEBUG] [discovery.ZoneMinderDiscoveryService] - [DISCOVERY]: Performing background discovery scan for zoneminder:server:zm
2018-02-25 11:26:48.680 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [WATCHDOG]: Server run(): StackTrace: File='ZoneMinderDiscoveryService.java', Line='103', Method='discoverMonitors', Exception: null

Not having much luck here. Since discovery wasn’t working, I decided to manually add a monitor.

  • disabled auto-discovery in the Server thing config
  • in the PaperUI inbox, I clicked the + button, then selected Zoneminder from the list of bindings
  • that generated the NPE below
  • selected Add Manually
  • selected Zoneminder Monitor
  • added a monitor, which worked ok
2018-02-25 11:54:00.246 [DEBUG] [discovery.ZoneMinderDiscoveryService] - [DISCOVERY]: Starting discovery scan for zoneminder:server:zm
2018-02-25 11:54:00.348 [ERROR] [nternal.DiscoveryServiceRegistryImpl] - Cannot trigger scan for thing types '[zoneminder:monitor]' on 'ZoneMinderDiscoveryService'!
java.lang.NullPointerException: null
        at org.openhab.binding.zoneminder.internal.discovery.ZoneMinderDiscoveryService.discoverMonitors(ZoneMinderDiscoveryService.java:103) [238:org.openhab.binding.zoneminder:2.3.0.201802251429]
        at org.openhab.binding.zoneminder.internal.discovery.ZoneMinderDiscoveryService.startScan(ZoneMinderDiscoveryService.java:77) [238:org.openhab.binding.zoneminder:2.3.0.201802251429]
        at org.eclipse.smarthome.config.discovery.AbstractDiscoveryService.startScan(AbstractDiscoveryService.java:209) [104:org.eclipse.smarthome.config.discovery:0.10.0.201802131303]
        at org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.startScan(DiscoveryServiceRegistryImpl.java:427) [104:org.eclipse.smarthome.config.discovery:0.10.0.201802131303]
        at org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.startScans(DiscoveryServiceRegistryImpl.java:412) [104:org.eclipse.smarthome.config.discovery:0.10.0.201802131303]
        at org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.startScan(DiscoveryServiceRegistryImpl.java:260) [104:org.eclipse.smarthome.config.discovery:0.10.0.201802131303]
        at org.eclipse.smarthome.io.rest.core.internal.discovery.DiscoveryResource.scan(DiscoveryResource.java:97) [126:org.eclipse.smarthome.io.rest.core:0.10.0.201802131303]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
        at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [178:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [178:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [178:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [178:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [178:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [178:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [178:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [178:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [178:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [177:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [177:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [177:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [177:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [177:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [177:org.glassfish.jersey.core.jersey-common:2.22.2]
        at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [178:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [178:org.glassfish.jersey.core.jersey-server:2.22.2]
        at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473) [175:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
        at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427) [175:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388) [175:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341) [175:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228) [175:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
        at com.eclipsesource.jaxrs.publisher.internal.ServletContainerBridge.service(ServletContainerBridge.java:76) [15:com.eclipsesource.jaxrs.publisher:5.3.1.201602281253]
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:848) [88:org.eclipse.jetty.servlet:9.3.22.v20171030]
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:584) [88:org.eclipse.jetty.servlet:9.3.22.v20171030]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71) [191:org.ops4j.pax.web.pax-web-jetty:6.0.7]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [87:org.eclipse.jetty.server:9.3.22.v20171030]
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) [85:org.eclipse.jetty.security:9.3.22.v20171030]
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226) [87:org.eclipse.jetty.server:9.3.22.v20171030]
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180) [87:org.eclipse.jetty.server:9.3.22.v20171030]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:284) [191:org.ops4j.pax.web.pax-web-jetty:6.0.7]
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512) [88:org.eclipse.jetty.servlet:9.3.22.v20171030]
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) [87:org.eclipse.jetty.server:9.3.22.v20171030]
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112) [87:org.eclipse.jetty.server:9.3.22.v20171030]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [87:org.eclipse.jetty.server:9.3.22.v20171030]
        at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80) [191:org.ops4j.pax.web.pax-web-jetty:6.0.7]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134) [87:org.eclipse.jetty.server:9.3.22.v20171030]
        at org.eclipse.jetty.server.Server.handle(Server.java:534) [87:org.eclipse.jetty.server:9.3.22.v20171030]
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:333) [87:org.eclipse.jetty.server:9.3.22.v20171030]
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251) [87:org.eclipse.jetty.server:9.3.22.v20171030]
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:283) [79:org.eclipse.jetty.io:9.3.22.v20171030]
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:108) [79:org.eclipse.jetty.io:9.3.22.v20171030]
        at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93) [79:org.eclipse.jetty.io:9.3.22.v20171030]
        at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303) [90:org.eclipse.jetty.util:9.3.22.v20171030]
        at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148) [90:org.eclipse.jetty.util:9.3.22.v20171030]
        at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136) [90:org.eclipse.jetty.util:9.3.22.v20171030]
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671) [90:org.eclipse.jetty.util:9.3.22.v20171030]
        at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589) [90:org.eclipse.jetty.util:9.3.22.v20171030]
        at java.lang.Thread.run(Thread.java:748) [?:?]

Embarassing. It is because the version of openHAB that you have has the fix regarding discovery that I was talking about. So in my code I am missin g a null pointer check . I will upload a corrected binding in a few minutes, just have to test it by myself :-).

I have found and corrected a problem related to Detailed status channel. The detailed-status, sometimes returned “Unknown”, causing the Binding to go offline. In my setup I saw this quite often, but that depends on your settings in ZoneMinder. Whille identifying the above problem, I have changed/improved error handling where appropriate. I have also corrected compiler warnings.

The Marketplace Binding has been updated with above fix.

I have indications that the event listener doesn’t disconnect correct. I will look into that, as it gives a lot of warnings:

28-feb.-2018 22:16:55.087 [WARN ] [g.zoneminder.handler.ZoneMinderThingMonitorHandler] - [MONITOR-1]: context='onTrippedForceAlarm' Skipping event 'name.eskildsen.zoneminder.api.telnet.ZoneMinderTriggerEvent@eab3d8', because Thing is 'OFFLINE'

zoneminder version": “1.31.44”, on ubuntu 18.04.2
api version": “1.0”
php 7.2.7
CakePHP 2.10.8

openhab 2.4.0-SNAPSHOT Build #1313
ZoneMinder Binding 2.3.0.201805211219

The zoneminder (1.31.44) is running well alone. So is the openhab
But this beta binding doesn’t work. Nor the 2.4.0.SNAPSHOT. Do we still have a working binding now?

openhab> bundle:list | grep ZoneMinder
242 │ Active │ 80 │ 2.3.0.201805211219 │ ZoneMinder Binding

PaperUI shows
Status: OFFLINE - CONFIGURATION_ERROR ZoneMinder Server Connection error

11:22:20.471 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'zoneminder:server:2650bd92' changed from OFFLINE: Retrying to connect to OFFLINE: Connecting to ZoneMinder Server
11:22:20.980 [ERROR] [handler.ZoneMinderServerBridgeHandler] - [BRIDGE (2650bd92)]: context='validateConnection' check='FAILED' - General error when creating ConnectionInfo. Retrying next cycle...
name.eskildsen.zoneminder.exception.ZoneMinderResponseException:  - HttpStatus='404', HttpMessage='Not Found', Request='http://192.168.11.15/zm/api/configs/view/ZM_PATH_ZMS.json', ExceptionMessage='Invalid config'
	at name.eskildsen.zoneminder.jetty.JettyConnectionInfo.fetchContentResponse(JettyConnectionInfo.java:161) ~[242:org.openhab.binding.zoneminder:2.3.0.201805211219]
	at name.eskildsen.zoneminder.jetty.JettyConnectionInfo.fetchDataAsJson(JettyConnectionInfo.java:349) ~[242:org.openhab.binding.zoneminder:2.3.0.201805211219]
	at name.eskildsen.zoneminder.jetty.JettyConnectionInfo.onConnect(JettyConnectionInfo.java:288) ~[242:org.openhab.binding.zoneminder:2.3.0.201805211219]
	at name.eskildsen.zoneminder.internal.GenericConnectionHandler.connect(GenericConnectionHandler.java:141) ~[242:org.openhab.binding.zoneminder:2.3.0.201805211219]
	at name.eskildsen.zoneminder.ZoneMinderFactory.CreateConnection(ZoneMinderFactory.java:34) ~[242:org.openhab.binding.zoneminder:2.3.0.201805211219]
	at org.openhab.binding.zoneminder.handler.ZoneMinderServerBridgeHandler.validateConnection(ZoneMinderServerBridgeHandler.java:801) [242:org.openhab.binding.zoneminder:2.3.0.201805211219]
	at org.openhab.binding.zoneminder.handler.ZoneMinderServerBridgeHandler.initializeAvaliabilityStatus(ZoneMinderServerBridgeHandler.java:1036) [242:org.openhab.binding.zoneminder:2.3.0.201805211219]
	at org.openhab.binding.zoneminder.handler.ZoneMinderServerBridgeHandler.updateAvaliabilityStatus(ZoneMinderServerBridgeHandler.java:1197) [242:org.openhab.binding.zoneminder:2.3.0.201805211219]
	at org.openhab.binding.zoneminder.handler.ZoneMinderServerBridgeHandler$1.run(ZoneMinderServerBridgeHandler.java:114) [242:org.openhab.binding.zoneminder:2.3.0.201805211219]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]
11:22:20.982 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'zoneminder:server:2650bd92' changed from OFFLINE: Connecting to ZoneMinder Server to OFFLINE (CONFIGURATION_ERROR): ZoneMinder Server Connection error

http://192.168.11.15/zm/api/configs/view/ZM_PATH_ZMS.json

|success|false|
|---|---|
|data||
|name|"Invalid config"|
|message|"Invalid config"|
|url|"/zm/api/configs/view/ZM_PATH_ZMS.json"|
|exception||
|class|"NotFoundException"|
|code|404|
|message|"Invalid config"|
|trace||
|0|"#0 [internal function]: ConfigsController->view('ZM_PATH_ZMS')"|
|1|"#1 /usr/share/zoneminder/www/api/lib/Cake/Controller/Controller.php(491): ReflectionMethod->invokeArgs(Object(ConfigsController), Array)"|
|2|"#2 /usr/share/zoneminder/www/api/app/Plugin/Crud/Lib/CrudControllerTrait.php(31): Controller->invokeAction(Object(CakeRequest))"|
|3|"#3 /usr/share/zoneminder/www/api/lib/Cake/Routing/Dispatcher.php(193): AppController->invokeAction(Object(CakeRequest))"|
|4|"#4 /usr/share/zoneminder/www/api/lib/Cake/Routing/Dispatcher.php(167): Dispatcher->_invoke(Object(ConfigsController), Object(CakeRequest))"|
|5|"#5 /usr/share/zoneminder/www/api/app/webroot/index.php(107): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))"|
|6|"#6 {main}"|
|queryLog||
|default||
|log||
|0||
|query|"SELECT `Config`.`Id`, `Config`.`Name`, `Config`.`Value`, `Config`.`Type`, `Config`.`DefaultValue`, `Config`.`Hint`, `Config`.`Pattern`, `Config`.`Format`, `Config`.`Prompt`, `Config`.`Help`, `Config`.`Category`, `Config`.`Readonly`, `Config`.`Requires` FROM `zm`.`Config` AS `Config`   WHERE `Config`.`Name` = 'ZM_OPT_USE_API'    LIMIT 1"|
|params|[]|
|affected|1|
|numRows|1|
|took|0|
|1||
|query|"SELECT `Config`.`Id`, `Config`.`Name`, `Config`.`Value`, `Config`.`Type`, `Config`.`DefaultValue`, `Config`.`Hint`, `Config`.`Pattern`, `Config`.`Format`, `Config`.`Prompt`, `Config`.`Help`, `Config`.`Category`, `Config`.`Readonly`, `Config`.`Requires` FROM `zm`.`Config` AS `Config`   WHERE `Config`.`Name` = 'ZM_OPT_USE_AUTH'    LIMIT 1"|
|params|[]|
|affected|1|
|numRows|1|
|took|0|
|2||
|query|"SELECT `User`.`Id`, `User`.`Username`, `User`.`Password`, `User`.`Language`, `User`.`Enabled`, `User`.`Stream`, `User`.`Events`, `User`.`Control`, `User`.`Monitors`, `User`.`Groups`, `User`.`Devices`, `User`.`System`, `User`.`MaxBandwidth`, `User`.`MonitorIds` FROM `zm`.`Users` AS `User`   WHERE `User`.`Username` = 'shark'    LIMIT 1"|
|params|[]|
|affected|1|
|numRows|1|
|took|0|
|3||
|query|"SELECT COUNT(*) AS `count` FROM `zm`.`Config` AS `Config`   WHERE `Config`.`Name` = 'ZM_PATH_ZMS'"|
|params|[]|
|affected|1|
|numRows|1|
|took|0|
|4||
|query|"SELECT `Config`.`Id`, `Config`.`Name`, `Config`.`Value`, `Config`.`Type`, `Config`.`DefaultValue`, `Config`.`Hint`, `Config`.`Pattern`, `Config`.`Format`, `Config`.`Prompt`, `Config`.`Help`, `Config`.`Category`, `Config`.`Readonly`, `Config`.`Requires` FROM `zm`.`Config` AS `Config`   WHERE `Config`.`Name` = 'ZM_OPT_USE_API'    LIMIT 1"|
|params|[]|
|affected|1|
|numRows|1|
|took|0|
|5||
|query|"SELECT `Config`.`Id`, `Config`.`Name`, `Config`.`Value`, `Config`.`Type`, `Config`.`DefaultValue`, `Config`.`Hint`, `Config`.`Pattern`, `Config`.`Format`, `Config`.`Prompt`, `Config`.`Help`, `Config`.`Category`, `Config`.`Readonly`, `Config`.`Requires` FROM `zm`.`Config` AS `Config`   WHERE `Config`.`Name` = 'ZM_OPT_USE_AUTH'    LIMIT 1"|
|params|[]|
|affected|1|
|numRows|1|
|took|0|
|6||
|query|"SELECT `User`.`Id`, `User`.`Username`, `User`.`Password`, `User`.`Language`, `User`.`Enabled`, `User`.`Stream`, `User`.`Events`, `User`.`Control`, `User`.`Monitors`, `User`.`Groups`, `User`.`Devices`, `User`.`System`, `User`.`MaxBandwidth`, `User`.`MonitorIds` FROM `zm`.`Users` AS `User`   WHERE `User`.`Username` = 'shark'    LIMIT 1"|
|params|[]|
|affected|1|
|numRows|1|
|took|0|
|count|7|
|time|0|

It seems like there is a configuration error in your zoneminder server. A correct response would look like:

{"config":{"Config":{"Id":"18","Name":"ZM_PATH_ZMS","Value":"\/zm\/cgi-bin\/zms","Type":"string","DefaultValue":"\/cgi-bin\/nph-zms","Hint":"relative\/path\/to\/somewhere","Pattern":"(?^:^((?:[^\/].*)?)\/?$)","Format":" $1 ","Prompt":"Web path to zms streaming server","Help":" The ZoneMinder streaming server is required to send streamed images to your browser. It will be installed into the cgi-bin path given at configuration time. This option determines what the web path to the server is rather than the local path on your machine. Ordinarily the streaming server runs in parser-header mode however if you experience problems with streaming you can change this to non-parsed-header (nph) mode by changing 'zms' to 'nph-zms'. ","Category":"paths","Readonly":"0","Requires":null}}}

Make sure ZM_PATH_ZMS is configured correctly in ZoneMinder

It seems in the newest version of ZoneMinder the url to call is /zm/api/configs/viewByName/ZM_PATH_ZMS.json

Another factor… if you want to upgrade to PHP7, then you need the latest Zoneminder because of a required change in the cakePHP framework (bundled with ZM)… and obviously, the latest ZM requires PHP7 too.

I don’t understand why ZM would put in a breaking API change like this (view_>viewByName). The documentation still references view. Maybe the binding could detect ZM versions in order to use the appropriate API locations (/zm/api//host/getVersion.json)? But I think there’s already a call to this. Decompiling the jar and comparing to the code submitted in the PR, there appear to be a lot of files missing? @mr_eskildsen, can you help explain where the missing files are? For example, where is this?

at name.eskildsen.zoneminder.IZoneMinderResponse.createFromJson(IZoneMinderResponse.java:24) ~[277:org.openhab.binding.zoneminder:2.3.0.201805211219]

Unfortunately I have had some private matters that I have had to deal with the last couple of months, so I haven’t really spent some time on openHAB / ZoneMinder lately.

What version of ZoneMinder do you refer to as newest version? As far as I can see, the download page refers to 1.30.4, which is the version I run, and it should work fine (at least for me :slight_smile: )

I just checked the code. It shouldn’t be a big problem (besides from time), to have different appraches deopending on the version. But I really need some advice on what to use for which versions (again time is a factor for me)

@mr_eskildsen I’m running ZoneMinder in a docker container. Tried both https://hub.docker.com/r/quantumobject/docker-zoneminder/ and https://hub.docker.com/r/linuxserver/zoneminder/ (Second one is easier if your new to docker)

The version is [zoneminder v1.31.44]

Let me know if I can help.

Thank you… I could not find any reference to this library in the PR!

In looking at this some more, I do not think changing the binding to make different API calls based on the ZM version will be enough. At ZM 1.31.1, some configuration settings were moved from the database to files. These settings are no longer available through the API. The ZM team has made a few of them available, but only through /zm/api/configs/viewByName. Of the configuration settings moved to the file, the only one that the binding uses is ZM_PATH_ZMS. In addition to this, ZM_OPT_FRAME_SERVER appears to have been completely removed.

To make the binding compatible with the updated version of ZM, my suggestion is to update the binding anywhere it uses the config details from the view call for ZM_PATH_ZM (name, type, category, readonly), and change the call for the value to use viewAsName. Or, we could request that the ZM team add it to view and not just viewByName. Also, any reference to ZM_OPT_FRAME_SERVER would need to be removed. Fortunately, I believe these binding changes would be compatible with previous versions of ZM too.

My wife (always my hero!) came up with a workaround for using the binding (2.3.0.201805211219) with the current ZM master snapshot build (ZM 1.31.45). Basically, put the ZM_PATH_ZMS and ZM_OPT_FRAME_SERVER records back into the Config table, and then modify the config.php to ignore them.

1 Like

I really hoped that the API finally was getting stable :frowning:

Thanks for the fix. I have been down for a while and would like to get ZM back into my OH setup. I don’t know much about SQL syntax or whatever, but I seem to be having difficulty inserting those records into the table. Not sure if it is a character set problem from copying and pasting off your wife’s page or what. Any ideas? Thx.

Database changed
MariaDB [zm]> INSERT INTO `Config` VALUES (225,’ZM_PATH_ZMS’,’/cgi-bin-zm/nph-zms’,’string’,’/cgi-bin-zm/nph-zms’,’relative/path/to/somewhere’,'(?^:^((?:[^/].*)?)/?$)’,’ $1 ‘,’Web path to zms streaming server’,’ The ZoneMinder streaming server is required to send streamed images to your browser. It will be installed into the cgi-bin path given at configuration time. This option determines what the web path to the server is rather than the local path on your machine. Ordinarily the streaming server runs in parser-header mode however if you experience problems with streaming you can change this to non-parsed-header (nph) mode by changing \’zms\’ to \’nph-zms\’. ‘,’hidden’,0,NULL);
    '> ';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'to/somewhere’,'(?^:^((?:[^/].*)?)/?$)’,’ $1 ‘,’Web path to zms streami' at line 1
MariaDB [zm]>

It looks like she forgot a semicolon at the end of the first one (fixed)… but you caught that. Try again… the formatting was getting mixed up because it was not posted as preformatted text (apostrophes were being converted to right and left single quotes). Same problem with the PHP code. Sorry about that!

That did it. Thanks to you and your lovely wife :slight_smile:

I figured it was something to do with that, but got reading about curly quotes, smart quotes, apostrophes, etc, etc and figured I would ask for a little help!

1 Like

Just in case anyone’s interested, after a couple of years I have finally given up on zoneminder. A frustrating experience trying to recover video from an event did it for me. That and monitors occasionally stopping working for no bloody reason at all.

Quite hard to find linux alternatives - the other open source ones all have their own problems (mostly rubbish motion detection). I ended up with Xeoma.

Downsides: not open source, costs £, made by a Russian company nobody has ever heard of, has server/client model but client has to run their software rather than just accessing through the web, very few resources to help if you run into trouble.

Upsides: works reliably, decent support from company, has robust motion detection, takes up 1/3 the CPU and 1/10th the disk space of zoneminder, whilst recording in higher resolution and including audio. Client runs on just about anything. Integrates easily with OH2.

Happy to give more details if anyone is interested.

(Full disclosure: Xeoma apparently has the very naughty habit of giving free licenses to people in exchange for favourable reviews. I paid for my licence!)

1 Like