Adding Creality K1 Max to HA using Nodered (No root required)

Hello everyone!

I’m a happy camper with my new K1 Max. After years using a Ender 3 I decided to upgrade to continue my 3D life :innocent:

I was looking for a way to bring data from the K1 Max into Home Assistant without having to resort to rooting, monraker of anything of the sort.

Luckly, the K1 Max exposes a websocket whenever it’s on, therefor I used nodered to bring the data to HA.

  • Is it the best way to do it ? => I’m sure it’s not
  • Was it worth the effort compared to rooting the printer? => Couldn’t say, haven’t even attempted to root it
  • Does it work ? => Totally

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.

You can get the workflow from here

Cheers
Chris

3 Likes

Additional tips:

You can add the K1 Camera to HA using the MJPEG IP Camera - Home Assistant integration

  • MJPEG URL : http://your_printer_ip:8080/?action=stream
  • 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)

Nice dashboard! I wanna know how to bring these sensor infos to my dashboard…

Hey @git-clover !

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

image

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 :slight_smile:

Hello @Spellbinder_4 ,

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

image

  • If you haven’t used Node-RED before, you can access debug messages on the right of your screen by clicking on

image

Do you get anything on that screen?

:bulb:
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.

Thanks for the help @bouyssic,

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.

Dose the below look correct?
Screenshot 2024-12-02 at 8.10.44 pm

Interesting !

What happens if you browse http://192.168.1.110 ? Do you reach an UI with your printer settings and ongoing print ?

When I do it on my side I have something like this (even when no printing):

If you have the same thing, you should have a WS socket working.

How can you check that part ?

When on that page:

  • Open a Developer console. (If you are on Chrome, the shortcut would be CTRL+SHIFT+I)
  • Go to the network tab
  • Refresh the page

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

1 Like

Yeh when heading to http://192.168.1.110 I get to the Creality Printer UI page.

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.

Still not having any luck with the node red debugging section either. :frowning:

Thanks

@Spellbinder_4 ,

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 :slight_smile:

The ws socket is available on port 9999, hence your WS node needs to look like this:
image

Sorry I missed that on your first screenshot … :face_exhaling:

Cheers

1 Like

Yep thats done it!! Amazing thank you. Appreciate you spending the time to troubleshoot!
magic-freak

1 Like

Anytime ! That’s what I love from this community. Sharing experience

1 Like

Thank you for sharing this!

It’s much nicer than dealing with a custom integration that may or may not continue to be supported.

1 Like

Hola, Me again. just wondering if there was a way to get print time and Time left?
Thanks :slight_smile:

Hola @Spellbinder_4 !

Pretty sure there is but haven’t played with it much since I posted this.

I’ll work on that next year and post an update here if you are patient enough.

I’m back to work on January the 6th, I’ll have some free time :crazy_face:

Happy Christmas period !

1 Like

I had a quick look at my ongoing print and indeed it’s possible
We have:

  • printJobTime - How long it has been printing for
  • printLeftTime - … self explanatory …

I’ll find a way to add them I think

1 Like

Hi @bouyssic !

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:

    - name: "Tempo de Impressão"
      unique_id: "sensor.k1max.print_job_time"
      state_topic: "k1max/printJobTime"
      icon: "mdi:clock-outline"

To filter the data, im parsing the msg.payload received by the websocket as a JSON in a function node:

try {
    msg.payload = JSON.parse(msg.payload);
} catch (e) {
    node.error("Error converting JSON: " + e.message);
    return null;
}

return msg;

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.

Happy New Year!!

2 Likes

Impressive work @thalesgmartins !!

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 :grin:

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 :brazil: Brazilian friend

2 Likes

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.

hello @manmacjonas

Here is my solution for now until I find something better:

- id: '1731873577025'
  alias: Restart Nodered on 3D start
  description: ''
  triggers:
  - type: turned_on
    device_id: 30a8b7d8bfe71e570468a3e5a6959277
    entity_id: 07ccec5a96939fb7eec1889bed9eb1ae
    domain: switch
    trigger: device
  conditions: []
  actions:
  - action: hassio.addon_restart
    metadata: {}
    data:
      addon: a0d7b954_nodered
  mode: single

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