I’m sure someone that knows python and HA integrations could make something work with the websocket exposed on the K1 … but not me.
What’s working:
Several temperature sensors (Nozzle, Case, Bed)
Other sensors (layer counts, material length, print progress)
Partial fan control (ON/OFF)
Light control
Changelog:
Jan7. 2025: Added support for Job Time and Time Left. Special thanks to @thalesgmartins for the inspiration
If you want to chat about it or need help understanding the mess I made, hit me up!
If there are node-red experts that care to check what I came up and give tips to improve the workflow, let me know. It’s my first time using it in 5 years.
Still Image: http://your_printer_ip/downloads/original/current_print_image.png (This will display a still image of the last print you sent to your printer)
Sorry been down sick past couple of days and missed your message.
I don’t know how far you are coming from so I’m gonna start with a simple answer and we’ll take it from there.
Using Node-RED’s “sensor” block which comes pre-installed when you add the Node-RED, it basically create a brand new entity on your HA (you need the Node-RED companion too
That entity can be used like any other on the dashboard, your creativity takes care of the rest. I didn’t share that part because all dashboards are different and people like to see them their own way
Thanks for sharing! Im real fresh with Home assistant but with a bit of chat GPT help iv managed to get Node red and the Companion app installed, iv input your script and added my printers IP.
I can see the sensors in the node red Integration but they don’t update or allow me to control.
Any pointers on what I could be missing to direct me to getting this running.
Thanks in advance
Some values are only updated while printing, so lets start with the simple question, are you printing when checking the sensors in HA?
If you are let’s start with the Node-RED side:
Add a debug node behind the Server Listener and make sure you have some output from the printer. Everything relies on that
If you haven’t used Node-RED before, you can access debug messages on the right of your screen by clicking on
Do you get anything on that screen?
I also noticed that the sensors get stuck on my side after a long time of the printer being off (I completely shut the power to the printer when not in use using a connected wll plug). I believe this is caused by Node-RED permanently shutting down the connection to the WS Server after too many attemps at connecting to a server that is off.
I solved that by creating an automation that I can share if you are on the same situation.
Ok so added the debugging node, and started a print. (I hadn’t had a print going before) and nothings coming up, so I’m assuming my printers not connected to begin with.
If you select the websocket line and click on the message tab, you should see plenty of messages displayed there. These are the messages we are parsing through NodeRed to generate the sensors
So Using Google Chrome I couldn’t see anything going on in the network panel. However I’m on a Mac and was able to get to the same place on Safari and can see the mentioned connectors.
This means that the WS server is available on your network but your NodeRED is unable to connect to it. This is probably a network related issue, rather than a NodeRED one, but I think I found out why
The ws socket is available on port 9999, hence your WS node needs to look like this:
Your solution is exactly what I needed. Now i’m using the websocket, but MQTT instead of NodeRed Companion (It may be useful someday, because I have a plenty of other devices that already use MQTT).
I think i have a solution (or something like that) for printJobTime and printLeftTime, so here is the .yaml of my sensor:
The time is given in seconds by the printer API, so we can convert that into hh:mm:ss in that way (i confess that chat gpt helped a lot in that part):
// Pick the seconds given by the API at the respective place.
let given_seconds = msg.payload.printLeftTime
// Calculate hh:mm:ss based on the previously saved seconds
let hours = Math.floor(given_seconds / 3600);
let minutes = Math.floor((given_seconds - (hours * 3600)) / 60);
let seconds = given_seconds - (hours * 3600) - (minutes * 60);
// Build the string that will be sent to the sensor using the calculated data.
let timeString = hours.toString().padStart(2, '0') + ':' +
minutes.toString().padStart(2, '0') + ':' +
seconds.toString().padStart(2, '0');
// Save as the main payload and return
msg.payload = timeString;
return msg;
It is working fine for me, and i expect that it helps you to do the same with Node Companion. Actually i am trying to make a better filter of the received messages, and more of the data received.
I’m from Brazil and new on home assistant community, so please forgive me if I make any silly mistakes. Feel free to ask if anything is unclear.
I do also have MQTT at home, so I might look into that. End of year festivities are almost over so I will surely look into that when I have some time to tinker
Nonsense sir ! In my honest opinion there is no small improvement or small ideas when starting in home automation. Whatever works for you will surely apply to soneone else needs.
I’m sure someone more skilled than us will have a look at all this and have a good laugh … but we made it work and shared it for the people that had no idea how to do it otherwise
Merry Christmas and Happy new year my Brazilian friend
I also keep turning off my printer every night. Please, if possible, share your solution how you reestablish WB connection automatically to make sensors to work. Thanks.
Basically, it’s an automation that restarts nodered’s addon when it detects the printer waking up. Kind of brute force solution, but I haven’t had time to look at a better fix
My printer being connected to a smart plug, I just need to check the status of said plug. You can use any variation that suits your needs to make it work the same