MQTT notification possible?

Is anyone using MQTT as a notification method for Flexget? There’s currently no plugin that I can find, but I was curious if anyone had kludged together a solution that they’d be willing to share.

I’d like to be notified via an MQTT topic whenever a torrent download is completed.

I think it should be fairly simple to make a new notifier plugin that supports this, you should give it a go. :wink:

Yeah, was thinking about it. Any suggestions on the best plugin to base it upon or any good docs on how to create plugins?

Also what’s the standard process around including additional python modules that might be required? I’m thinking starting with the paho-mqtt-client has lots of the functionality pre-built so I don’t have to re-write from scratch. Would you install that module in the core, or only if users want to use an MQTT plugin?

Take a peek at a few of the other notifier plugins. As for the dependency, we’d probably not add it to core, rather just fail and give the user a message they need to install it to use that plugin. You can see an example here:

So I coded up an MQTT notifier plugin, but was hoping to get some feedback. So far it’s working and I can submit to my self-hosted broker using certificates as well as to a public broker w/out authentication. Haven’t tested against a broker with user/pass auth just yet.

Question for you @gazpachoking - the callbacks don’t seem to be executing (or at least logging to the logger correctly with everything else). Any ideas or suggestions on getting the callbacks to fire entries into logs?

I’m open to feedback on coding styling, etc too - just let me know. Once I do a bit more testing and hopefully fix the call-back issue, I’ll create a PR.

A few things:

  • The DependencyError should be raised inside your notify method, rather than at the root of the module.
  • Maybe rather than using the class, you could use the one-off publish function? I think the reason you weren’t getting your callback logging is because you never call the .connect method on the instantiated class.

Don’t be afraid to open a pull request, even if it’s not done yet. Pull requests are a nice place to have discussion, and it’s easy to add comments right on the code in those.

I initially started with the one-off publish, but it lacks most of the detailed configuration that I wanted. This way requires a little more code, but offers far more configuration flexibility. The biggest one was the ability to use self-signed SSL certs for authentication, which as far as I can tell, can’t be done with paho using the simple publishing functions.

Working on creating a PR for the changes.