Zoneminder, home assistant and Machinelearning

Nico Writing by Nico
  8 min of reading

This page has been visited ... times

Zoneminder, home assistant and Machinelearning

Dlandon this year released a Docker image complete with Zoneminder and Machinelearning, integration into home assistant is complete. This is why this article absolutely had to see the light of day. For less than a year, installation under docker has been greatly simplified. In addition, machinelearning is very complete thanks to object detection, facial detection, facial recognition, plate recognition, etc ….


  • Home assistant core or HAOS installed and functional
  • Traditional computer with HDD or NAS type
  • Docker installed and functional on the computer
  • Know how to use the docker environment to install and configure Zoneminder

The installation environment:

Zoneminder will be installed on a NAS running Openmediavault with docker. This choice is almost essential, on the one hand the CPU / GPU processor is relatively powerful, moreover the storage of videos can become very invasive. I do not recommend installing Zoneminder on a Raspberry Pi, not powerful enough for zm and active Machinelearning.

when the home assistant OS, it is installed on a Raspberry pi since can, before I used the home-assistant core which was running in a container on the NAS.

below we find the docker command that we find in the documentation of the github repository .

docker run -d --name="Zoneminder" \
--net="bridge" \
--privileged="false" \
--shm-size="8G" \
-p 8443:443/tcp \
-p 9000:9000/tcp \
-e TZ="America/New_York" \
-e PUID="99" \
-e PGID="100" \
-v "/mnt/Zoneminder":"/config":rw \
-v "/mnt/Zoneminder/data":"/var/cache/zoneminder":rw \

Example of custom configurations “the one I use” for Openmediavault, you have to think about customizing the TZ timezone as well as any mounting volume. You can install ZM unsecured with the port -p 8080: 80 , however I strongly advise to install in ssl, letsencrypt is part of the container. Bye!

docker run -d --name="Zoneminder" \
--net="bridge" \
--privileged="false" \
--shm-size="8G" \
-p 8443:443/tcp \
-p 9000:9000/tcp \
-e TZ="Europe/Paris" \
-e PUID="1000" \
-e PGID="100" \
-v "/sharedfolder/Appdata/Zoneminder":"/config":rw \
-v "/sharedfolder/Télésurveillance/Zoneminder":"/var/cache/zoneminder":rw \

After launching the image, the installation is done quickly thanks to dlandon’s work on the image. Previously with the old image of Zoneminder you had to wait 20 to 40 minutes, the ES and ML part took a lot of time. Now Zoneminder and The ZMEventnotification package install in less than 5 minutes .

PS: If you want to use a installation under docker-compose you will find the code here.

1 - Preparation of Zoneminder for Home assistant and Machinelearning ML

Zoneminder password protection

Change the default user Admin in options »> users and set a password

Then in Options »> Systems

Check the boxes like the image below and enter a Hashsecret code for more security

  1. OPT-USE_AUTH: password authentication
  2. AUTH_HASH_SECRET: Additional code ( you can generate a code here )
  3. AUTH_HASH_LOGINS: take into account double security
  4. OPT_USE_API: Activate the Zoneminder API
  5. OPT_USE_LEGACI_API_AUTH: enable API authentication
  6. OPT_USE_EVENTNOTIFICATION: Consideration of machine learning
zoneminder option settings

Setup for Home Assistant

Then you have to create a user dedicated to Homeassistant with an opening to the Zoneminder API:

Options »> Users » Add users

zoneminder user settings

2 - Machinelearning configuration (ZMEVENTNOTIFICATION)

To begin with, all the documentation is available at this address

For the learning machine we have 3 files to customize for these 3 files there is also a duplicate example. So these are the secret.ini files which contain all the passwords and objectconfig.ini contains each setting for each camera. Basically we indicate what we want Zmeventnotification to analyze according to each camera.

secrets.ini should look like this (in my config I don’t use the ML API, OpenAlpr, Escontrol, Mqtt and Pushover)

