Zoneminder zone specific alarms

I have zoneminder cameras and sensors setup in HASS, and I have automatons currently triggering off of event count increases on a per camera basis. However I’d really love to be able to trigger off of specific motion zones on a camera (monitor in zoneminder).

For example: Camera pointed at front yard and street. I’d want to detect motion in a zone that defines the street and record but if same camera detects motion in the zone near the front door send me an alert.

Has anyone figured out how to surface zone specifics to HASS?

I’ve since discovered which apparently alerts HASS as soon as a zone detects motion, which gets rid of the delay I’m getting from the default zone minder integration.


Could you please provide an example og how you got this working?

Best regards
Nuno Reis

For some reason I’ve yet to figure out I cannot get it to talk to MQTT correctly, it is always an error. Hard to find anyone talking about this recently for help.

I get this:

New client connected from 192.168.XXX.XXX as Net::MQTT::Simple[9576] (c1, k60).
Socket error on client Net::MQTT::Simple[9576], disconnecting.

I got that too, without the client name thou.
Socket error on client , disconnecting.
In zmnotifications.ini i have set the ssl protocol to no, that error disaperead.
I got a new one XD
Invalid protocol version 3 in CONNECT
Seems the MQTT client uses one protocol and mosquitto addon is on another.
In my case at least.
Anyone knows what MQTT protocol version the addon uses? And what protocol this one uses

I got to where you were.

That error, at least with me, the topic zoneminder/monitor_id gets info, an example with HiveMQTT from my addon.

2019-06-20 19:24:18
Topic: zoneminder/1
Qos: 0
{"monitor":"1","eventid":"686","state":"alarm","name":"Porta:(686) Forced Web "}

So check if the info is there or not on your case.
That error always is there, because after publishing the zmeventserver drops the connection, seamingly without calling a the proper disconnect method from NET::MQTT::Simple
I am trying some tinkering with the script to see if i can get the connection dropped properly.
Also there is a bug on one of the .pl scripts at this location (in my install ofcourse)
On the line 25, where the default stuff is:

package Net::MQTT::Simple::Auth;

use parent 'Net::MQTT::Simple';

our $VERSION = '0.001';

sub new {
        my ($class, $server, $user, $password, $sockopts) = @_;
        # @_ == 2 or @_ == 3 or _croak "Wrong number of arguments for $class->new";

        my $self = $class->SUPER::new ($server, $sockopts);

        $self->{mqtt_user} = $user;
        $self->{mqtt_password} = $password;

        return $self;

sub _send_connect {
        my ($self) = @_;

        $self->_send("\x10" . Net::MQTT::Simple::_prepend_variable_length( pack (
                "x C/a* C C n n/a* n/a* n/a*",

Your file will have 0x03 that is MQTT 3.1 not 3.1.1, so that was also my error.
If you put, 0x04, it will use 3.1.1 protocol, but the best solution is to use the variable name that is on my code, since thtat value is set on another file of the Net::MQTT::Simple library.

At this point i could create a binary sensor for receiving alarms on initial movement, but have to reset the sensor on a time basis because zoneminder, nor zmninja send a alarm off when the movement stops, so it has to be time based.
I am trying to clear that error from the log, but since i dont know perl, it is basicaly a hack job :stuck_out_tongue:

Hope it helped you with your problem.

Best regards

1561056020: New client connected from as Net::MQTT::Simple[DLRJQDONHE] (p2, c1, k60, u'iot').
1561056020: Client Net::MQTT::Simple[DLRJQDONHE] disconnected.

Got rid of the error :stuck_out_tongue:

I am going to do a PR to zmNinja to see if he will accept the changes.
For now if you want the .pl files with the changes, let me know.

That’s great work, thank you! Excited to get this going. Like most people I just need a realtime alert of motion to send the camera feed to my phone/devices. This is great.