Zoneminder binding

I have updated to latest build and now it starts to connect (consistently) as expected. The strange thing though is that in console it is still reporting Build #929, so I am uncertain if the upgrade is done completely. Also Zwave seems to work, but haven’t testet in details…

The breaking change only impacts the development version of ZWave at this time, and hopefully in 30 minutes or so I’ll compile up a new one anyway…

I don’t restart openHAB very often, but when I do, the zoneminder binding often fails, giving me a series of messages like this:

2017-06-26 09:08:12.862 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [MONITOR]: Method 'refreshThing()' for Bridge failed for thing='zoneminder:monitor:zm:monitor-5' - Exception='java.lang.ClassCastException: org.openhab.binding.zoneminder.handler.ZoneMinderThingMonitorHandler cannot be cast to org.openhab.binding.zoneminder.handler.ZoneMinderBaseThingHandler'

The only solution I’ve found that works is to manually delete all the cameras and zoneminder server Things, restart openHAB, and then re-add them.

Anyone else seeing this?

Dan

1 Like

I’ve recently updated to the 7/1 snapshot and I’m seeing better performance until this happens:

06:26:08.892 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [MONITOR]: Method 'refreshThing()' for Bridge failed for thing='zoneminder:monitor:756ae518:monitor-1' - Exception='java.lang.NullPointerException'
06:26:10.328 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [MONITOR]: Method 'refreshThing()' for Bridge failed for thing='zoneminder:monitor:756ae518:monitor-1' - Exception='java.lang.NullPointerException'
06:26:11.761 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [MONITOR]: Method 'refreshThing()' for Bridge failed for thing='zoneminder:monitor:756ae518:monitor-1' - Exception='java.lang.NullPointerException'
06:26:13.237 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [MONITOR]: Method 'refreshThing()' for Bridge failed for thing='zoneminder:monitor:756ae518:monitor-1' - Exception='java.lang.NullPointerException'
06:26:14.674 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [MONITOR]: Method 'refreshThing()' for Bridge failed for thing='zoneminder:monitor:756ae518:monitor-1' - Exception='java.lang.NullPointerException'
06:26:16.409 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [MONITOR]: Method 'refreshThing()' for Bridge failed for thing='zoneminder:monitor:756ae518:monitor-1' - Exception='java.lang.NullPointerException'
06:26:17.862 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [MONITOR]: Method 'refreshThing()' for Bridge failed for thing='zoneminder:monitor:756ae518:monitor-1' - Exception='java.lang.NullPointerException'
06:26:19.291 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [MONITOR]: Method 'refreshThing()' for Bridge failed for thing='zoneminder:monitor:756ae518:monitor-1' - Exception='java.lang.NullPointerException'
06:26:20.763 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [MONITOR]: Method 'refreshThing()' for Bridge failed for thing='zoneminder:monitor:756ae518:monitor-1' - Exception='java.lang.NullPointerException'

Which seems to trigger sometimes when a command is sent to the Thing to change its state to Movies or Nodect (the only thing my rules do when someone comes up the driveway). The logs get full of this every two seconds and stopping/starting the bundle in karaf is the only way to fix it.

These refreshThing errors seem to happen any time the camera changes state on its own to. If the monitor is set to mocord, the errors start if a recording is triggered from zoneminder due to motion. Then the log is filled with these errors every 2 seconds

Thanks a lot for you observations, I haven’t had time to look at them due to vacation :-). I will try to find som time to look at the code with your observations in mind.

Hey Rich,
I was wondering about zoneminder / motion as well. This is what I ended up doing.

I have a VM running motioneye as my central box. Then I use a raspberry pi to be my remote camera.

I have motioneye do the motion detection even on the remote cameras and fires off motion detect scrips to openhab.

I am currently working on a newer version of the camera using a raspberry pi zero / POE / IR cut filter and IR leds.

1 Like

Hi @mr_eskildsen,

i’ve also got this wierd problem after upgrading to oh 2.2.0 build 1014 (online). Zoneminder Version is 1.30.4

I’ve set the main zm language to en_gb and also the language for the user to en_gb:


Username	Language	Enabled	Stream	Events	Control	Monitors	Groups	System	Bandwidth	
openhab	    en_gb	    Yes	    View	Edit	Edit	Edit	    Edit	Edit	High	 	

Reinstalled the binding multiple times, also restarted everything (oh and zm):

