Zoneminder binding

Tags: #<Tag:0x00007f5c86a6d1e8> #<Tag:0x00007f5c86a6d0a8>

(Dan) #142

oddly not - disk usage is still reported correctly, and the isAlive switch remains ON

(Martin Eskildsen) #143

Strange, it should go offline when connection is lost to ZoneMinder Server. It could be that it doesn’t properly detect that it has lost connection, and then stays in a state where it believes it is ONLINE but it isn’t.
I will have to look through my code for that kind of problems

(Martin Eskildsen) #144

Did you install an earlier version of the binding? I have sometimes seen that this can cause weird behaviour. I really doesn’t see anything strange in your log.
I would advise you to try three things:

  1. Start openHAB in console mode and force bundle:uninstall on all ZoneMidner Bindings (there might be more than one). Identify instances by typing
list | grep ZoneMinder

Make sure all instances is uninstalled
Also make sure all mappings to ZoneMinder (either in your .things .items or Inbox) is remvoed / disabled.
Restart openHAB and verify that ZoneMinder is completely gone. Manually add the ZoneMinder Server and hopefully it comes online and discovers your monitors

  1. If it doesn’t help, try to run this:
curl -d "username=XXXX&password=YYYY&action=login&view=console" -c cookies.txt  http://yourzmip/zm/index.php

Replace username, password and yourzmip to your setup.
If that succeeds execute:

curl -b cookies.txt http://yourzmip/zm/api/monitors.json

This should give you a json response. If that works I really doen’t understand, since those calls is pretty much the same calls the binding does,

(Martin Eskildsen) #145

I have looked a little bit into the code that handles if the binding is ONLINE or OFFLINE. If have found some situations where it could theoretically go OFFLINE without it is registered correctly. I will look at it tonight, and hopefully I can build a new JAR tonight (at least with some additional logging in. I would be really happy to get rid of this problem before the binding is merged. :slight_smile:

(Martin Eskildsen) #146

As promised I have a new build ready:

It is only tested minimalistic: It can start and doesn’t fail right away in my environment
It doesn’t bring any new functionality, so it is only recommended if you are having problems with the previous versions.

  1. It adds additional logging to help figure out why things is stopping in setups.
  2. Handling of thing status ONLINE / OFFLINE has been improved,
    I hope that this will solve Dan’s disconnect issue, or at least point out where the problem is.
    I am uncertain if it will solve the problem Joerg has reported, but at least the extra logging should help in pinpointing the problem.

Please make sure at all older versions is uninstalled before, just to be 100% sure that we aren’t looking at old problems :slight_smile:

(Joerg) #147

Quite strange: the two curl commands work (I get my monitors with the second curl command).
But logging from your new jar (thanks!) put’s out:‘URL not a ZoneMinder Server’ - despite the fact that I’m quite sure, that it is one :wink:

2017-01-26 22:57:50.518 [DEBUG] [.www.protocol.http.HttpURLConnection] - 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:}{Connection: keep-alive}
2017-01-26 22:57:50.549 [DEBUG] [.www.protocol.http.HttpURLConnection] - pairs: {null: HTTP/1.1 200 OK}{Date: Thu, 26 Jan 2017 21:58:24 GMT}{Server: Apache/2.4.7 (Ubuntu)}{X-Powered-By: PHP/5.5.9-1ubuntu4.20}{Set-Cookie: ZMSESSID=nipomsd3193sasja9ps1no90f4; 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 21:58:24 GMT; Max-Age=311040000}{Set-Cookie: zmCSS=flat; expires=Sat, 05-Dec-2026 21:58:24 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 22:57:50.549 [ERROR] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (c6554e88)]: Bridge OFFLINE because of ‘URL not a ZoneMinder Server’

To ensure, that no old artifacts were kept, I did an installation of openhab2 on a new linux box, but the result was also ‘URL not a ZoneMinder Server’

(Martin Eskildsen) #148

I believe we are getting close to where the problem is. It is (unfortunately) pointing directly at some part of the code which I am not very fond of…
I have already planned rework of that part, but I have hoped it could wait until after release of the binding.

