Klangen82 / Creality-Control

Seamlessly integrate your Creality 3D printer with Home Assistant for streamlined control and monitoring.
Apache License 2.0
7 stars 1 forks source link

Information: Support for other models is possible #1

Open petto opened 2 months ago

petto commented 2 months ago

Hey Martin,

thanks for your awesome component. Just today I saw your project and took some time to get it working for my Creality K1C by changing around some sensor names with values that I could capture from my device. The configuration is quite different from your device. The device by default does not use a password for the websocket and the default port is now 9999. I was able to get a load of information over to Home Assistant. I am not a good coder, at least not in python and I don't quite understand the Home Assistant syntax, so I can't really contribute working code as I just copy pasted your sensor names and changed them to what I saw in the websocket output from my device. The device also has a camera builtin that can be accessed via http://IPADDRESS:8080/?action=stream

If you would like to make this component compatible with the K1C (and therefore maybe also the K1 and K1 Max) I have included the whole set of data that is transmitted from the printer so you can use them. I have not tested sending commands yet, as I don't want to risk my ongoing print to fail :) Again: NOT ASKING you to add this for me; just providing information for the case that you want to push this component forward with other models. I am happy to provide other data if you give me a hint on how to capture / provide.

Best wishes from germany

The first long batch is what you get for the initial response to opening the connection. The next rows are every update, I assume the printer just sends every changed bit since the last transmission. I have redacted some parts with the word REDACTED.

{ "TotalLayer": 72, 
"accelToDecelLimits": 2500, 
"accelerationLimits": 5000, 
"aiDetection": 0, 
"aiFirstFloor": 0, 
"aiPausePrint": 0, 
"aiSw": 0, 
"autoLevelResult": "", 
"autohome": "X:1 Y:1 Z:1", 
"auxiliaryFanPct": 0, 
"bedTemp0": "69.250000", 
"bedTemp1": "0.000000", 
"bedTemp2": "0.000000", 
"bedTempAutoPid": 0, 
"boxTemp": 35, 
"caseFanPct": 100, 
"connect": 1, 
"cornerVelocityLimits": 5, 
"curFeedratePct": 100, 
"curFlowratePct": 100, 
"curPosition": "X:78.26 Y:152.20 Z:1.15", 
"dProgress": 0, 
"deviceState": 1, 
"enableSelfTest": 0, 
"err": { "errcode": 0, 
"key": 0 }, 
"fan": 1, 
"fanAuxiliary": 0, 
"fanCase": 1, 
"hostname": "K1C-REDACTED", 
"layer": 6, 
"lightSw": 1, 
"materialDetect": 0, 
"materialStatus": 0, 
"maxBedTemp": 115, 
"maxNozzleTemp": 320, 
"model": "K1C", 
"modelFanPct": 100, 
"modelVersion": "printer hw ver:;printer sw ver:;DWIN hw ver:REDACTED;DWIN sw ver:1.3.3.8;", 
"nozzleMoveSnapshot": 0, 
"nozzleTemp": "229.410000", 
"nozzleTempAutoPid": 0, 
"powerLoss": 0, 
"pressureAdvance": "0.055000", 
"printFileName": "REDACTED.gcode", 
"printId": "", 
"printJobTime": 1811, 
"printLeftTime": 8430, 
"printProgress": 4, 
"printStartTime": 1712777364, 
"realTimeFlow": "8.730000", 
"realTimeSpeed": "112.780000", 
"repoPlrStatus": 0, 
"smoothTime": "0.040000", 
"state": 1, 
"targetBedTemp0": 70, 
"targetBedTemp1": 0, 
"targetBedTemp2": 0, 
"targetNozzleTemp": 230, 
"tfCard": 1, 
"upgradeStatus": 0, 
"usedMaterialLength": 5397, 
"velocityLimits": 600, 
"video": 1, 
"video1": 0, 
"videoElapse": 1, 
"videoElapseFrame": 15, 
"videoElapseInterval": 1, 
"withSelfTest": 100 }