2017-08-16 21:55:23.849 [DEBUG] [er.internal.ZoneMinderHandlerFactory] - [FACTORY]: creating handler for bridge thing 'org.eclipse.smarthome.core.thing.internal.BridgeImpl@50184d2c'
2017-08-16 21:55:23.854 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (1b289f14)]: Starting ZoneMinder Server Bridge Handler (Bridge='null')
2017-08-16 21:55:23.858 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE]: About to initialize bridge server
2017-08-16 21:55:23.860 [INFO ] [andler.ZoneMinderServerBridgeHandler] - BRIDGE: ZoneMinder Server Bridge Handler Initialized
2017-08-16 21:55:23.863 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - BRIDGE:    HostName:           172.18.0.1
2017-08-16 21:55:23.864 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - BRIDGE:    Protocol:           http
2017-08-16 21:55:23.865 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - BRIDGE:    Port HTTP(S)        80
2017-08-16 21:55:23.866 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - BRIDGE:    Port Telnet         6802
2017-08-16 21:55:23.867 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - BRIDGE:    Server Path         /zm
2017-08-16 21:55:23.868 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - BRIDGE:    User:               openhab
2017-08-16 21:55:23.870 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - BRIDGE:    Refresh interval:   10
2017-08-16 21:55:23.871 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - BRIDGE:    Low  prio. refresh: 0
2017-08-16 21:55:23.872 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - BRIDGE:    Autodiscovery:      true
2017-08-16 21:55:23.873 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (1b289f14)]: closeConnection(): Closed HTTP Connection!
2017-08-16 21:55:23.881 [DEBUG] [andler.ZoneMinderServerBridgeHandler] - BRIDGE [1b289f14]: Starting ZoneMinder Bridge Monitor Task. Command='org.openhab.binding.zoneminder.handler.ZoneMinderServerBridgeHandler$1@611f9787
2017-08-16 21:55:26.001 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (1b289f14)]: Exception occurred in updateAvailabilityStatus Exception='null'
2017-08-16 21:55:26.002 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (1b289f14)]: Bridge status changed from 'OFFLINE' to 'OFFLINE'
2017-08-16 21:55:42.579 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (1b289f14)]: Exception occurred in updateAvailabilityStatus Exception='null'
2017-08-16 21:55:59.163 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (1b289f14)]: Exception occurred in updateAvailabilityStatus Exception='null'

User could logon to Zoneminder without a problem:

Date/Time                  Component	PID	    Level	Message	                            File	                  Line
2017-08-16 22:00:55.928966	web_php		17895	INF	    Login successful for user "openhab"	/usr/share/zoneminder/www/includes/functions.php	53
2017-08-16 22:00:55.189667	web_php		17895	INF	    Login successful for user "openhab"	/usr/share/zoneminder/www/includes/functions.php	53

greetings,

W.G.

Thanks for your logs, seems like I have to do some debugging. Unfortunately I have been quite busy with other things lately, first of all a broken disk in my fileserver - ended with a large cleanup project…

Unfortunately, my ZM server goes from Running state to Stopped state if i do an Operating mode change from Modect to Monitor. I have to then login into ZM webserver, and change the ZM state from Stopped to ‘Start’.

Is it possible to change the ‘state’ of the ZM server in rule?

Here is a short log

2017-08-16 19:01:57.077 [ItemCommandEvent          ] - Item 'ZoneMinderMonitorLiving1_OperatingMode' received command Monitor
2017-08-16 19:01:57.080 [ItemStateChangedEvent     ] - ZoneMinderMonitorLiving1_OperatingMode changed from Modect to Monitor
2017-08-16 19:02:35.977 [hingStatusInfoChangedEvent] - 'zoneminder:server:daced488' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): ZoneMinder Server Daemon not running
2017-08-16 19:02:35.980 [hingStatusInfoChangedEvent] - 'zoneminder:monitor:daced488:monitor-2' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2017-08-16 19:02:35.987 [hingStatusInfoChangedEvent] - 'zoneminder:monitor:daced488:monitor-3' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2017-08-16 19:02:35.988 [hingStatusInfoChangedEvent] - 'zoneminder:monitor:daced488:monitor-1' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2017-08-16 19:02:53.202 [hingStatusInfoChangedEvent] - 'zoneminder:server:daced488' changed from OFFLINE (COMMUNICATION_ERROR): ZoneMinder Server Daemon not running to OFFLINE (CONFIGURATION_ERROR): ZoneMinder Server Daemon not running

Hi! Did you check the ZM log? Also the message log?

@mr_eskildsen: oh, doesn’t sound fun… hopefully you didn’t lost any important data! So good luck with fixing your server!

@whopperg, yes the logs do show that zmc has stopped working. It is some sort of race condition which cause zm to shutdown. Here are the details of it.