I see two potential problems with my code:

  1. Your ZoneMinder instance isn’t located in the default location (http:///zm)
  2. You might have changed the name of your ZoneMinder Instance in the settings

I would like to ask me a favour, could you send med a text file containing the output of this statement:

curl http://<YOUR_ZONEMINDER_SERVER_IP>/zm/index.php > zoneminder.txt

If you answered yes to the first bullet, please change the above URL accordingly.
You can just send me a PM with the contents, I am curious why this page isn’t recognized as a ZoneMinder Server :slight_smile: .

(Joerg) #149

Here we go.

I was not sure if you wanted with or without cookie authentication for detection, so I sent you both.
I’m using the german version (maybe some tags have different names then)…

If I could help you further on, it would be my pleasure…

Kind regards


PS: Url is unchanged (or /zm/index.php)

zoneminder_with_cookie.xml (21.2 KB)
zoneminder_without_cookie.xml (2.6 KB)

(Martin Eskildsen) #150

Thanks for sending both versions, that would be needed.
It absolutely pinpoints the problem with the approach I have (and the reason i want to rewrite this part).
My approach is to look for some specific text on the page. In this particxular case I am looking for “ZoneMinder Login”, which is obviously translated to German :slight_smile:
The quick fix will be to look for something that is not translated, and the correct fix would be to rewrite the code that determines if it is a ZM server and if I have to login.

Without analyzing all details, I think I can provide a quick fix tonight.

Thanks for your patience and your work on documenting your problem.

(Joerg) #151

You’re welcome and it’s me that has to be thankful!!!

(Martin Eskildsen) #152

After pprox. 20 years in Software business, I have learned that users most often aren’t capable of describing a problem more detailed than: It doesn’t work, please fix it.
So getting detailed logs as well as some thoughts/description of your setup is a gift :slight_smile:

(Joerg) #153

You forgot “yesterday it worked and I havn’t done anything

  • being in software and network business since 1984 :wink:

(Martin Eskildsen) #154

Oh thanks for reminding me about the “advanced” users…:scream:

(Dan) #155

Whilst we’re on the subject: yesterday it didn’t work and now it does and I haven’t done anything.

(I haven’t installed your latest JAR but it all seems to be working perfectly)


(Martin Eskildsen) #156

You can find a build of the jar that accepts ZoneMinder instances running another language than english.

OK, sounds great, if you get any problems again, I would recommend that you upgrade to this version, since it contains much more logging related to the communication to ZoneMinder. But if it works, leave it as is :slight_smile:

(Joerg) #157

Good work, thanks a lot!

The new jar works caught up the server and all monitors got added by autodetection.

(Michael) #158

Great work on the binding so far! Any way to turn off the additional logging? The changed from online to online is a bit tedious. :slight_smile:

2017-01-27 16:37:00.242 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (xxxxxxxx)]: Bridge status changed from ‘ONLINE’ to ‘ONLINE’

(Martin Eskildsen) #159

You can always control what is logged by setting your loglevel to what ever you think is reasonable.
The above logentry shouldn’t obvious be logged. Only changes from one state to another should be logged. I will check if ther is some obvious logical error.

Since it seems that the binding is running in a couple of setups I will stop further coding, to allow the code review, so that ZoneMinder can be merged into the 2.1 branch of openHAB…

(Martin Eskildsen) #160

I have build [quote=“MJ377, post:158, topic:15386”]
Great work on the binding so far! Any way to turn off the additional logging? The changed from online to online is a bit tedious. :slight_smile:

2017-01-27 16:37:00.242 [INFO ] [andler.ZoneMinderServerBridgeHandler] - [BRIDGE (xxxxxxxx)]: Bridge status changed from ‘ONLINE’ to ‘ONLINE’
I have now build a jar where you should get rid of that useless log line :slight_smile:

It doesn’t bring any new functionality, so if the log lines doesn’t disturb, you should not upgrade :slight_smile:

As I haven’t heard complaints about things not working, I assume that it works, else I would really like to know about it.

Thanks to all of you for your patience and effort testing,

(Dan) #161

minor but funny point: zoneminder itself reports server load of 0.19 and disk usage 29%. This is consistent with what the zoneminder server command line tells me.

However the binding shows disk usage as 32.87% and server load of 0.37