ZoneMinder Binding cannot connect to the API

Hi,
I installed latest snapshot of OpenHab2 and installed ZoneMinder Binding.
When I create Bridge i got auht error, but I’m sure that credential are fine. Also ZM’s API configuration are fine, because I use them with ZmNinja and Zabbix to monitor cams.
Here is logs:

1	DEBUG	nding.zoneminder.internal.ZoneMinderHandlerFactory	[FACTORY]: creating handler for bridge thing 'org.eclipse.smarthome.core.thing.internal.BridgeImpl@f03d7db6'
2017-09-28 14:05:13.721	INFO 	g.zoneminder.handler.ZoneMinderServerBridgeHandler	[BRIDGE (cbced587)]: Starting ZoneMinder Server Bridge Handler (Bridge='null')
2017-09-28 14:05:13.722	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	[BRIDGE]: About to initialize bridge server
2017-09-28 14:05:13.722	INFO 	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE: ZoneMinder Server Bridge Handler Initialized
2017-09-28 14:05:13.722	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    HostName:           192.168.1.76
2017-09-28 14:05:13.722	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    Protocol:           http
2017-09-28 14:05:13.722	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    Port HTTP(S)        80
2017-09-28 14:05:13.723	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    Port Telnet         6802
2017-09-28 14:05:13.723	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    Server Path         /zm
2017-09-28 14:05:13.723	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    User:               admin
2017-09-28 14:05:13.723	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    Refresh interval:   10
2017-09-28 14:05:13.723	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    Low  prio. refresh: 0
2017-09-28 14:05:13.723	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    Autodiscovery:      true
2017-09-28 14:05:13.723	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	[BRIDGE (cbced587)]: closeConnection(): Closed HTTP Connection!
2017-09-28 14:05:13.723	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE [cbced587]: Starting ZoneMinder Bridge Monitor Task. Command='org.openhab.binding.zoneminder.handler.ZoneMinderServerBridgeHandler$1@7e118f'
2017-09-28 14:05:20.815	INFO 	g.zoneminder.handler.ZoneMinderServerBridgeHandler	[BRIDGE (cbced587)]: Bridge status changed from 'OFFLINE' to 'OFFLINE'

I tried to run from command line

curl -d "=XXXX&=YYYY&action=login&view=console" -c cookies.txt http:///zm/index.php

and connection is fine and cookie is downloaded. I just use this method to monitor camera, but I would like to move to native binding. Telnet to port 6802 is fine.

Have you tried to use the IP adress instead off zm?
Also make sure that you do the test from your openHAB server, to verify that you can access ZoneMinder Server from openHAB server

Hi,
i just use IP for connection, and I just have a mechanism use curl and Exec binding to retrieve status of the monitor from my ZM server, so comunication is fine

There is no problems (ERRORs) stated in the log you have posted. SO there isn’t much to dig into.
Have you tired to restart openHAB? Alternatively change logging to debug and restart openHAB.

Log is set to TRACE, it should be more than DEBUG, it is right?

Marco

Arghhh, sorry I didn’t notice that you already posted DEBUG logging :slight_smile:
Have you tried restarting openHAB?

Yes,
just restarted

Marco

And what is the result? Any errors?
Else i need the zoneminder. Entries

Even after restart, does not work,
What do you need ZM side?

Marco

First off All a debug log from openHAB. Preferrably only Zoneminder.

Hi @mr_eskildsen
is attached in first post, it is at TRACE level.

Marco

I would expect more logentries with debug enabled. Also I see no errors or warnings at all.
i suggest that you pass all logentries from ZoneMinder in its own file, it will make it easier to see what is going on.

Hi @mr_eskildsen
the log in 1st post is captured with a separate file dedicated to ZM binding.
Here is the log configuration, let me know if it’s enought:

# ZoneMinder Logger
			log4j2.logger.LoggerCalDav.name = org.openhab.binding.zoneminder
			log4j2.logger.LoggerCalDav.level = TRACE
			log4j2.logger.LoggerCalDav.additivity = false
			log4j2.logger.LoggerCalDav.appenderRefs = ZoneMinder-my
			log4j2.logger.LoggerCalDav.appenderRef.ZoneMinder-my.ref = ZONEMINDER
		# ZoneMinder Appender
			log4j2.appender.LoggerCalDav.name= ZONEMINDER
			log4j2.appender.LoggerCalDav.type = RollingRandomAccessFile
			log4j2.appender.LoggerCalDav.fileName=${openhab.logdir}/ZoneMinder-my.log
			log4j2.appender.LoggerCalDav.filePattern = ${openhab.logdir}/ZoneMinder-my.log.%i
			log4j2.appender.LoggerCalDav.immediateFlush = true
			log4j2.appender.LoggerCalDav.append = true
			log4j2.appender.LoggerCalDav.layout.type = PatternLayout
			log4j2.appender.LoggerCalDav.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-50.50c] - %m%n
			log4j2.appender.LoggerCalDav.policies.type = Policies
			log4j2.appender.LoggerCalDav.policies.size.type = SizeBasedTriggeringPolicy
			log4j2.appender.LoggerCalDav.policies.size.size = 100MB
			log4j2.appender.LoggerCalDav.strategy.type = DefaultRolloverStrategy
			log4j2.appender.LoggerCalDav.strategy.max = 10

Looks correct. I am wondering why it is named LoggerCalDav? Do the same name (LoggerCalDav) appear else where in your config file?

Hi,
“LoggerCalDav” is unique.
I just restarted OH and captured a new set of logs:

2017-10-02 11:07:38.431	DEBUG	org.openhab.binding.zoneminder                    	BundleEvent INSTALLED - org.openhab.binding.zoneminder
2017-10-02 11:07:40.535	DEBUG	org.openhab.binding.zoneminder                    	BundleEvent RESOLVED - org.openhab.binding.zoneminder
2017-10-02 11:07:43.002	DEBUG	org.openhab.binding.zoneminder                    	BundleEvent STARTING - org.openhab.binding.zoneminder
2017-10-02 11:07:43.003	DEBUG	org.openhab.binding.zoneminder                    	BundleEvent STARTED - org.openhab.binding.zoneminder
2017-10-02 11:07:43.012	DEBUG	org.openhab.binding.zoneminder                    	ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={component.name=binding.zoneminder, component.id=154, service.id=780, service.bundleid=592, service.scope=bundle} - org.openhab.binding.zoneminder
2017-10-02 11:08:06.550	DEBUG	nding.zoneminder.internal.ZoneMinderHandlerFactory	[FACTORY]: creating handler for bridge thing 'org.eclipse.smarthome.core.thing.internal.BridgeImpl@6de52b05'
2017-10-02 11:08:06.552	INFO 	g.zoneminder.handler.ZoneMinderServerBridgeHandler	[BRIDGE (333fc0dd)]: Starting ZoneMinder Server Bridge Handler (Bridge='null')
2017-10-02 11:08:06.566	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	[BRIDGE]: About to initialize bridge server
2017-10-02 11:08:06.566	INFO 	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE: ZoneMinder Server Bridge Handler Initialized
2017-10-02 11:08:06.580	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    HostName:           192.168.1.76
2017-10-02 11:08:06.581	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    Protocol:           http
2017-10-02 11:08:06.581	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    Port HTTP(S)        80
2017-10-02 11:08:06.581	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    Port Telnet         6802
2017-10-02 11:08:06.581	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    Server Path         /zm
2017-10-02 11:08:06.582	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    User:               admin
2017-10-02 11:08:06.582	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    Refresh interval:   10
2017-10-02 11:08:06.582	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    Low  prio. refresh: 0
2017-10-02 11:08:06.582	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE:    Autodiscovery:      true
2017-10-02 11:08:06.582	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	[BRIDGE (333fc0dd)]: closeConnection(): Closed HTTP Connection!
2017-10-02 11:08:06.594	DEBUG	g.zoneminder.handler.ZoneMinderServerBridgeHandler	BRIDGE [333fc0dd]: Starting ZoneMinder Bridge Monitor Task. Command='org.openhab.binding.zoneminder.handler.ZoneMinderServerBridgeHandler$1@6cd5e026'
2017-10-02 11:08:23.070	INFO 	g.zoneminder.handler.ZoneMinderServerBridgeHandler	[BRIDGE (333fc0dd)]: Bridge status changed from 'OFFLINE' to 'OFFLINE'

Great :slight_smile:

The above logline is the only odd thing I see in your logentries. The only thing that strikes my mind is if you are sure that following is true:

  1. http://192.168.1.76/zm is the url to your ZoneMinder server
  2. admin is the user
  3. Make sure you use the correct password.
  4. If none of the above is the answer I would like to see You can eventually excute curl command below. Make sure to replace XXXX with correct password.
curl -d "username=admin&password=XXXX&action=login&view=console" -c cookies.txt  http://192.168.1.76/zm/index.php

The HTML text from the ZoneMinder page should be returned by the curl command.

This may not be the OP’s issue, but it’s a somewhat related topic and I couldn’t find a good place to post it! Our API stopped working after a relatively recent Zoneminder update. The Apache config for Zoneminder was in /etc/httpd/conf.d/zoneminder.conf. After the update, we had a zoneminder.conf.rpmnew, which came down with the updated Zoneminder package. If you’ve never modified the original, then you can just swap them out. There was something in the new Apache configuration that was needed to get our API functioning again.

hi @mr_eskildsen
steps 1,2,3 are fine.
Running command @step 4, i got a lot of html code and coockie are created.
It contain:

# Netscape HTTP Cookie File
# http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

#HttpOnly_192.168.1.76  FALSE   /       FALSE   0       ZMSESSID        lsf3niqviuvfd0bjq4gukas4a3
192.168.1.76    FALSE   /zm/    FALSE   1818053769      zmSkin  classic
192.168.1.76    FALSE   /zm/    FALSE   1818053769      zmCSS   classic

As told before, I just have an integration in place that use exec binding and curl command.

@5iver
I just using ZMNinja, the mobile applicarion for ZM, and as i know it use APIs and it work.
I do not have file you’re speaking for. my zoneminder.conf is:

# Remember to enable cgi mod (i.e. "a2enmod cgi").
ScriptAlias /zm/cgi-bin "/usr/lib/zoneminder/cgi-bin"
<Directory "/usr/lib/zoneminder/cgi-bin">
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    AllowOverride All
    Require all granted
</Directory>

Alias /zm /usr/share/zoneminder/www
<Directory /usr/share/zoneminder/www>
  Options -Indexes +FollowSymLinks
  <IfModule mod_dir.c>
    DirectoryIndex index.php
  </IfModule>
</Directory>

<Directory /usr/share/zoneminder/www/api>
    AllowOverride All
</Directory>

Marco

Strange. As far as I can see it doesn’t connect to ZoneMinder. The obvious problems is wrong user and/or password, and no connection to server. None those issues seems to be the answer.

What version of ZoneMinder are you using?
What is your language settings in ZM?

hi @mr_eskildsen

I use ZM version 1.31.1
Language is en_gb