No data lost. Since long ago I wanted to add Write cache (SSD disks) to my storage. been pushing that in front of me, because I know I had to rearrange a lot in the server. So it ended up with a slightly larger project than just buy and install a new disk

For the moment I am working on a Jython script to presence detection, when that comes to some point where I can put that aside, I believe it is time to look at ZoneMinder Binding. Hopefully in a couple of days.

This is a workaround to restart ZM until proper support comes in
Setup this rule

         sendCommand(ZoneMinderMonitorMonitor1_OperatingMode, "Monitor")
         Thread::sleep(5)
         executeCommandLine("sh /home/openhab/restart_zm.sh",10000)

and

$cat /home/openhab/restart_zm.sh
#/bin/sh
curl -d "username=admin&password=admin&action=login&view=console" -c /tmp/cookies.txt http://zmserver/index.php
curl -b /tmp/cookies.txt  -XPOST  http://zmserver/api/states/change/restart.json #restarts ZM
1 Like

@mr_eskildsen Rather than restarting zmserver each time the camera operating mode changes, I wanted to only restart it if it has gone offline. However, I noticed that even when the bridge goes down like this

[INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (582d1d4a)]: Bridge status changed from 'OFFLINE' to 'OFFLINE'

I see that the ZoneMinder Server State is still online? It should go offline if the bridge dies. I wanted to use the following code to bring the ZM server up, but it doesnt work due to above issue.

rule "Zoneminder Restart"
when
    Item ZoneMinderServer_Online changed
then
         logInfo("Zoneminder", ZoneMinderServer_Online.state)
         if (ZoneMinderServer_Online.state==OFF)
         {
                Thread::sleep(10)
                 logInfo("Zoneminder", "Restarting ZM server")
                 executeCommandLine("sh /home/openhab/restart_zm.sh",10000)
         }
end

Any comments?

Hello eskildsen,

I just installed the Zoneminder binding and running also into Status: OFFLINE - COMMUNICATION_ERROR Error occurred (Check log). The bridge doesn’t come ONLINE.

Debug:
Exception occurred in updateAvailabilityStatus Exception='null’
11:59:24.426 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (1311ee20)]: Bridge status changed from ‘OFFLINE’ to 'OFFLINE’
11:59:24.428 [INFO ] [smarthome.event.ThingStatusInfoEvent] - ‘zoneminder:server:xxxxxx’ updated: OFFLINE (COMMUNICATION_ERROR): Error occurred (Check log)
11:59:24.431 [INFO ] [me.event.ThingStatusInfoChangedEvent] - ‘zoneminder:server:xxxxxx’ changed from OFFLINE (CONFIGURATION_ERROR): Cannot access ZoneMinder Server. Check provided usercredentials to OFFLINE (COMMUNICATION_ERROR): Error occurred (Check log)
Credentials are okay

Went through the troubleshooting steps and noticed a flaw on the “I have tried all of the above, it still doesn’t work” part. When I issued the command given “curl -d “=XXXX&=YYYY&action=login&view=console” -c cookies.txt http:///zm/index.php” it will proof that connectivity is working, but actual login failed.
When using “curl -d “username=XXXX&password=YYYY&action=login&view=console” -c cookies.txt http:///zm/index.php” it does login successful.

Would be good to have that changed on the Github and document page.
(there’s a typo anabled instead of enabled in the top, next to some table <tags> on the document page)

Running the 2.1.0 release build with standard bindings, but guess I need to obtain and load a later zoneminder-binding, correct?

Have you tried to enable DEBUG logging? The log indicates a configuration error.
A valid configuration should look something like that:

There has been reported some issues, so whenever get the time I will dig into it.
I might have an idea about the problem. As far as I remember the API has it’s own path, Normally zoneminder is http://zoneminder.mydomain.org/zm and thus API is based at http://zoneminder.mydomain.org/zm/api
From what you post it looks like you have redirected to NOT using /zm. I briefly tried this setting in ZoneMinder and it seemed like the API still located at http://zoneminder.mydomain.org/zm/api (in my test) - and thus things failed.
I gues that could cause the problem you describe

Nope, just use the binding deployed with openHAB, haven’t changed for a long time - unfortunately.

To be sure I created a symbolic link in the zoneminder director for zm pointing upwards. That should allow any external queries including /zm to work as well.

/var/www/zoneminder
/var/www/zoneminder/zm -> /var/www/zoneminder.

Than /var/www/zoneminder/zm/api just works, which was needed to get zmNinja running.