MQTT & NodeRed support

Anything you want added or changed in future versions of ZoneMinder? Post here and there's a chance it will get in! Search to make sure it hasn't already been requested.
Post Reply
bradmck
Posts: 1
Joined: Wed Sep 12, 2018 9:59 pm

MQTT & NodeRed support

Post by bradmck »

Hi:

I listened to a couple of the devs on FLOSS Weekly (Andrew and Isaac I believe) and talk about integration with other systems came up. They were asked about integrating with other security systems, etc and one of the devs stated that they'd love to have more integration with things down the road. MQTT and NodeRed both came to mind as an easy(ish) ways to be able to increase integration possibilities. In fact someone would just write a NodeRed "Node" to be able to talk to the ZM API - or maybe your event engine? Granted MQTT would take some work on the ZM side but MQTT has libraries available for pretty much all languages and is very lightweight. I don't have the knowledge to code anything up to help but thought it was worth mentioning given the talk on the podcast.

And one of the devs mentioned HomeAssistant thinking they were using the API, and yes, it is HomeAssistant that someone built a "Component" for ZoneMinder for. I don't know what it's doing under the hood but you had the right name.

Also - congrats on the new release!
Brad
kevins
Posts: 7
Joined: Sun Aug 06, 2017 8:24 pm

Re: MQTT & NodeRed support

Post by kevins »

Here is a working flow that performs a login and then passes cookie to JSON request.

Code: Select all

[{"id":"df9abd12.9df57","type":"inject","z":"b852244.c78c5d8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":248,"y":525,"wires":[["62b463e4.f8e27c"]]},{"id":"448767a9.6a3788","type":"http request","z":"b852244.c78c5d8","name":"post","method":"POST","ret":"txt","url":"http://192.168.50.240/zm/index.php","tls":"","x":709,"y":525,"wires":[["5977884a.e8e458","96a00cfb.c3323"]]},{"id":"62b463e4.f8e27c","type":"function","z":"b852244.c78c5d8","name":"set login payload and headers","func":"msg.payload = \"username=ADMIN&password=PASSWORD&action=login&view=console\";\nmsg.headers = {};\nmsg.headers['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';\nmsg.headers['Accept-Encoding'] = 'gzip, deflate';\nmsg.headers['Accept-Language'] = 'en-GB,en;q=0.5';\nmsg.headers['Connection'] = 'keep-alive';\nmsg.headers['Content-type'] = 'application/x-www-form-urlencoded';\nmsg.headers['Cookie'] = 'zmSkin=classic; zmCSS=classic;';\nmsg.headers['Host'] = '192.168.50.240';\nmsg.headers['Referer'] = 'http://192.168.50.240/zm/';\nmsg.headers['Upgrade-Insecure-Requests'] = '1';\nmsg.headers['User-Agent'] = 'node-red';\nreturn msg;","outputs":1,"noerr":0,"x":480,"y":525,"wires":[["448767a9.6a3788"]]},{"id":"96a00cfb.c3323","type":"debug","z":"b852244.c78c5d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":985,"y":524,"wires":[]},{"id":"5977884a.e8e458","type":"function","z":"b852244.c78c5d8","name":"set request payload and headers","func":"msg.payload = {};\nmsg.headers = {};\nmsg.headers['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';\nmsg.headers['Accept-Encoding'] = 'gzip, deflate';\nmsg.headers['Accept-Language'] = 'en-GB,en;q=0.5';\nmsg.headers['Cache-Control'] = 'max-age=0';\nmsg.headers['Connection'] = 'keep-alive';\nmsg.headers['Cookie'] = 'zmSkin=classic; zmCSS=classic; ZMSESSID='+msg.responseCookies.ZMSESSID.value;\nmsg.headers['Host'] = '192.168.50.240';\nmsg.headers['Upgrade-Insecure-Requests'] = '1';\nmsg.headers['User-Agent'] = 'node-red';\n\n//headers[\"set-cookie\"][0]\n\nreturn msg;","outputs":1,"noerr":0,"x":487,"y":678,"wires":[["f50d7b5c.5a23c8"]]},{"id":"20ee379.f0f59c8","type":"debug","z":"b852244.c78c5d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":979,"y":677,"wires":[]},{"id":"f50d7b5c.5a23c8","type":"http request","z":"b852244.c78c5d8","name":"get","method":"GET","ret":"txt","url":"http://192.168.50.240/zm/api/events/consoleEvents/1%20hour.json","tls":"","x":716,"y":677,"wires":[["20ee379.f0f59c8"]]}]
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: MQTT & NodeRed support

Post by asker »

MQTT support was recently added to the event notification server.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
Post Reply