3d printer octoprint domoticz monitoring

Client tools or tools that can connect with Domoticz. Tools for Windows, iOS, Android, Linux etc.

Moderator: leecollings

borgkitty
Posts: 34
Joined: Wednesday 26 October 2016 21:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Contact:

3d printer octoprint domoticz monitoring

Post 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
borgkitty
Posts: 34
Joined: Wednesday 26 October 2016 21:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Contact:

Re: 3d printer octoprint domoticz monitoring

Post 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
Fnys
Posts: 2
Joined: Thursday 14 January 2016 19:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sweden
Contact:

Re: 3d printer octoprint domoticz monitoring

Post 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..
User avatar
Varazir
Posts: 451
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: 3d printer octoprint domoticz monitoring

Post 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 :)
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
borgkitty
Posts: 34
Joined: Wednesday 26 October 2016 21:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Contact:

Re: 3d printer octoprint domoticz monitoring

Post 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
bjacobse
Posts: 85
Joined: Tuesday 06 September 2016 9:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sorø, DK
Contact:

Re: 3d printer octoprint domoticz monitoring

Post 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 10803 times
print_done.png
print_done.png (16.15 KiB) Viewed 10795 times
node-red.png
node-red.png (16.11 KiB) Viewed 10803 times
Last edited by bjacobse on Friday 05 January 2018 20:30, edited 1 time in total.
bjacobse
Posts: 85
Joined: Tuesday 06 September 2016 9:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sorø, DK
Contact:

Re: 3d printer octoprint domoticz monitoring

Post 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 10772 times
dp106
Posts: 2
Joined: Thursday 09 March 2017 12:50
Target OS: -
Domoticz version:
Contact:

Re: 3d printer octoprint domoticz monitoring

Post 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
dp106
Posts: 2
Joined: Thursday 09 March 2017 12:50
Target OS: -
Domoticz version:
Contact:

Re: 3d printer octoprint domoticz monitoring

Post 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":""}]
bjacobse
Posts: 85
Joined: Tuesday 06 September 2016 9:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sorø, DK
Contact:

Re: 3d printer octoprint domoticz monitoring

Post 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
bjacobse
Posts: 85
Joined: Tuesday 06 September 2016 9:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sorø, DK
Contact:

Re: 3d printer octoprint domoticz monitoring

Post 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 10613 times
then copy this script as lua, like this:
3D_print_lua.png
3D_print_lua.png (19 KiB) Viewed 10613 times

Code: Select all

-- created by [email protected] 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
SHadley1138
Posts: 47
Joined: Thursday 10 March 2016 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: 3d printer octoprint domoticz monitoring

Post 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
matzeb74
Posts: 49
Joined: Sunday 07 January 2018 19:23
Target OS: Raspberry Pi / ODroid
Domoticz version: newest
Location: Stuttgart
Contact:

Re: 3d printer octoprint domoticz monitoring

Post by matzeb74 »

I Struggle here:
bjacobse wrote: Saturday 23 December 2017 15: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?
bjacobse
Posts: 85
Joined: Tuesday 06 September 2016 9:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sorø, DK
Contact:

Re: 3d printer octoprint domoticz monitoring

Post by bjacobse »

matzeb74 wrote: Friday 23 February 2018 0:17 I Struggle here:
bjacobse wrote: Saturday 23 December 2017 15: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
AimoPaukku
Posts: 43
Joined: Saturday 28 January 2017 9:35
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Contact:

Re: 3d printer octoprint domoticz monitoring

Post by AimoPaukku »

DAVIZINHO
Posts: 234
Joined: Sunday 27 August 2017 18:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Spain
Contact:

Re: 3d printer octoprint domoticz monitoring

Post 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?
bjacobse
Posts: 85
Joined: Tuesday 06 September 2016 9:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sorø, DK
Contact:

Re: 3d printer octoprint domoticz monitoring

Post by bjacobse »

DAVIZINHO wrote: Sunday 04 November 2018 22: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
DAVIZINHO
Posts: 234
Joined: Sunday 27 August 2017 18:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Spain
Contact:

Re: 3d printer octoprint domoticz monitoring

Post by DAVIZINHO »

bjacobse wrote: Sunday 11 November 2018 21:37
DAVIZINHO wrote: Sunday 04 November 2018 22: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 :-(
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: 3d printer octoprint domoticz monitoring

Post by emme »

I either did not use MQTT.....
now I cannot live without!
The most dangerous phrase in any language is:
"We always done this way"
bjacobse
Posts: 85
Joined: Tuesday 06 September 2016 9:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sorø, DK
Contact:

Re: 3d printer octoprint domoticz monitoring

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest