MQTT

Current Development version likely to have breaking changes
Post Reply
atlas
Posts: 14
Joined: Fri Jan 17, 2020 10:46 pm

MQTT

Post by atlas »

I have openhab and Eclipse Mosquitto running on the same machine that has zoneminder on it. It looks like the mqtt currently implemented is for subscribing to topics only? I get two error msgs, MQTT publish returns 4 Interrupted system call & MQTT connect returns 15 Block device required

The way I think it should work is to publish messages. So on a Linux machine, apt-get install mosquitto (apt-get install mosquitto-clients as well) and this could send a simple msg to your home automation stuff like turning on a light, or sending a email/sms. This would be far simpler than what ever the current thing is now.

Is there a way to run a command when a camera triggered? If there was a box/empty field for a command when a camera is triggered would be nice, ex,

Code: Select all

 mosquitto_pub -h host -t zoneminder –m FrontDoorAlert
User avatar
iconnor
Posts: 3263
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: MQTT

Post by iconnor »

It should do both. Wwe publish new events. But it's not well tested. No one is using it.
atlas
Posts: 14
Joined: Fri Jan 17, 2020 10:46 pm

Re: MQTT

Post by atlas »

iconnor wrote: Mon Nov 25, 2024 3:41 pm It should do both. Wwe publish new events. But it's not well tested. No one is using it.
Hmm, Im still having trouble. 1.37.65

I tried a different approach, I opened up two remote terminals on my zoneminder/mqtt/openhab machine. One terminal I give command

Code: Select all

mosquitto_sub -h localhost -t zoneminder
and the other terminal I send it a message

Code: Select all

mosquitto_pub -h 192.168.46.3 -t zoneminder -m hi
. This works.
Next I try this from the my desktop computer

Code: Select all

sudo -u www-data /usr/bin/mosquitto_pub -h 192.168.46.3 -t zoneminder -m hi
and the message is received on my zoneminder machine as well.

So I move on to the zoneminder web gui - defining monitors -> recording tab -> Event Start Command:

Code: Select all

/usr/bin/mosquitto_pub -h 192.168.46.3 -t zoneminder -m hi
and no luck on that approach as well. I feel like I am getting close.
User avatar
iconnor
Posts: 3263
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: MQTT

Post by iconnor »

ZM appends event id and monitor id to the command, maybe that is screwing up mostquitto_pub. Maybe try wrapping it in a script which ignores command line parameters?
atlas
Posts: 14
Joined: Fri Jan 17, 2020 10:46 pm

Re: MQTT

Post by atlas »

iconnor wrote: Tue Nov 26, 2024 6:41 pm ZM appends event id and monitor id to the command, maybe that is screwing up mostquitto_pub. Maybe try wrapping it in a script which ignores command line parameters?
I think I got it to work (mqtt Publishing) via Recording --> Event Start Command
I put a very basic script in /usr/share/zoneminder/www/ and named it trigger1.sh

the script:

Code: Select all

nano /usr/share/zoneminder/www/trigger1.sh

Code: Select all

#!/bin/bash
/usr/bin/mosquitto_pub -h 192.168.46.3 -t zoneminder -m hi

Code: Select all

chmod a+x /usr/share/zoneminder/www/trigger1.sh

Code: Select all

chown www-data:www-data /usr/share/zoneminder/www/trigger1.sh


Back to zoneminder in the field "Event Start Command" I put :

Code: Select all

./trigger1.sh
When I triggered manual alarm I got the "hi" message using terminal with

Code: Select all

mosquitto_sub -h localhost -t zoneminder
So this is good enough for me. Thanks for your help, it would be nice to see mqtt fully implemented and buffed out someday as I think its here to stay and going to be used in everything in the future.
Post Reply