{ "nozzleTemp": "229.600000", "printJobTime": 1812, "realTimeFlow": "6.380000", "curPosition": "X:86.59 Y:144.47 Z:1.18" }
{ "nozzleTemp": "229.830000", "bedTemp0": "69.240000", "usedMaterialLength": 5398, "curPosition": "X:104.71 Y:126.71 Z:1.26" }
{ "nozzleTemp": "230.090000", "bedTemp0": "69.230000", "printLeftTime": 8429, "usedMaterialLength": 5400, "curPosition": "X:86.03 Y:145.62 Z:1.18" }
{ "nozzleTemp": "230.340000", "bedTemp0": "69.240000", "usedMaterialLength": 5401, "curPosition": "X:81.20 Y:151.04 Z:1.16" }
{ "nozzleTemp": "230.560000", "bedTemp0": "69.250000", "printJobTime": 1813, "usedMaterialLength": 5402, "curPosition": "X:102.22 Y:130.02 Z:1.25" }
{ "curPosition": "X:90.47 Y:142.37 Z:1.19" }
{ "nozzleTemp": "230.720000", "bedTemp0": "69.270000", "printLeftTime": 8428, "usedMaterialLength": 5403, "curPosition": "X:79.12 Y:154.30 Z:1.14" }
{ "nozzleTemp": "230.830000", "usedMaterialLength": 5404, "curPosition": "X:99.10 Y:134.33 Z:1.23" }
{ "nozzleTemp": "230.870000", "bedTemp0": "69.280000", "printJobTime": 1814, "realTimeFlow": "8.570000", "curPosition": "X:93.56 Y:140.47 Z:1.20" }
{ "nozzleTemp": "230.860000", "bedTemp0": "69.300000", "usedMaterialLength": 5405, "curPosition": "X:78.50 Y:156.12 Z:1.14" }
{ "nozzleTemp": "230.790000", "bedTemp0": "69.320000", "printLeftTime": 8427, "usedMaterialLength": 5406, "curPosition": "X:98.46 Y:136.15 Z:1.22" }
{ "bedTemp0": "69.340000", "usedMaterialLength": 5407, "curPosition": "X:94.19 Y:141.02 Z:1.20" }
{ "nozzleTemp": "230.640000", "bedTemp0": "69.360000", "printJobTime": 1815, "curPosition": "X:80.20 Y:155.61 Z:1.14" }
{ "nozzleTemp": "230.450000", "usedMaterialLength": 5408, "curPosition": "X:100.15 Y:135.65 Z:1.22" }
{ "nozzleTemp": "230.200000", "bedTemp0": "69.390000", "printLeftTime": 8426, "usedMaterialLength": 5409, "curPosition": "X:92.50 Y:143.90 Z:1.19" }
{ "nozzleTemp": "229.950000", "bedTemp0": "69.420000", "usedMaterialLength": 5410, "curPosition": "X:84.23 Y:152.76 Z:1.15" }

I have chosen to display this values, as they are enough information to me :) image

Klangen82 commented 2 months ago

Hey @petto,

This idea seems like an intriguing item to add to the backlog. Currently, I am working on a service to send commands that replicate the functions of our physical buttons, which should streamline the process of building automations.

However, to achieve this, I need to restructure our codebase. The aim is to segregate devices, thereby enabling the simultaneous operation of multiple printers. This also provides the added benefit of being able to pause/stopped a specific printer as needed.

As soon as time and energy permit, I plan to dive deeper into this. However, if you is keen to take this on, please feel free to do so. Ideally, users would be able to select the model they're adding when integrating the system into HA. However, there may be a way to automate this process, eliminating the need for manual selection.

danielskowronski commented 1 month ago

I also got K1C, did some digging and would be happy to help :)

Their filament printers (or at least K1 family) actually use forked Klipper (https://github.com/CrealityOfficial/K1_Series_Klipper) with custom Web UI that doubles as API server for Creality Print app. That server is a single binary in ROM (/usr/bin/web-server) and appears not to be any open-source clone.

While I was able to install more common API server - Moonraker and integrate it with Home Assistant properly getting various sensors (except camera - but it's simple MJPEG stream), many features (like current GCODE information) are not available there if you keep using stock firmware functions (e.g. their slicer to upload models or start print from touchscreen).

That said, even if it may be harder to cover both types of printers in this integration, it'd still be worth getting support for stock API. And I think that whatever API they have on Halot should be close enough not to split projects.

Yannik25 commented 1 month ago

Hi @petto, how have you been able to get this working with your K1C? Would you be able to share your files? Thanks

petto commented 1 month ago

Hey @Yannik25 download the latest release from the repo and replace two files with the files from this .zip Please note: This is a very very very dirty hack, not meant for any release as I have removed / changed some files without really thinking about compatibility / code quality. (It is enough for me to display a status in Home Assistant however)

Copy the folder to your Home Assistant installation and restart the system. Then use the wizard to add the printer, fill in user and password with default values if you are asked to provide them. Please remember to add the printer with port 9999 in the wizard.

custom_files_for_K1C.zip