Problems with adding ZoneMinder to Home Assistant

Hello everyone

I’m trying to add ZoneMinder to my Home Assistant to get a live feed from a camera.
ZoneMinder works as it should, I have a live feed of the camera in the GUI (after much toil).

I’ve been looking at the guide here but as many of the integration guides from the Home Assistant website, it’s very short and assumes a lot of knowledge. But I’ve tried my best.

Okay, here’s the setup:

  • ZoneMinder is running on the same Raspberry Pi 3B+ as Home Assistant. (I only want one camera, currently running 1280*720, so as not to stress the CPU).
  • This is my configuration.yaml:
#Camera feed from ZoneMinder
zoneminder:
  - host: http://127.0.0.1/zm
    path: /etc/zm/
    path_zms: /zm/cgi-bin/nph-zms
    ssl: false
    verify_ssl: false
    username: xxxx
    password: xxxx

camera:
  - platform: zoneminder

I know the guide says that the path is /zm/ but it’s not for me for some reason. /zm/ does not exist, but my zm.conf etc are in /etc/zm/. I’ve tried with SSL on or off and with https/http and port 443 and 80. The host is http://127.0.0.1/zm because if I use that URL in the browser then I get into ZM, so that’s just my idea. Home Assistant is talking to ZoneMinder locally anyway.

I’ve been trying to read the log error I get but it’s not really helping me along. Maybe one of your could help me decipher where the hookup is. This is the first error block I get:

Logger: homeassistant.setup
Source: components/zoneminder/__init__.py:75
First occurred: 23.02.28 (1 occurrences)
Last logged: 23.02.28

