New ZoneMinder API

Thanks! It brought me closer, but I get errors in my HA logs as ZM is using a self-signed certificate. It seems the downloader integration chokes on these…

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 978, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 362, in connect
    self.sock = ssl_wrap_socket(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/ssl_.py", line 397, in ssl_wrap_socket
    return context.wrap_socket(sock)
  File "/usr/local/lib/python3.8/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/local/lib/python3.8/ssl.py", line 1040, in _create
    self.do_handshake()
  File "/usr/local/lib/python3.8/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1123)

I use my own CA and sign my own internal certs, so I have those added each HA container update.

Hadn’t thought of that. Do you automate this? Is there an easy way to do this?

The CA is manual as is the importing of the CA cert into the container :frowning:

I was able to edit the Downloader integration so that it did not balk at self-signed certificates. The file in question is /usr/src/homeassistant/homeassistant/components/downloader/__init__.py. Line 78, change req = requests.get(url, stream=True, timeout=10) to req = requests.get(url, stream=True, timeout=10, verfiy=False). When you restart HA, all will be good.

I was going to see if I could figure out how to put in a PR, however this did not solve my problem as the file downloaded from https://<ZMIP>:<ZMPORT>/zm/index.php?view=image&eid=<eventID>&fid=objdetect was the html login form, not an image. For whatever reason, HA was not authenticated against ZM.

Looks like I am going to have to go the AppDaemon route–thanks for your help!

I don’t have logins setup for my zoneminder instance.

1 Like

Well that was too obvious, thanks! I will look into how to go about submitting an official PR to the Downloader integration to ignore self-signed certs.

Can anyone help me with getting ES sending MQTT messages, I’m using the dlandon docker container, ZM is working correctly, the ES is also running but I’m not getting any MQTT messages from events so I’m guessing it’s my zmeventnotification.ini that’s wrong.

My docker container is set to use port 2080>9000
Do I need to change that in the ini to 2080 or leave it as 9000?

I have
push off
FCM off
MQTT on, server set to 192.168.1.3 (do I need the port)
No MQTT username or password
SSL set to off
Hooks set to off

I must be missing something or doing something wrong here.

Hi, my reply could be late, but still better than never :slight_smile:
As workaround (not a good from security point of view, since credentials will be part of URL) You can get the picture from ZM by providing credentials in the URL
https://<ZMIP>:<ZMPORT>/zm/index.php?view=image&eid=<eventID>&fid=objdetect& username=<ZMUser>&password=<ZMPass>&
I think it’s acceptable if HA and ZM servers are not available from outside.

I run hassio in a docker container and the dlandon ZM container. I was having similar issues of not receiving mqtt messages. The issue (I think) was the event server wasn’t able to connect to the MQTT broker.

Pretty sure I fixed it by adding the dlandon ZM container to the hassio docker network.

My current issue is i’m receiving the mqtt messages when an event happens but they’re very generic messages. They appear to come from the default zone setup in ZM and not any sort of object detection. Also none of the events in ZM have anything related to object detection.

In zmeventnotification.ini - i’m not using ssl. I have auth enabled, port 9000, fcm enable, mqtt enable,

I’m using the dlandon container with the following environment variables

    ports:
      - 8089:80
      - 9089:9000
    environment:
      - TZ=America/New_York
      - SHMEM=60%
      - PUID=99
      - PGID=100
      - INSTALL_HOOK=1
      - INSTALL_FACE=1
      - INSTALL_TINY_YOLOV3=0
      - INSTALL_YOLOV3=1
      - INSTALL_TINY_YOLOV4=0
      - INSTALL_YOLOV4=0
      - MULTI_PORT_START=0
      - MULTI_PORT_END=0

this is what one of the alerts look like.

{
  "hookvalue": "1",
  "state": "alarm",
  "name": "Front Door Sub:(7419) Motion All",
  "monitor": "3",
  "detection": [],
  "eventtype": "event_start",
  "eventid": "7419"
}

Any ideas what i’m missing that would prevent object detection from working?

Did you just install dlandons latest dockercimage for zm?
I’m having the same problems. There seems to be a problem with that image. A lot of people have seen the issues at this moment.

There are maps missing and other stuff.
At least I’ve push notifications but with no object detections.

Interesting… Is there a known working image that you know of?

EDIT: I’m not sure i’m using the new image that people are mentioning in the dlandon github issues.

Here’s my logs: https://i.imgur.com/KjiPnmj.png I think the “start hook processing failed” line could possibly be a clue… I need to figure out why that is failing. I am receiving the event_start notifications via mqtt but again they’re very generic and only related to the motion alert and nothing to do with object detection.

For reference, the ID hash for my dlandon/zoneminder image is sha256:42db1ce73998a70f7017fa534ec71dff6ad7862e382c3e0d44c0323a3aa22d34

EDIT EDIT:

Following along with some of the debug steps, i’m getting this python error when attempting to manually run the zm_event_start script.

sudo -u www-data /var/lib/zmeventnotification/bin/zm_event_start.sh 7438 3
Traceback (most recent call last):
  File "/var/lib/zmeventnotification/bin/zm_detect.py", line 27, in <module>
    import zmes_hook_helpers.utils as utils
ModuleNotFoundError: No module named 'zmes_hook_helpers'

EDIT EDIT EDIT: I fixed my issues by deleting everything and restarting (ha!). one issue I ran into on round 2 was trying to use Yolov3 when the config appears to be setup for v4. Switched to yolov4 and i’m now getting detections.

Tried that. Did get the missing folder from gtihub… Did put in Zoneminder folder but it didn’t work.
My docker/Linux knowledge is nearly zero.

How did you do it?

docker -rm Zoneminder ?

He changed again the image. Reading the notes I think mqtt is gone :frowning:

Thats not good… I relay on the MQTT for my object detections…

Well heck… Just saw this:
“THIS DOCKER IS DEPRECATED AND NO LONGER SUPPORTED.”
Seems that this is the end for the docker version?

I saw that… I’m guessing she/he got fed up with all the questions and requests for support.

I took a look and don’t see any other good Docker images. Does anyone have any suggestions?

Update. MQTT is still there. I tested and it’s working :slight_smile:

He just changed image to a lighter one and excluded hook.

yeah something like that, I use docker-compose though so I think I just did docker-compose down.

I also deleted the mounted data/config folder so that the container would recreate all of that.