Skip to content
This repository has been archived by the owner on Jun 18, 2022. It is now read-only.

Provide an IO service for publishing events to MQTT #89

Closed
flaviostutz opened this issue Jul 17, 2017 · 16 comments
Closed

Provide an IO service for publishing events to MQTT #89

flaviostutz opened this issue Jul 17, 2017 · 16 comments

Comments

@flaviostutz
Copy link

flaviostutz commented Jul 17, 2017

In the same way we have Webhook/TCP, there could be the possiblity of Kerberos.io to publish events to a MQTT broker.

That way it could be much simpler for various engines to listen to "motion" events and perform various tasks in parallel by listening to MQTT topics. One could look for people crossing, other to people identification, other to car counting, other to store snapshots on the cloud, just like plugins, but with no need to change the Marchinery code, in parallel and over the network (each one of these features could be a separate running container, on site or at the cloud).

We could start with simple event publishing (just like Webhook/TCP implementation), but them there could be some sort of time aggregation (just like "video" does when recording 5s of footage etc).

@flaviostutz
Copy link
Author

If it is OK for you guys (it's a great work you're doing here!), I will try to start an implementation on this.

@cedricve
Copy link
Member

@flaviostutz amazing ideas, yeah would be great! do you need any more info?

@cedricve
Copy link
Member

@flaviostutz let me know if you need help.

@cedricve
Copy link
Member

If someone can help contributing on this? I would love to pair program this feature.

@cedricve
Copy link
Member

@zingelst
Copy link

zingelst commented Sep 8, 2017

As a small suggestion, you may be able to achieve this using your existing Script IO plugin. Using the mosquitto-clients package (which should exist on Raspberry Pi, it's in Debian already), you could easily make a script that would publish to a MQTT broker. I'm not quite sure how your configuration gets to the Script plugin, but you'd need the MQTT broker host IP along with any security/QOS/etc options.

You'd at least be able to try it out without having to add code or an additional dependency (on say libmosquitto I do have some experience with libmosquitto. It's a very nice, small library which is pretty easy to use. If no one has gotten too far already, I might have some bandwidth to contribute some code to help out.

@cedricve
Copy link
Member

@zingelst would be great, let me know if you have some questions.

@flaviostutz
Copy link
Author

Unfortunately I had no time to code this yet. Sorry.
I was thinking it would publish the image on the topic too (not just metadata, configurable). Would it be too heavy?

@cedricve
Copy link
Member

Sorry publish the image on the topic?

@zingelst
Copy link

zingelst commented Sep 19, 2017 via email

@cedricve
Copy link
Member

aha ok, well I think videos shouldn't be a problem too but from my opinion you can just send a url instead of encoding the images in the message.

@cedricve
Copy link
Member

Hey guys,

@gianricod started working on a MQTT implementation, and we would like to have feedback.

@cedricve i have started working to it using libmosquittopp.

it is very basic at the moment.
it sends a message to a topic upon each call of save(image,json). the message contains the json object. very similar to the tcpsocket in that sense.

gianrico@vlin:~/machinery/build$ mosquitto_sub -h localhost -t "kios/mqtt" -v
kios/mqtt {"regionCoordinates":[97,41,220,208],"numberOfChanges":483,"timestamp":"1508514764","microseconds":"6-471402","token":16}
kios/mqtt {"regionCoordinates":[7,40,290,207],"numberOfChanges":1676,"timestamp":"1508514764","microseconds":"6-967244","token":16}

i see you have an enhancement open for that, we can discuss it there.
it needs to be polished a bit with more options/settings (and maybe use cases as well).

@cedricve
Copy link
Member

UPDATE - FYI @gianricod, I've added a throttling function yesterday. Which helps with not flooding the MQTT service. https://github.com/kerberos-io/machinery/blob/develop/src/kerberos/machinery/io/IoMQTT.cpp#L17

You can set the throttling rate in the configuration file (https://github.com/kerberos-io/machinery/blob/develop/config/io.xml#L43). So we can extend your current MQTT configuration with this also.

@cedricve
Copy link
Member

cedricve commented Oct 30, 2017

Update - @gianricod added a MQTT implementation. #106.

I will be testing it in a node-red flow, would be nice to receive some feedback about possible usecases (real life scenarios).

@cedricve
Copy link
Member

cedricve commented Nov 9, 2017

Integrated with @gianricod PR: MQTT intitial implementation #106

@cedricve cedricve closed this as completed Nov 9, 2017
@wicadmin
Copy link

wicadmin commented Sep 11, 2018

Use-case: Send to Telegram bot
Use-case: Send to Text-to-Speech in home automation/speaker system

I just implemented a node-red flow to send the alert and image URL to my Telegram bot and a messeage to my text-to-speech endpoint of home speakers. Thanks for the contribute!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants