Page 1 of 2

3d printer octoprint domoticz monitoring

Posted: Wednesday 02 November 2016 16:31
by borgkitty
I was wondering if anybody has played around with the idea of monitoring their 3d printer if you have one?
If you have an rpi controlling it with octoprint you should be able to query it via the api for at the bare minimum temperatures of bed and hot end
have a look. it runs from what I gather very similar with json which I am guessing can be asked for the extracted and pushed to temp sensors

http://docs.octoprint.org/en/master/api ... tool-state

I realise that octoprint has a nice interface which I use and quite like and putting it on domoticz wouldn't be a complete replacement nor I'm I trying to replace it. I just figure since it has an api the core temps and some other variables could be ported over

I am not that good at coding so I think this will take me a long ass time to code. just wanted some feedback from more experienced coders as if you think it would be possible
nor can I find information on this as it seems no one has done this before

Re: 3d printer octoprint domoticz monitoring

Posted: Thursday 03 November 2016 18:39
by borgkitty
right well, I shall assume that no one has as by the lack of replies and I can't find anything on google

I shall dive into the head first and go balls deep :P
even though I can't code LUA then I shall create a walk through if I am sucessful

Re: 3d printer octoprint domoticz monitoring

Posted: Sunday 14 May 2017 17:36
by Fnys
Did you do anything with this? I just installed octoprint to use with my new 3d printer.. I was thinking about using a fibaro wall plug to kill the power to the printer when it's done and stuff like that..

Re: 3d printer octoprint domoticz monitoring

Posted: Friday 19 May 2017 22:50
by Varazir
borgkitty wrote:right well, I shall assume that no one has as by the lack of replies and I can't find anything on google

I shall dive into the head first and go balls deep :P
even though I can't code LUA then I shall create a walk through if I am sucessful
I stand in line :)

Re: 3d printer octoprint domoticz monitoring

Posted: Wednesday 21 June 2017 18:11
by borgkitty
lol sorry guys, not on this forum much and i do so many different projects i frequently forget about other projects i had. I would like this but havent even started it. probably wont happen till i prioritize my projects plus you need octoprint and i had it running on my 3d printer which i stopped using octoprint bc it broke and im lazy to fix it

Re: 3d printer octoprint domoticz monitoring

Posted: Saturday 23 December 2017 16:31
by bjacobse
Hi, I was searching for exact same solution and I have something working, I only need to understand if print is in progress or done, I don't mind temperature so this you need to fix yourself...

It requires octoprint + mqtt plugin. The MQTT plugin to be setup to your broker (my broker is mosquitto running on Domoticz RPI server)

Then on your domoticz server it's required:
mosquitto + node-red, setup here: http://www.domoticz.com/wiki/MQTT
also to setup a dummy text device, my idx: 224, so you need to modify idx accordingly

when node-red is working, check your server:1880
then CTRL-i and insert the below text, as this will setup your flow, my idx: 224
[EDIT 2018-01-05] as I had a minor bug and comma was shown in percentages below 10 was showing up as 5,% (if the number was 5%)

[{"id":"5d05beab.45536","type":"function","z":"5828a86.49629d8","name":"Send progress to dummy idx","func":"//Get progess 0-99\nvar progress = parseInt(msg.payload.substring(13,15));\n\n//Clear msg buffer\nmsg.payload = {};\n\n//Set dummy idx number here:\nmsg.payload.idx = 224;\nif (progress === 0){\n msg.payload.svalue = (\"On\");\n} else \nif ((progress >= 0) && (progress < 99)){\n msg.payload.svalue = (\"Print progress: \"+ progress +\"%\");\n} else \nif (progress == 99){\n msg.payload.svalue = (\"Print done\");\n} else {\n msg.payload.svalue = (\"Printer off\");\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":486.5,"y":184,"wires":[["e5923d30.e4c248","a52de4f4.5fcb1"]]}]
device.png
device.png (10.75 KiB) Viewed 3121 times
print_done.png
print_done.png (16.15 KiB) Viewed 3113 times
node-red.png
node-red.png (16.11 KiB) Viewed 3121 times

Re: 3d printer octoprint domoticz monitoring

Posted: Sunday 24 December 2017 14:07
by bjacobse
In octoprint you specify your mqtt broker ip address, I have put here xxx.xxx.xxx.xxx, no need to change anything else
octoprint_mqtt.png
octoprint_mqtt.png (98.38 KiB) Viewed 3090 times

Re: 3d printer octoprint domoticz monitoring

