Bambu Lab X1 X1C MQTT

having some trouble to get it work - is there a youtube video or something - or someone who can help me?

You need to setup the credentials for homeassistant connection and the FTP connection.

Homeassistant you need to create a server and assign it to the nodes, fill in the required credentials/server/access token. Go to any sensor, then the pencil icon for the entity config, then there will be a field there to setup a server. Need to set all your entity configs to this server once made.

For the FTP if you want to use it, you need the “LAN only” password from the printer as the password.

ok now all are running

but in homeassistant there are only a few entities and the others are not availible and if i press the chamber light it doesnt tunr on/off :

Is the MQTT connection set up properly and did you replace the instances of BAMBU_SERIAL in the flow json? It will be in the “topic” for both the MQTT In and MQTT Out nodes and be the serial number of your printer.

image

Only reason I can think of them being unknown is you aren’t getting the proper mqtt messages/topic.

thanks a lot works! is it possible to get your homeassistant site? looks pretty awesome!!!

Here’s a gist for part of my HA dashboard after I just worked on changing it up a bit. This isn’t everything, but it should be a good start. It should give you exactly what’s in this image after configuring everything as per my top comment on the gist.

Also included in the comments are the images I use for the AMS and the X1C (chamber light on and off)

2 Likes

my last problem is the thumbnail of the print.

Setup:
HASSOS with nodered addon

Yeah for there my solution is pretty use-case specific. For me, I’m running home-assistant-core as a docker container in unraid, same with node-red. I have both of these exposed w/ my domain, auth’d and all, so I can just make an http endpoint in nodered to expose it, and call it as an image link in home-assistant.

For your case, I’m not sure if it will work to refer to the nodered addon as a url, since it may be frontend only when referring to a URL. Instead, you can have the Write Image node write to a location that HomeAssistant has access to (www for example) and do a path url in the dashboard to that path. So modify the /local/x1x_meta/preview.png to say, in the eyes of homeassistant, /www/something/preview.png, then use /local/something/preview.png in the dashboard.

The downside of that approach is HomeAssistant will cache the image for a longer time. Main reason I went with my http approach was so I could set the cache time to a small number or even no-cache, and if it was using old version, I could just refresh and it’ll load the new one.

If you’re able to get it working using the HTTP endpoint then that would be a bit better cache-wise.

I’ve got a X1C on the way.

Has anyone thought about starting a wiki, gist, git repo or similar to get all the endpoints into a single place?

Node Red is nice, but would be better to turn this into a custom component. I’ve got a bit of experience doing this so might be able to take a look when mine arrives too

I’ve considered porting everything in my NR flow into a custom component (would make it much nicer for dynamically adding AMS units, speed control not as separate buttons, better sensor setup, etc), but don’t have the time right now to really start it.

I tried just seeing if I could start it a couple weeks ago but every custom component template I tried kept breaking for me so I just took a step back :laughing:

I may try again though. The code isn’t a problem, just as usual it’s project setup :slight_smile:

As with most of these things, they’re open source so anyone can contribute.

Normally you’d build a python library to handle the connection and API calls, and then a component to stream the HA stuff.

What I’m a little confused about though since I don’t have my Bambu yet, is the Bambu an MQTT server itself, or does it publish events to an MQTT server you specify yourself?

That’d change whether or not we have to listen, or have to connect to another MQTT instance

It has its own MQTT server (and ftp server). I had a template already setup with a package and python imports for working with mqtt and such.

Had the python code independently working as a proof of concept but like I said, when I tried making a HA component out of it using some HACS template, all the ones I tried broke either during dependency installation or building. Even just the HA package itself. Tried on windows and Linux, venvs setup etc.

Gonna give it another shot in a week or two.

Have you got the code in a repo?

I can probably have a look and see if I can get it running

Was local only proof of concept, but not hard to remake. I think next time around I will try starting from a template for a component and trying to get that to work. May get around to it sometime next weekend.

