Zoneminder, home assistant and Machinelearning
8 min of reading.
This page has been visited ... times.
- The installation environment:
- 1 - Preparation of Zoneminder for Home assistant and Machinelearning ML
- Zoneminder password protection
- Setup for Home Assistant
- 2 - Machinelearning configuration (ZMEVENTNOTIFICATION)
- 3 - Integration of Zoneminder in Home Assistant
- What is a state in Zoneminder:
- 4 - How Modes work in Zoneminder:
- How Zones work in Zoneminder
- How filters work in Zoneminder
- In Conclusion
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 .
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!
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
- OPT-USE_AUTH: password authentication
- AUTH_HASH_SECRET: Additional code ( you can generate a code here )
- AUTH_HASH_LOGINS: take into account double security
- OPT_USE_API: Activate the Zoneminder API
- OPT_USE_LEGACI_API_AUTH: enable API authentication
- OPT_USE_EVENTNOTIFICATION: Consideration of machine learning
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
2 - Machinelearning configuration (ZMEVENTNOTIFICATION)
To begin with, all the documentation is available at this address https://zmeventnotification.readthedocs.io/
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)
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
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.
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 https://zmeventnotification.readthedocs.io/en/latest/guides/hooks.html?highlight=known#known-faces-images
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:
Once all the images are integrated in the folder or in case of adding images, run the following command to generate the trainface:
restart the service
and voila if everything went well Zmeventnotification should be functional.
3 - Integration of 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:
- Stopped: unactive all cameras
- Reboot: reboot all cameras
- 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
- HOME: when I am at home the indoor cameras are in Monitor mode and the exteriors in Modect.
- 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.
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
How filters work in Zoneminder
An article is dedicated to filters, click here!
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.