Posted: Thursday 04 January 2018 23:00
by dp106
Hey, thanks for doing all the hard work for me! Took me a while but think I finally have this working. I wasn't really happy with the function parsing the payload as text when it was effectively a JSON string so I think doing this is better:

Code: Select all

var varPayload = JSON.parse(msg.payload);
var vartemp = varPayload.actual;
I think this allows for the payload changing in the future.

Full code from the function

Code: Select all

var varPayload = JSON.parse(msg.payload);
var vartemp = varPayload.actual;

//Clear msg buffer
msg.payload = {};

//Set dummy idx number here:
msg.payload.idx = 12;
msg.payload.nvalue=0;
msg.payload.svalue = (""+vartemp+"");
return msg;
I've also created a couple of flows for the bed and extruder temperature: I'll see if I can export them and add them to the next post

Re: 3d printer octoprint domoticz monitoring

Posted: Thursday 04 January 2018 23:03
by dp106
Hopefully this is an export of the temperature flows:

[{"id":"3aea8e93.309a72","type":"mqtt in","z":"1763ab9b.39ab34","name":"Extruder Temp","topic":"octoprint/temperature/tool0","qos":"2","broker":"9ccc9e2b.1b109","x":160,"y":207,"wires":[["3ec16cec.0e06c4"]]},{"id":"83806805.370eb8","type":"mqtt out","z":"1763ab9b.39ab34","name":"","topic":"domoticz/in","qos":"","retain":"","broker":"9ccc9e2b.1b109","x":579,"y":206,"wires":[]},{"id":"3ec16cec.0e06c4","type":"function","z":"1763ab9b.39ab34","name":"Format Message","func":"var varPayload = JSON.parse(msg.payload);\nvar vartemp = varPayload.actual;\n\n//Clear msg buffer\nmsg.payload = {};\n\n//Set dummy idx number here:\n//var newMsg = {payload: {}};\n//var newMsg = {};\nmsg.payload.idx = 12;\nmsg.payload.nvalue=0;\nmsg.payload.svalue = (\"\"+vartemp+\"\");\nreturn msg;","outputs":1,"noerr":0,"x":369,"y":206,"wires":[["83806805.370eb8","7c4f10ea.34908"]]},{"id":"7c4f10ea.34908","type":"debug","z":"1763ab9b.39ab34","name":"","active":false,"console":"false","complete":"true","x":545,"y":304,"wires":[]},{"id":"db32e719.bf2618","type":"mqtt out","z":"1763ab9b.39ab34","name":"","topic":"domoticz/in","qos":"","retain":"","broker":"9ccc9e2b.1b109","x":580,"y":368,"wires":[]},{"id":"592e0035.0d7a7","type":"mqtt in","z":"1763ab9b.39ab34","name":"Bed Temp","topic":"octoprint/temperature/bed","qos":"2","broker":"9ccc9e2b.1b109","x":132,"y":367,"wires":[["587c7b23.5c0954"]]},{"id":"587c7b23.5c0954","type":"function","z":"1763ab9b.39ab34","name":"Format Message","func":"var varPayload = JSON.parse(msg.payload);\nvar vartemp = varPayload.actual;\n\n//Clear msg buffer\nmsg.payload = {};\n\n//Set dummy idx number here:\n//var newMsg = {payload: {}};\n//var newMsg = {};\nmsg.payload.idx = 13;\nmsg.payload.nvalue=0;\nmsg.payload.svalue = (\"\"+vartemp+\"\");\nreturn msg;","outputs":1,"noerr":0,"x":328,"y":368,"wires":[["db32e719.bf2618","c28cf0cc.7cc4d"]]},{"id":"c28cf0cc.7cc4d","type":"debug","z":"1763ab9b.39ab34","name":"","active":false,"console":"false","complete":"true","x":557,"y":459,"wires":[]},{"id":"9ccc9e2b.1b109","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]

Re: 3d printer octoprint domoticz monitoring

Posted: Friday 05 January 2018 21:33
by bjacobse
@ dp106
you are welcome, glad you could use it for your own purpose and improve it :-)
I wasn't aware that the message was a JSON string, your improvement looks quite good

Re: 3d printer octoprint domoticz monitoring

Posted: Sunday 07 January 2018 21:51
by bjacobse
And then I have created this LUA script, that will switch on a lamp when 99% done.
First create a user variable: 3D printer boolean and make this an integer
3d_printer_boolean_variable.png
3d_printer_boolean_variable.png (42.9 KiB) Viewed 2931 times
then copy this script as lua, like this:
3D_print_lua.png
3D_print_lua.png (19 KiB) Viewed 2931 times

Code: Select all

-- created by ohotbar@gmail.com 2018
commandArray = {}

-- loop through all the devices
for deviceName,deviceValue in pairs(otherdevices) do
    if ((deviceName=='3D Printer') and (uservariables["3D printer boolean"] == 0)) then
        if otherdevices_svalues['3D Printer'] == "99%" then
            --uservariables["3D printer boolean"] = 1;
            commandArray['Variable:3D printer boolean']='1'
            print ("3D Printer event fired");
            commandArray['Kitchen HK Lamp'] = "On"
        end
    end
end
if otherdevices_svalues['3D Printer'] ~= "99%" then
            --uservariables["3D printer boolean"] = 0;
            commandArray['Variable:3D printer boolean']='0'
end

return commandArray

Re: 3d printer octoprint domoticz monitoring

Posted: Tuesday 30 January 2018 11:35
by SHadley1138
looks like you have octoprint working with mqtt and domoticz. im really struggling. in the mqtt settings, what are the 'Topics'? do i leave them blank, or use the defaults?

then on domoticz, ive go mqtt client installed.

im looking for a text sensor, that shows status messages from octoprint, but i can't see how i create that relationship

any help would be appreciated

Re: 3d printer octoprint domoticz monitoring

Posted: Friday 23 February 2018 1:17
by matzeb74
I Struggle here:
bjacobse wrote:
Saturday 23 December 2017 16:31

when node-red is working, check your server:1880
then CTRL-i and insert the below text, as this will setup your flow, my idx:
What exactly should i do?

Re: 3d printer octoprint domoticz monitoring

Posted: Thursday 08 March 2018 15:09
by bjacobse
matzeb74 wrote:
Friday 23 February 2018 1:17
I Struggle here:
bjacobse wrote:
Saturday 23 December 2017 16:31

when node-red is working, check your server:1880
then CTRL-i and insert the below text, as this will setup your flow, my idx:
What exactly should i do?
Sorry for my late reply - I am unsure where you need help?

Can you confirm that node-red is working? it shall be online and you can connect to it on port 1880?
https://www.domoticz.com/wiki/MQTT

did you follow this?
http://www.domoticz.com/forum/viewtopic ... nt#p162935

Re: 3d printer octoprint domoticz monitoring

Posted: Tuesday 10 July 2018 20:54
by AimoPaukku

Re: 3d printer octoprint domoticz monitoring

Posted: Sunday 04 November 2018 23:05
by DAVIZINHO
hello.
and how it works. I see the plugin in octoprint but i dont know how to configure
:-(
Its necesary to create virtual switches? how many?

Re: 3d printer octoprint domoticz monitoring

Posted: Sunday 11 November 2018 22:37
by bjacobse
DAVIZINHO wrote:
Sunday 04 November 2018 23:05
hello.
and how it works. I see the plugin in octoprint but i dont know how to configure
:-(
Its necesary to create virtual switches? how many?
I don't use the octoprint plugin, it's not needed if you carefully follow the guide in the below link
you need to create 1 virtual switch, note it's s text switch,
viewtopic.php?f=21&t=14021&p=172263&hil ... nt#p162935

Re: 3d printer octoprint domoticz monitoring

Posted: Monday 12 November 2018 13:24
by DAVIZINHO
bjacobse wrote:
Sunday 11 November 2018 22:37
DAVIZINHO wrote:
Sunday 04 November 2018 23:05
hello.
and how it works. I see the plugin in octoprint but i dont know how to configure
:-(
Its necesary to create virtual switches? how many?
I don't use the octoprint plugin, it's not needed if you carefully follow the guide in the below link
you need to create 1 virtual switch, note it's s text switch,
viewtopic.php?f=21&t=14021&p=172263&hil ... nt#p162935
i dont use MQQT in domoticz, maybe this will be the moment to configure it.
I think with the octoprint plugin it will work :-(

Re: 3d printer octoprint domoticz monitoring

Posted: Monday 12 November 2018 13:33
by emme
I either did not use MQTT.....
now I cannot live without!

Re: 3d printer octoprint domoticz monitoring

Posted: Monday 12 November 2018 22:40
by bjacobse
I can only recommend MQTT, I also use it for my ESP8266 Heatpump IR controller, that also reports temperature
and if you gets MQTT to be working, then it's fairly easy to use my guide to get Octoprint print percentage to Domoticz