Struggling with zoneminder component

I am struggling with the configuration of the zoneminder configuration, and I suspect the origin lies in the zoneminder’s server running httpd AND zm on port 777, not port 80, but my HASSBIAN installation queries it on port 80.

In configuration.yaml, I have the following:

zoneminder:
host: lefanu
username: !secret zm_user
password: !secret zm_pass

the homeassistant.log file says:

equests.exceptions.ConnectionError: HTTPConnectionPool(host=‘lefanu’, port=80): Max retries exceeded with url: /zm//index.php (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x7508d910>: Failed to establish a new connection: [Errno 111] Connection refused’,))

I have not yet configured a sensors.yaml or switch.yaml, and I don’t know if the absence of those files is germane, given the attempts to query port 80.

Any thoughts?

try adding the ZM port you are using in the configuration

zoneminder:
  host: ZM_HOST:PORT

Thank you for the quick response.

I tried both ports 777 and 80, but to no avail. I know the credentials are good, because I can log into the web interface. I also know the server running zoneminder is listening on both ports 80 and 7777 (see below):

root@LeFanu:/etc/apache2# telnet localhost 80
Trying ::1…
Connected to localhost.
Escape character is ‘^]’.

root@LeFanu:/etc/apache2# telnet localhost 7777
Trying ::1…
Connected to localhost.
Escape character is ‘^]’.

I also verified that iptables is configured to let connections from the HASSBIAN server on both those ports
-A INPUT -s 192.168.10.115/32 -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -s 192.168.10.115/32 -p tcp -m tcp --dport 7777 -j ACCEPT

I am somewhat mystified,

what version of zoneminder are you using?
are you still using the default path for zonemonder http://[IP:Port]/zm
is zoneminder setup with SSL?

equests.exceptions.ConnectionError: HTTPConnectionPool(host=‘lefanu’, port=80): Max retries exceeded with url: /zm//index.php (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x7508d910>: Failed to establish a new connection: [Errno 111] Connection refused’,))

Also in the error message, you have posted note the // in the middle of the Max retries exceeded with URL.

I am using version 1.29; no ssl; and all paths kept to the defaults, including port 7777 at localhost. I am running ZM on one raspberry pi, running raspian jessie, which I patched to current levels Saturday (including the kernel). Let me know if I should post any logs in their entirety or just sections.

Can you telnet from the Home Assistant host to port 80 or 7777 on the ZM server?

Affirmative on both ports (I neglected to mention in my initial post that I had verified this):

pi@hassbian:~ $ telnet lefanu 80
Trying 192.168.10.122…
Connected to lefanu.
Escape character is ‘^]’.

pi@hassbian:~ $ telnet lefanu 7777
Trying 192.168.10.122…
Connected to lefanu.
Escape character is ‘^]’.

You can try a curl http://lefanu/zm/index.php and see the outcome.
Likely an apache/nginx misconfig going on.

Correct me if I’m wrong, but this looks like a success condition. I managed to pull this last night and repeat it just now:

curl http://lefanu/zm/index.php

ZoneMinder - Login //<![CDATA[

ZoneMinder Login

Username
Password

I tried to pass curl credentials, but I think I needed to embed/encapsulate/offset them somehow, and it was after ten pm when I got this far. As a point of reference, this was my written path for the install: ZoneMinder Wiki - Wiki - Raspbian

Until yesterday, Zoneminder only listened on port 7777, but I added 80 to /etc/apache2/conf/ports.conf and restarted apache. Then, once I realized telnet client was missing and I added it via apt-get, I was able to telnet to both 80 and 7777 – from localhost on the zoneminder and from the homeassistant user on the hassbian host referenced as ‘stoker’ in the zoneminder host (lefanu)'s iptables files.

Sounds like an authentication issue, try disabling the auth in Zoneminder and remove the username/pass from home assistant. I use my zoneminder without auth and HA is able to access it just fine.

Okay disabling auth worked from the curl perspective:

curl http://lefanu/zm/

ZoneMinder - Console

Wed 29th Nov, 3:07pm

Load: 0.54 / Disk: 79%

ZoneMinder Console - Running - default v1.29.0

Configured for Low Bandwidth

Name Function Server Source Events Hour Day Week Month Archived Zones Order Mark
8929 0 72 917 917 0 1
Sauron Modect /dev/video0 (0) 8929 0 72 917 917 0 1 UpDown

but I’m still seeing errors in the homeassistant log:

(homeassistant) homeassistant@hassbian:~ $ tail -100 .homeassistant/home-assistant.log| grep zoneminder
2017-11-29 20:06:20 ERROR (Thread-11) [homeassistant.components.zoneminder] Connection error logging into ZoneMinder
2017-11-29 20:06:20 ERROR (MainThread) [homeassistant.setup] Setup failed for zoneminder: Component failed to initialize.

1 Like

Are you getting any connection errors like last time?

That still seems to be an issue.

I think I am going to restart zoneminder, then restart home assistant to see if I get a different outcome. Unless you don’t think that’s a useful diagnostic step?

(homeassistant) homeassistant@hassbian:~ $ grep -i connection .homeassistant/home-assistant.log
2017-11-29 20:06:20 ERROR (Thread-11) [homeassistant.components.zoneminder] Connection error logging into ZoneMinder
(homeassistant) homeassistant@hassbian:~ $ date
Wed 29 Nov 22:45:37 UTC 2017

That didn’t achieve anything useful. I can STILL telnet to the zm host on 7777 and 80, but I still get this bit from the homeassistant.log:

homeassistant@hassbian:/home/pi $ cd; source /srv/homeassistant/bin/activate
(homeassistant) homeassistant@hassbian:~ $ tail -100 .homeassistant/home-assistant.log| grep zoneminder
2017-11-29 22:49:02 ERROR (Thread-9) [homeassistant.components.zoneminder] Connection error logging into ZoneMinder
2017-11-29 22:49:02 ERROR (MainThread) [homeassistant.setup] Setup failed for zoneminder: Component failed to initialize.

I do see access to zm’s apache logs:

ACCESS

root@LeFanu:~# grep -i 192.168.10.115 /var/log/apache2/access.log
192.168.10.115 - - [29/Nov/2017:01:48:32 +0000] “GET /zm/api/monitors/1.json HTTP/1.1” 404 457 “-” “curl/7.38.0”
192.168.10.115 - - [29/Nov/2017:01:49:21 +0000] “POST /zm//index.php HTTP/1.1” 200 2681 “-” “python-requests/2.18.4”
192.168.10.115 - - [29/Nov/2017:01:49:22 +0000] “GET /zm/api/host/getVersion.json HTTP/1.1” 404 518 “-” “python-requests/2.18.4”
192.168.10.115 - - [29/Nov/2017:02:37:11 +0000] “GET /zm/api/monitors/1.json HTTP/1.1” 404 365 “-” “curl/7.38.0”
192.168.10.115 - - [29/Nov/2017:02:41:17 +0000] “GET /zm/api/composer.json HTTP/1.1” 200 1057 “-” “curl/7.38.0”
192.168.10.115 - - [29/Nov/2017:02:53:25 +0000] “POST /zm//index.php HTTP/1.1” 200 2664 “-” “python-requests/2.18.4”
192.168.10.115 - - [29/Nov/2017:02:53:26 +0000] “GET /zm/api/host/getVersion.json HTTP/1.1” 404 426 “-” “python-requests/2.18.4”
192.168.10.115 - - [29/Nov/2017:02:57:19 +0000] “GET /zm HTTP/1.1” 301 407 “-” “curl/7.38.0”
192.168.10.115 - - [29/Nov/2017:02:57:44 +0000] “GET /zm/ HTTP/1.1” 200 3013 “-” “curl/7.38.0”
192.168.10.115 - - [29/Nov/2017:02:59:08 +0000] “GET /zm HTTP/1.1” 301 407 “-” “curl/7.38.0”
192.168.10.115 - - [29/Nov/2017:02:59:18 +0000] “GET /zm HTTP/1.1” 301 407 “-” “curl/7.38.0”
192.168.10.115 - - [29/Nov/2017:03:01:59 +0000] “POST /zm//index.php HTTP/1.1” 200 2664 “-” “python-requests/2.18.4”
192.168.10.115 - - [29/Nov/2017:03:02:01 +0000] “GET /zm/api/host/getVersion.json HTTP/1.1” 404 426 “-” “python-requests/2.18.4”
192.168.10.115 - - [29/Nov/2017:03:08:09 +0000] “POST /zm//index.php HTTP/1.1” 200 2664 “-” “python-requests/2.18.4”
192.168.10.115 - - [29/Nov/2017:03:08:11 +0000] “GET /zm/api/host/getVersion.json HTTP/1.1” 404 426 “-” “python-requests/2.18.4”
192.168.10.115 - - [29/Nov/2017:03:13:12 +0000] “POST /zm//index.php HTTP/1.1” 200 2664 “-” “python-requests/2.18.4”
192.168.10.115 - - [29/Nov/2017:03:13:14 +0000] “GET /zm/api/host/getVersion.json HTTP/1.1” 404 426 “-” “python-requests/2.18.4”
192.168.10.115 - - [29/Nov/2017:17:10:35 +0000] “^]” 400 0 “-” “-”
192.168.10.115 - - [29/Nov/2017:18:40:41 +0000] “GET /zm/index.php HTTP/1.1” 200 3013 “-” “curl/7.38.0”
192.168.10.115 - - [29/Nov/2017:20:07:45 +0000] “GET /zm/ HTTP/1.1” 200 12007 “-” “curl/7.38.0”
192.168.10.115 - - [29/Nov/2017:22:49:42 +0000] “^]” 400 0 “-” “-”