My addition to the party - replacing the NodeRed HA integrations with MQTT AutoDiscovery, by more or less repeating translated copies of what is being received and interpreted in the NR flows elsewhere in this thread. It’s a long way from maturity since I don’t have a whole lot of time to dedicate, but it should provide a more scalable road to integrating these machines.

This looks great, much better than using the HA integration. I have been working on changes to it to replicate previous flow into it, and I’m almost done but I just found something useful when randomly checking messages.

When checking some of the ‘mc_print’ messages, I opened one at random and discovered that the raw humidity values of the AMS still exist!

Specifically, this is the payload I read from:

{"mc_print":{"command":"push_info","param":"[AMS][TASK]ams0 temp:19.9;humidity:37%;humidity_idx:2","sequence_id":"265"}}

Going to modify the new flow to include reading this singular message, and while I’m at it, snoop some other mc_print messages to see what I can dig up. For some reason, the AMS reports voltages as well… So lots to work with!

Edit: And from this yes I can confirm, higher humidity idx means lower humidity. 2 was 37/38%, and now level 3 is 33%.

2 Likes

Forked the flow and made edits here, comments say what needs to change for config (aside from obvious user/password setup for servers):

Benefits of this approach over my previous flow with HA integration:

  • This is way more scalable
  • We can link devices in HA through this
  • We aren’t limited to just sensors and buttons, we can have selects and light entities now
  • Much more configurable and less dependencies!
  • Easier to hook up / refer to states and attributes in HA yaml

Note: This flow does not contain the flow/code for the FTP fetch for print preview images. This I felt was too use-case specific for me and for now I still rely on the HA integration nodes for state change detection and such. If you want that, you can import the previous node-flow and copy it to this new one or whatever setup you have :slight_smile:

Something else I noticed - The humidity level and raw humidity % are very loosely tied, whatever algorithm they have must be heavily biased to temperature or something else, as now it kept swapping between level 2 and 3, while the humidity was 20-24%… earlier it did this at like 33-38%.

Fantastic work! Much improved and actually usable! :smiley:

Yeah, the more I look at those fields, the less related the appear to be. It’s almost like humidity level is a rate, of some other derived field that’s not directly related to the actual %RH.

It’s exactly that, Bambu stated as much to me. Due to the placement of the humidity sensor (which they said is sub-optimal) they effectively use a bunch of things mushed into an “algorithm” to account for its poor placement and come up with the index. Is why they removed it from the other data feed in the first place. They wouldn’t tell me what things they used though; I did ask :slight_smile:

A number of the voltages reported are the readings from the hall effect sensors which are used to detect filament movement/existence. If it’s these, you are talking about anyway;

[AMS][Period]:len=8.153m,buf_pos=0.49,e_hall=354mV,cut_hall=1599mV

I wouldn’t rely too much on the Temp sensor either, or maybe apply some logic to its data handling.

          "humidity": "5",
          "id": "0",
          "temp": "-46.7",
          "tray": [

It’s summer here. It’s not -46.7°C :upside_down_face:

I may like the cold but even that cold would be too much for me :laughing:

Might be just a defective sensor or mis-calibrated on boot. I’ve had many DHT22, DHT11 and other misc temperature sensors do the same thing randomly on one bootup, fixed later on.

It’s definitely more biased to temperature than actual humidity, as later on I did an ABS print, chamber temperature got to 40c and the AMS temp jumped up from 23 to high 30’s, humidity level changed and so did humidity a bit.

As for the voltages, figured those were hall-e sensor readings, just didn’t think the AMS used those for some reason. I wonder if it stores the values somewhere or if it does some other weird “smart” readings, as my AMS is able to tell if I move one spool to a different tray. I don’t need to reconfigure it at all, it just automatically sets the old other tray values to the new tray. Wonder how it does that, unless it’s just something dumb like a timeout for “spool switching”.