OctoPrint-MQTT icon indicating copy to clipboard operation
OctoPrint-MQTT copied to clipboard

Feature Request: MQTT Subscribe to Issue Commands to Octoprint

Open HotTabascoSauce opened this issue 6 years ago • 13 comments

It would be cool if you could issue MQTT publications on another device and have the octoprint perform actions based on subscriptions. Either octoprint native actions or sending Gcode options to the printer.

For example, if you were to send {"message": "connect", "port": "/dev/ttyUSB0", "baudrate": "115200"} to the topic /octopi/cmnd/ then the octopi instance would attempt to connect to the printer on USB0 at the given baud rate.

Or {"message": "position", "home": "all"} to the topic /octopi/cmnd/ then octopi would sent G28 to the printer while {"message": "position", "home": "X Y"} would home just the X and Y axis with G28 X Y.

I guess you might not need an entire library for gcode, could do something like {"message": "printer control", "gcode": "G28 X Y"}

Incoming messages from other devices could be executed immediately with a "now", or if printing, queued and executed when printer status is Operational

HotTabascoSauce avatar Nov 01 '17 02:11 HotTabascoSauce

I would also like some sort of control over MQTT. Just beeing able to use MQTT to change the temperatures would be a great help!

nightcat91 avatar Dec 30 '17 11:12 nightcat91

Ah, I've just created a new topic asking for the same thing! :)

Only solution I've found so far is to use the api to issue a command.

dp106 avatar Jan 08 '18 09:01 dp106

The plugin has helpers to subscribe and publish to topics. This can be used by other plugins. So you are welcome to write your own plugin to handle commands via mqtt.

derpicknicker1 avatar Jan 12 '18 08:01 derpicknicker1

Not sure I follow, I don't want to write another plugin. Rather as this is the MQTT plugin I would like it to be able to accept incoming messages as well as publishing them.

I'm probably using completely the wrong terminology as have been using MATT nodered etc for about 3 days 😀

dp106 avatar Jan 13 '18 15:01 dp106

Just adding another request for this feature. Would be nice to have OctoPrint perform built-in actions based on subscribed topics. Actions such as pausing, canceling and changing the temps, turning on/off the part cooling fan, etc. To keep the monitoring devices updated, I imagine it would also need to publish the action's current state as well.

mwolter805 avatar Jul 13 '18 18:07 mwolter805

I would love to be able to control my printer through home automation (Alexa/siri) and use MQTT commands to send GCode commands for that. Example to tell it to do stuff like "Alexa, pre-heat PLA" . This would be really cool do control my printer handsfree. I can already turn it on and off with voice commands using Sonoff.

SoundGuy avatar Sep 11 '18 05:09 SoundGuy

Add me to the list as someone who'd really love an 'in' topic for commands!

rpitera avatar Oct 03 '18 15:10 rpitera

I've actually developed a plugin that will proxy api commands to the OctoPrint server. It's a little tricky to set-up but you can potentially do what you're trying to accomplish using it. You would use the send-an-arbitrary-command-to-the-printer call in the plugin settings. You can find the plugin over here.

https://github.com/jneilliii/OctoPrint-MQTTSubscribe

jneilliii avatar Oct 03 '18 15:10 jneilliii

how come MQTTSubscribe didn't appread in the plug-in manager, and i had to install it manually through the URL you provided?

SoundGuy avatar Oct 10 '18 22:10 SoundGuy

Because I haven't released it to the plugin repo as I haven't thoroughly tested it.

jneilliii avatar Oct 10 '18 22:10 jneilliii

I managed to get it working, sort of. Posted in the other project. I'll make a video of me turning on the printer with Siri soon.

SoundGuy avatar Oct 15 '18 01:10 SoundGuy

I managed to get it working, sort of. Posted in the other project.

Which "other project"? I'm totally curious how you did it.

hakan42 avatar Oct 15 '18 14:10 hakan42

https://www.youtube.com/watch?v=Lm6Eh-JXWs0

see discussion here: https://github.com/jneilliii/OctoPrint-MQTTSubscribe/issues/1

SoundGuy avatar Oct 15 '18 16:10 SoundGuy