ERROR
root@LeFanu:~# grep -i 192.168.10.115 /var/log/apache2/error.log
[Wed Nov 29 01:49:21.326461 2017] [:error] [pid 6659] [client 192.168.10.115:36134] INF [Login successful for user “admin”]
[Wed Nov 29 02:53:25.317459 2017] [:error] [pid 10161] [client 192.168.10.115:36328] INF [Login successful for user “admin”]
[Wed Nov 29 03:01:59.871677 2017] [:error] [pid 10275] [client 192.168.10.115:36362] INF [Login successful for user “admin”]
[Wed Nov 29 03:05:53.061199 2017] [:error] [pid 10341] [client 192.168.10.115:37662] INF [Login successful for user “admin”]
[Wed Nov 29 03:08:09.889449 2017] [:error] [pid 10341] [client 192.168.10.115:36466] INF [Login successful for user “admin”]
[Wed Nov 29 03:13:12.531893 2017] [:error] [pid 10285] [client 192.168.10.115:36546] INF [Login successful for user “admin”]
[Wed Nov 29 03:14:16.827295 2017] [:error] [pid 10288] [client 192.168.10.115:37804] INF [Login successful for user “admin”]
[Wed Nov 29 05:03:25.949308 2017] [:error] [pid 10277] [client 192.168.10.115:39182] INF [Login successful for user “admin”]

I don’t know about you, but I find that ‘login successful’ contradictory and interesting.

This doesn’t look like a good sign.

Check the log for anything between

as you’re only grep’ing “zoneminder”

That is sound advice, but those are literally the only two lines that come up in /home/homeassistant/.homeassistant/homeassistant.log when the system starts up; after that, nothing else shows up; perhaps the other output gets written to another log?

try adding this to your configuration.yaml:

logger:
  logs:
    homeassistant.components.zoneminder: debug

should produce more information.

Little more granularity:

pi@hassbian:~ $ sudo grep -i zoneminder /home/homeassistant/.homeassistant/home-assistant.log
2017-11-30 19:31:16 INFO (MainThread) [homeassistant.loader] Loaded zoneminder from homeassistant.components.zoneminder
2017-11-30 19:31:16 INFO (MainThread) [homeassistant.setup] Setting up zoneminder
2017-11-30 19:31:16 DEBUG (Thread-2) [homeassistant.components.zoneminder] Attempting to login to ZoneMinder
2017-11-30 19:31:18 ERROR (Thread-2) [homeassistant.components.zoneminder] Connection error logging into ZoneMinder
2017-11-30 19:31:18 INFO (MainThread) [homeassistant.setup] Setup of domain zoneminder took 1.8 seconds.
2017-11-30 19:31:18 ERROR (MainThread) [homeassistant.setup] Setup failed for zoneminder: Component failed to initialize.

What I find interesting is that a) opt_auth is turned off in the ZM options; and I just reconfirmed I can telnet to the zm host on ports 80 and 7777. I think I need to look at the access and error logs on the zm host, but I’m not sure if the failure to connect is app-based or apache-centric.

Thanks again for your follow-up and insight.

I know it’s been a while since the last update in this topic but I just had the same problem.

Try going to:

http://your.zm.host/zm/api/

and it’ll tell you if everything is alright with your zoneminder CakePHP installation. In my case, mod_rewrite wasn’t working and that was because I had AllowOverride None for the Zoneminder html directory in apache2/sites-enabled/000-default.conf … I fixed that, restarted apache2, and restarted HA and I can see my cameras.

thank you for this – I had my zoneminder app disabled while I switched ISP’s and I’m about to turn it back on again. I will test this.