Hi there, new to the HA community.
I’m the developer for the ZoneMinder Event Server/machine learning hooks and zmNinja. A lot of folks who come by my GitHub repos seem to use ZM with HA. I recently setup HA and realized the existing integration uses legacy approach to ZM. ZM 1.33 and beyond use a better API system (via tokens) as well as other improvements. I also realized a lot of folks fall back to MQTT or Nodered to talk to my ES because there isn’t another way. Well, there is an easier way now.
I’ve just released a new project called py-zm that gives you access to:
The new API system (or falls back to the old one)
Pythonic access to the ZM Event server, so you get real time access
Access to Mapped Memory (like the perl daemons do)
Integration with the ZM logging system (if it makes sense)
This is going to evolve over time, but though folks who want better ZM integration may want to explore this package. I’ll likely eventually build HA modules on my own.
Yup - its a simple wrapper around TFLite and uses Google Coral accelerator. There are multiple models that do this (and some more accurate than mobile net SSD that this project uses). ZM is an NVR for motion recording, systems such as this (or many others) can be used as an adjunct as you say. I tested both mobile net and yolov3 and found the latter more accurate. You can run it off an accelerated USB stick (Coral/Movidius/etc) and get good real time FPS. You can also run it off a GPU, if you have one.
My apologies - I might not have been clear. Yolov3 is another ‘approach’ of doing person detection. It is not a docker image. The project you linked to does the work required to make things work easily with Home Assistant. I haven’t looked at the project in detail (just a cursory glance) but I suppose we are completely digressing. My original post was about more detailed support for ZM APIs and doesn’t have much to do with object detection, except for the fact that for folks who use the ZM Event Server (which does also do object/person detection using Yolo) will now have python API support
No I apologize, I didnt mean distract from the post. I understand about yolo, i just thought you were talking about a specific docker project similar to frigate.
SO back to the topic here, i wasnt aware zoneminder handled object/person detection. I’m going to install it now. Appreciate all the good info and work here!
@pliablepixels, just want to say thanks for all your work. I have only in the last month (in a new home) brought up a new system using HA + Zoneminder + zmeventnotification. All of this is running via docker containers so yes I am leveraging the dlandon docker image you pointed to (also Kudos to dlandon). Thus far I have been using the YOLO3 person detection you provided to relay events into HA via MQTT. Processing these events in HA and retrieving images from Zoneminder is not as clean/elegant as I would like, so just wanted let you know I will try out your pyzm API via AppDaemon. I am stealing the idea to use appdaemon from seanb’s article (thanks for the write-up!).
Nice! Glad you find all of this useful. We just released ZM 1.34 and along with it, pyzm which I am hoping becomes the standard official API(+ES+etc) wrapper for ZM in Python so we can extend/maintain one solution. I just read the article you pointed to and have the following thoughts:
When you use pyzm, please use the new token system, not user/pass.
The ES supports notification throttling on its own - no need for external throttling, if its just time based (tokens.txt has an interval field per monitor which specifies how long to wait before sending the next one)
I’ve also implemented a remote ML component, if running ML in the ZM docker is too expensive and the master branch of the ES now has the ability to fallback to local OD if the gateway fails (as a last resort) - the advantage here is that the gateway is a constantly running service, so the expensive model “load” time is eliminated on a per request basis.
Thanks for the speedy response and pointers.
Regarding tokens, yep I saw that in your docs, I am definitely going to go with pyzm.
Will definitely look into the ES throttling, thanks for the pointer, I am assuming ES is the zm event server you wrote (zmeventnotification).
dlandon was quick to provide 1.34, took me awhile to work through updating in docker (noob on docker) but yes i am already on 1.34.
I will update this thread once I have something. Gotta knock the rust off of my python skills.
I’m currently using the dlandon docker as well and finding it hard to get the motion detection images and object classifications from ZM into HA notifications.
So if the use of pyzm makes it easier to extract the detected object from the ZM alert as well as the image then I’m super interested to see how you go.
Currently, I’m getting an alert array sent via MQTT and the alert array is slightly different for person and car object detection which makes it tricky for someone like me with very little programming skill to pull out the detected object and image and feed them into a HA notification service.
No, pyzm is a ‘developer SDK’ not a replacement for dlandon’s docker container. His docker container is meant be ‘run out of the box’ in terms of not needing any programming, but you do need to configure the machine learning options correctly. Your post isn’t clear on what exactly is the issue.
@wjbeckett I agree, pyzm will not make it easier to get the desired notifications out of zoneminder/zmeventnotification-server (ES). Given I recently went through this effort, I found the main areas to focus are on how you invoke dlandon’s docker image (I just set it up to install all the image processing libraries) and properly configuring ES via the .ini files located in /etc/zm internal to the running container. If you are running docker-hassio on the same host as zoneminder, you will need to adjust the exposed listening ports via this same command line.
Debugging iterated through the following steps:
Opened MQTT Explorer, pointed to my mqtt-server and watched from zoneminder/xx topics.
I must say I like the MQTT events as a simple/clean way to push these notifications into HA. I was attempting to use these events to trigger an automation to message/text the notes/info text inside the ES notification plus the objectdetect image associated with the notification event. This is available via the old URL based zoneminder API but have not found it yet in the pyzm API.
Thus far, pyzm is a piece of cake to set and pull info from zoneminder. However, I have yet to find a way to easily pull an event image e.g. objectdetect, snapshot, or explicit fid? I am looking for a method on the Event object or ZMApi and don’t see one. Perhaps @pliablepixels can comment?
That is correct. Pulling an image isn’t actually part of the ZM API per se. It uses https://portal/zm/index.php?view=image (not /zm/api) so as of now pyzm does the api wrapper part but I’m not averse to adding wrappers for direct media access too. Of course, PRs are very welcome - these days I’m context switching so much between zmNinja, zmMagik, zmES and mlapi, I’ve come to a stage where I completely forget what I did a week ago in any of these projects and have to relearn…
Understood, I prototyped a child class of ZMApi with a get_event_image(…) method using that URL template (you provided in your documentation… thanks). I was able to retrieve a local copy of the alarm, snapshot, or objectdetect frame. However, your _make_request(…) method returns the r.json() version of the response which caused problems when trying to pull a raw copy.
Specifying this uri for sending text message was the area I was unhappy with in HA. Trying to code via HA yaml and feed the uri to notify caused me some grief (very cryptic error messages).Using the python requests api (emulating what you did) combined with the token based auth was rock solid in retrieving these image files (beat the heck out of it).
Happy to post a PR to your zmeventnotification github project. I will do that this weekend. LMK if you prefer a different avenue. Thanks again for the fast response.