Error during setup of component zoneminder
Traceback (most recent call last):
  File "/home/pi/homeassistant/lib/python3.8/site-packages/urllib3/connection.py", line 169, in _new_conn
    conn = connection.create_connection(
  File "/home/pi/homeassistant/lib/python3.8/site-packages/urllib3/util/connection.py", line 73, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

I get further errors afterwards, you can see all of them in this pastebin.

Anyone out there had success integrating ZoneMinder with Home Assistant who has an idea how to help? I would greatly appreciate your input.

Depending on your setup 127.0.0.1 may not be correct, try the actual ip of the pi.

Also, at a guess, if your path is /etc/zm then I would think your path_zms should be /etc/zm/cgi-bin/nph-zms

1 Like

Thanks for the response.

I would think that would be the right path as well, but under /etc/zm/ is only my config files, not the zms path. I’m working off the paths listed in the zm.conf file in /etc/zm/conf.d/.

Right now my “path:” in the configuration.yaml file is the path listed as ZM_PATH_DATA aka /usr/share/zoneminder. But I have also tried using the path for ZM_PATH_CONF aka /etc/zm. Again these are the paths listed in the ZM config file. My only doubt here is what is actually the path that Home Assistant needs. The ZM_DATA_PATH path has a bunch of files so that’s what I assume to be the right one, but again I could be very wrong.

My “path_zms” is now changed to /usr/lib/cgi-bin/nph-zms because that’s where I found the nph-zms file. Also it’s the one listed in the zm.conf file as ZM_PATH_ZMS.

Barring stupidity I am reasonably sure that the paths are correct. What I am NOT sure about is the actual host to use. Both ZM and HASS run locally on the same RPi. I’ve tried 127.0.0.1, localhost, my DuckDNS url, the Pi’s actual IP address…

Logically (at least to me) I would either have to use 127.0.0.1 or localhost OR whatever IP, port, hostname I can access ZM with on my PC. I’ve tried both 127.0.0.1 and localhost, but am unsure of the ports here. I can access ZM locally on the Pi with 127.0.0.1/zm, but I’m unsure of how to do that on my PC, and wouldn’t that then be the right url?

I’ve read some about the dude who developed ZM requiring SSL which is just crazy. I’ll enable it if I want to… anyway. I’m not sure if it’s the SSL messing me up because I do not want to connect via SSL if I don’t have to… this is a prototype project. I literally don’t care about security at this point in time. I just want it to work.

Anyway, I’ve yet to solve this.

I don’t use it so I don’t know about ssl, or what those paths are supposed to represent (or lead to), so I was just guessing based on the configuration options.

But regarding the host -

  • If it does need ssl, then it will need to be your duckdns address, and potentially you may need to forward any appropriate ports at the router
  • local host/127.0.0.1 may not mean what you think depending on your setup.

Regarding the latter point, as an example, if your homeassistant is running in a docker container then 127.0.0.1 will still be inside that container, whereas your zoneminder may be in another container (usually on a different 172.x.x.x address).

As I said, I’m just educated-guessing at all of this but hopefully it will help you diagnose the issue :slightly_smiling_face:

I guess this is your host that doesn’t work. In my configuration, I only have the IP address, not an URL.
I can’t say for sure if 127.0.0.1 will work, I also have both services on the same server, and I use the actual IP address.
In fact, my ZM configuration couldn’t be more simple :

zoneminder:
    host: 192.168.2.3
    username: user
    password: password

I’m using the latest 1.35 (which I wouldn’t recommend for a daily use !), didn’t change configuration when I upgraded from 1.30 or 32, no SSL, on an Ubuntu 20LTS server. Of course, there is a /etc/zm but it’s only for configuration, and zms resides in /usr/share/zoneminder/www/cgi-bin

1 Like

Okay, so I tried copying your more simple setup and I got further. Instead of giving me what I perceived as pretty random errors, I am now getting ZM login errors. I’m a bit confused because for the purpose of testing I have disabled authentication on ZM, so there should be no interface to login to. I’ll try adding the details anyway.

Question to you, however. Are you able to browse the Zoneminder GUI on your PC? I can browse it just fine (and have set up my camera) on the RPi’s browser, but I can’t figure out what url to use on my PC. My Pi’s IP address gets me Apache and adding a “/zm” at the end like I do on my RPi does nothing.

Anyway I am tiring a bit of ZM. I only need a live feed of a camera. But my attempts at setting up both FFmpeg and Onvif have failed spectacularly.

If you use Zoneminder just for a live feed, there’s way too much complication !
Can’t your camera be accessed with generic camera and RTSP flow ?

Maybe the API needs a user/password set ?
Only test I can make from my server is with nc/telnet as it’s headless. Both 127.0.0.1 or the IP answer on port 80, and I get answers to /zm and /zm/ (first one redirects to second).
Check with netstat -an | grep 80

Or, your ZM configuration isn’t fully installed, but if it works from another clients, I doubt it. See in your /etc/apache2/conf-enabled folder if there is a zoneminder.conf ? And there are several actions to enable cgi mod too. (a2enmod cgi, not sure it’s enough)

Yes, ZM is a pain to make it work. I’m having it because I used it years before HA (maybe years before HA even existed !) and as I’m used to it, I haven’t tried to fully integrate my cameras in HA (“never touch a running system” !!!). And once it works, it’s very efficient.

Yeah, I’ve found out that ZM is just hassle, I SHOULD just be able to use a generic setup with RTSP, Onvif, FFmpeg etc. But I’ve spent hours trying that as well. FFmpeg struggles to properly install and I can’t get Onvif to work. I get this error:

Unable to install package onvif-zeep-async==1.0.0: ERROR: 
Command errored out with exit status 1: 
command: /home/pi/homeassistant/bin/python3 -c 'import sys, setuptools, 
tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_r9famoe/lxml_ff24580b15b94d758f27ef68d81e16ce/setup.py'"'"';
 __file__='"'"'/tmp/pip-install-_r9famoe/lxml_ff24580b15b94d758f27ef68d81e16ce/setup.py'"'"';
f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', 
'"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' 
egg_info --egg-base /tmp/pip-pip-egg-info-buja1amp cwd: /tmp/pip-install-
_r9famoe/lxml_ff24580b15b94d758f27ef68d81e16ce/ 
Complete output (3 lines): Building lxml version 4.6.2. Building without Cython. 
Error: Please make sure the libxml2 and libxslt development packages are installed. ---------------------------------------- 
ERROR: Command errored out with exit status 1: python setup.py egg_info
Check the logs for full command output. 

WARNING: You are using pip version 20.3; however, version 20.3.1 is available. 
You should consider upgrading via the '/home/pi/homeassistant/bin/python3 -m pip install --upgrade pip' command.

Platform error: camera - Requirements for onvif not found: ['onvif-zeep-async==1.0.0'].

I then tried adding Onvif via the Integrations tab in the settings on the HA GUI but that one is stuck on “please wait while the integration is being installed”.

Suffice to say I am stumped.

Edit: And yeah I’ve tried installing the libxml12 and libxslt packages but pip can’t find them.

This is my working config, running latest ZM as a VM in Proxmox:

zoneminder:
  - host: 172.16.0.7
    path: /zm/
    path_zms: /zm/cgi-bin/nph-zms
    ssl: false
    #    verify_ssl: false
    username: !secret ZM_user
    password: !secret ZM_password

camera:
  - platform: zoneminder

What OS do you run on your PI ? Depending on the distribution, ffmpeg can be tricky to run. Compilation from source isn’t the easy way but sometimes necessary.

And how is connected your camera (over WiFi I guess) ?
I’m not using OnVif at all, neither with ZM nor HA (just RTSP flow when ZM isn’t active, while somebody’s home for instance).
Older MJPEG camera are configured this way :

  - platform: mjpeg
    mjpeg_url: http://192.168.7.14/videostream.cgi
    still_image_url: http://192.168.7.14/snapshot.cgi
    name: etage_direct
    username: !secret zm_user
    password: !secret zm_pass

Newest H264 this way :

  - platform: generic
    stream_source: rtsp://192.168.7.13:554/1
    still_image_url: http://192.168.7.13/tmpfs/auto.jpg
    name: rdc_direct
    username: !secret zm_user
    password: !secret zm_pass

Only the latest should need ffmpeg. I have v4.2 on an Ubuntu 20LTS. (from repository)