New Zoneminder Binding for Zoneminder versions >= 1.34.0

Yes and Yes - API is enabled as well as a user (openhab) setup… and the user has API rights…

if I enter:
http://ipaddress/zm/api/host/getVersion.json

I get:

{“success”:false,“data”:{“name”:“Not Authenticated”,“message”:“Not Authenticated”,“url”:"/zm/api/host/getVersion.json",“exception”:{“class”:“UnauthorizedException”,“code”:401,“message”:“Not Authenticated”}}}

when I enable: OPT_USE_LEGACY_API_AUTH

i get:

{“version”:“1.34.21”,“apiversion”:“2.0”}

hope this helps to solve my problem…?

Does your username or password have any special characters (including ? & etc)? There’s currently a bug relating to url encoding of the username and password.

If so, I can give you a version that has a fix for this.

Nope…

pass is:
cuJzTImEDO8HcKPwIFmT

but I’ll change it in a few seconds :slight_smile:

but even if I turn off authentification it will not connect…

1 Like

Hmm. You shouldn’t need OPT_USE_LEGACY_API_AUTH. Just OPT_USE_AUTH and the user name and password in the Zoneminder Server thing config.

thats what I thought… however, If I don’t enable OPT_USE_LEGACY_API_AUTH I get the error above when I enter the http://ipaddress/zm/api/host/getVersion.json

If I enable OPT_USE_LEGACY_API_AUTH i get the version and apiversion

I can login and do everything normaly on the zoneminder server through chrome…

AUTH_RELAY is set to hashed… :thinking:

just edited the host… and got this log output

020-09-19 22:00:05.125 [DEBUG] [.zm.internal.handler.ZmBridgeHandler] - Bridge: Handler initializing

2020-09-19 22:00:05.130 [DEBUG] [b.binding.zm.internal.handler.ZmAuth] - ZmAuth: Authorization is enabled

2020-09-19 22:00:05.134 [DEBUG] [.zm.internal.handler.ZmBridgeHandler] - Bridge: Checking for valid Zoneminder host: URL.com

2020-09-19 22:00:05.137 [DEBUG] [b.binding.zm.internal.handler.ZmAuth] - ZmAuth: Update expired REFRESH token using url ‘http://URL.com/zm/api/host/login.json

2020-09-19 22:00:05.126 [me.event.ThingUpdatedEvent] - Thing ‘zm:server:161efefb’ has been updated.

2020-09-19 22:00:05.834 [DEBUG] [.zm.internal.handler.ZmBridgeHandler] - Bridge: IOException: java.util.concurrent.ExecutionException: org.eclipse.jetty.client.HttpResponseException: HTTP protocol violation: Authentication challenge without WWW-Authenticate header

at org.openhab.binding.zm.internal.handler.ZmBridgeHandler.executePost(ZmBridgeHandler.java:447) [bundleFile:?]

at org.openhab.binding.zm.internal.handler.ZmAuth.getNewRefreshToken(ZmAuth.java:97) [bundleFile:?]

at org.openhab.binding.zm.internal.handler.ZmAuth.checkTokens(ZmAuth.java:83) [bundleFile:?]

at org.openhab.binding.zm.internal.handler.ZmAuth.isAuthorized(ZmAuth.java:76) [bundleFile:?]

at org.openhab.binding.zm.internal.handler.ZmBridgeHandler.getVersion(ZmBridgeHandler.java:392) [bundleFile:?]

at org.openhab.binding.zm.internal.handler.ZmBridgeHandler.isHostValid(ZmBridgeHandler.java:513) [bundleFile:?]

at org.openhab.binding.zm.internal.handler.ZmBridgeHandler.initialize(ZmBridgeHandler.java:170) [bundleFile:?]

2020-09-19 22:00:05.908 [WARN ] [.zm.internal.handler.ZmBridgeHandler] - Bridge: Can’t get version information from server

Can you try this from the shell?

curl -XPOST -d "user=YOURUSERNAME&pass=YOURPASSWORD&stateful=1" http://IPADDRESS/zm/api/host/login.json

You should get something like this.

{"access_token":"XXXXXXXXX","access_token_expires":3600,"refresh_token":"YYYYYYYY","refresh_token_expires":86400,"version":"1.34.21","apiversion":"2.0"}

Here’s what my config looks like. I’m running 1.34.21.

zm-options

301 Moved Permanently

Moved Permanently

The document has moved here.

is the replay…

apache is ssl and permanently redirected

C:>curl -XPOST -d “user=xxx&pass=xxxx&stateful=1” URL.com - MediaOptions
curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - Die Sperrfunktion konnte keine Sperrprüfung für das Zertifikat durchführen.

Is your Zoneminder on http or https? I don’t think it’s ever been tested on https. :frowning_face:

My zoneminder is not https, but the apache server its behind is…

please visit https://url.com/zm and you see the login page

maybe its a ssl certificate error?

Ah. Can your openHAB directly access the http zoneminder instance (either by host name or ip address)?

well my sitemap can grab the video with:

https://URL.comt/zm/cgi-bin/nph-zms?scale=50&width=640p&height=480px&mode=jpeg&maxfps=5&buffer=1000&&monitor=1&auth=&user=test&pass=123456&connkey=36139

test user has no API…

The binding currently won’t use https. I never added that because ZM didn’t support https directly.

I could build you a version that uses https for you to try. If it works, I can add a config option in the binding to select http or https. Let me know if you’d like to test it.

Yes, and thank you for your support - really appreciate!

Try this version. You first will need to remove the older binding version in addons before adding this one.

https://github.com/mhilbush/openhab-binding-releases/blob/master/zm/org.openhab.binding.zm-2.5.9-SNAPSHOT.jar?raw=true

wow… THX thats working now!!! :grinning:

I owe you a few beers… whenever you get the chance to come to Vienna Austria :wink:

Awsome support !

Ok. I’ll add a config option to select http or https. Might not get around to that for a few days. In the meantime, at least you’re working now. :wink:

Haven’t been there for quite a few years. Beautiful city.

True, and excelent beer :wink: is waiting - so once this pandemic sheit is over - its waiting for you!

1 Like