# your secrets file

# fid can have the following values:
# a particular <frameid>, alarm or snapshot
# starting ZM 1.35, you can also specify
# objdetect_mp4, objdetect_gif or objdetect_image
# this needs create_animation enabled in objectconfig.ini and associated flags




PLATEREC_ALPR_KEY=your_platerec_api_key # that i use




Next to objectconfig.ini which should look like the code below. With the new version of ZMeventnotification, the configuration of monitors has been greatly simplified

Click here if you want to read the official doc.

For these settings, do not hesitate to write to me but in the first place it is a question of modifying the [monitor-x] indeed we do not put the name of its camera but if this is in the first position, we will call it monitor-1 and so on, below is an example of garage monitoring.

# mon Door


use_sequence= yes # Important for the support of the new system

in order to be able to use the capture of images by person you must create a folder if it does not exist in … named known_faces and integrate inside a subfolder named nicolas then integrate photos of you which will be named 1.webp, 2.webp, etc. architecture direct link


Once all the images have been inserted or as soon as you add a new image, you will have to generate the train_face, so let’s go into the docker zoneminder:

docker exec -it zoneminder /bin/bash

Once all the images are integrated in the folder or in case of adding images, run the following command to generate the trainface:

sudo -u www-data /var/lib/zmeventnotification/bin/

restart the service

sudo service zoneminder restart

and voila if everything went well Zmeventnotification should be functional.

3 - Integration of Zoneminder in Home Assistant

zmeventnotification known-faces

the lines of codes below are to be entered in the configuration.yaml of home-assistant to know all the parameters consult this official page: Intéegrate Zoneminder and Home assistant.

interface zoneminder in home assistant

full zoneminder interface in home assistant

In addition to this integration into home-assistant Zoneminder allows a service called zoneminder.set_run_state. Allows to Change the state of Zoneminder.

What is a state in Zoneminder:

A state in Zoneminder allows you to manage the Camera Modes as we see fit, just by switching to this state.

By default there are 3 states in Zm:

  1. Stopped: unactive all cameras
  2. Reboot: reboot all cameras
  3. Default default setting

For Home Assistant I created two new states, HOME is a state when I am at home, and AWAY when I am away, these states are used as part of an automation by alarm management

  1. HOME: when I am at home the indoor cameras are in Monitor mode and the exteriors in Modect.
  2. AWAY: when I am away they all switch to Modect.

IMPORTANT ! the camera modes must be configured before recording a new state, see the Gif below.

ADVANTAGE: Compared to the Zm binary-sensor which allows you to switch from one mode to another in HA, the change of state is very practical when you want to choose another mode, when you are full of cameras and above all simplifies automations in HA call a service without needing to call each camera or create a binary_sensor Home or Away group in HA group.yaml.

Setting up a report in zoneminder

4 - How Modes work in Zoneminder:

  • None: Monitor disabled. No flow visualized nor any event generated.
  • Nodect: This is a special mode designed to work with external triggers. In Nodect, no motion detection takes place but the events are recorded on external triggers
  • Monitor: The monitor is only available for live streaming. Without image or event analysis.
  • Mocord: The monitor records continuously, with any movement evidenced in these events.
  • Modect: The monitor analyzes images and generates events. The video records in motion for a specified time.
  • Record: The monitor records continuously. Events of fixed duration are generated regardless of movement, much like conventional time-lapse video recording. No motion detection takes place in this mode.

How Zones work in Zoneminder

An article is dedicated to zones and presets, click here!

How filters work in Zoneminder

An article is dedicated to filters, click here!

In Conclusion

Finally, Zoneminder may not have the most beautiful interface, but thanks to its free and stable nature it is certainly the best camera management tool around. Once you have mastered the various aspects, it then becomes practical, intuitive and essential from a security point of view, integration into Home assistant is a significant plus.



Founding member of the Haade site, a home automation enthusiast with all the tricks that go well.