Bambu Lab X1 X1C MQTT

Requeriments (HACS or manual installation):

I’m assuming this is trying to get requirements for the HA Yaml snippet? I think you may be missing card-mod as a requirement.

@WolfwithSword New to this whole thing, including mqtt and node red and HASS but this looks pretty awesome. I noticed after pulling the yaml from your gist that i dont have the spool icons/colors in the AMS image. How do i get those? Also, any insight on managing multiple AMS units?


The icons are a bit tricky, since I used a custom SVG. You can use any icon available in your homeassistant, or if you download the HACS repo for fapro (font-awesome icons) you can then create a “custom_icons” folder in your homeassistant config (same place as custom_components), then drop the SVGs in there, then on a reboot of HA they should come up. I forget if the fontawesome hacs repo needs any special setup like adding it to the configuration.yaml, so check to see if it needs anything special!

Currently all the icons are set in the snippet to fapro:filament-1 if you want to change to something else or something. There is another approach which I use involving a custom js file to load icons with a custom: tag, but it’s not worth the hassle for most people. Honestly not sure why it started finally working for me after trying for many days :stuck_out_tongue:

If you look in the comments of the yaml gist, there is the SVG I used attached in one of them. Here it is again to make it easy :slight_smile:

As for multiple AMS units, you can probably go into your dashboard, hit edit then go to the section from the yaml, go to its edit page. In there, there should be 3 cards - the first one is the YAML for the AMS unit. You could copy and paste it to a new card, and then rename all the sensors accordingly.

I.E. ams_0_{printer_name} becomes ams_1_{printer_name} for your second AMS unit. Best to do this in like np++ and do a replace all. I don’t have multiple AMS units to try but this should work, or at least get you on the right track!

Hi, Can someone tell me and direct me to the files i need to intergrate the X1c with AMS as it stand.
Very much apprichate all the hard work you are all doing.
Happy to be a beta tester

Sure! The current full way we’ve come up with here goes as follows:

  1. Requirements/Assumptions
    • Home Assistant is setup
    • MQTT broker setup and connected to homeassistant
    • Node Red ready to use
2) NodeRed Setup
  • NodeRed Palette Requirements
    • I think none for just the base flow. Let me know if this isn’t the case.
  • Download the first file from here bambu-mqtt.json Node-RED Flow - BambuLab X1 MQTT Relay for Home Assistant MQTT Auto-Discovery · GitHub
  • Open it up in a text editor such as NP++ and get ready to do some replace-alls
    • The top comment of the gist link has the information you need for replacing. Anytime I update this gist, replacements for that main flow will be edited in that comment, and I will always comment with changes down below linked to a revision number.
  • Once all is replaced, import the JSON into NodeRed (top right hamburger menu → Import)
  • If your MQTT server for HA has any credentials, you will need to edit them.
    • Click on any pinkish/purple MQTT node that is for HomeAssistant (Name probably contains it)
    • In the edit for that node, click the edit icon next to the “server”, then enter credentials in the new window, save and close.

I suggest ignoring the second json file in the gist for now, that is for a more complex setup I have that requires PostgresDB, and/or setting up the FTP server connection, hosting an HTTP endpoint etc, and requires more palettes.

3) HomeAssistant Setup
  • Requirements

    • MQTT is connected
    • If you have the node red flow setup, and the printer is ON, then go to the devices/integrations tab, MQTT, then you should see your printer and all attached AMS units as separate devices if everything is working.
  • Dashboard Yaml

    • Requirements
      • HACS repos
        • card-mod
        • lovelace-layout-card
        • hui-element
        • button-card
        • mushroom
        • config-template-card
        • FontAwesome Icons (to load custom_icons)
        • custom-ui* (Maybe, I can’t remember)
      • Device Requirements
        • Smart Plug/Switch printer is connected to (if not, then can edit the yaml to remove)
    • Download this yaml from the gist Bambu X1C + NodeRed HomeAssistant YAML Snippet · GitHub
      • More replacements to do, marked in a comment a bit lower down, but essentially just {PRINTER_NAME}. Replace all cases of it with the LowerCase version of your printer name like in the nodered json. This is for the sensor/entity naming.
      • Find {PREVIEW_URL} and remove it + the picture hui-element it’s in. This is only if you have the advanced FTP stuff setup with the second flow.
      • Go to the third comment in the gist and download each of the attached images of the AMS and X1C. Save them in the locations in homeassistant mentioned in the comment. (/local/media is /config/www/media for HA structure)
      • Create a folder in your homeassistant config called custom_icons (right next to custom_components) and copy this SVG into it. Rename it to filament-1.svg.
    • If you have a smart plug for the printer, change the sensor entity to it (replace switch.bambu_printer)

Then just copy and paste the yaml into a new dashboard. Also restart home-assistant after putting in the custom SVG icon. I put the dashboard into a grid layout custom layout dashboard myself, but it’s up to you for any customizing!


Thank you so much for this

1 Like

Is there also an effort to create a HACS integration that doesn’t require nodered?

There was one being worked on here but neither the main dev nor I have had time in the past few weeks to contribute. It has its own limitations that you can’t replicate from the NodeRed method, but the majority of it should be transferrable, just will take some time.

I’ll have time free up to continue contributing in a few weeks I’d imagine. Currently it only has a few of the sensors being read, no AMS detection and no printer control. Planning to implement all the same sensors and AMS detection, all the same controls, and maybe some bonus stuff :slight_smile:

I have a P1P so that will require very different handling by the looks of it. Not clear how well you can track state if there’s no direct way to poll for it. But my integration building experience is nil so I’ll need something to boot strap off and something similar-ish to help me understand what’s possible.

Not a lot of spare time at the moment either so while I’d kind of like to learn how node red works given I see lots of good things written about it, probably not something I’ll have to time to learn first.

1 Like

Now that I’m more familiar with mqtt explorer I see I missed the response to this in the rapid spew. It did work once I stripped the outer {“payload”: } off it.


I’m trying to replicate your progress with my P1P. I tried the mqtt bridge approach but after adjusting my local mosquitto config (running as a service), I don’t see any evidence in the output it even attempts to connect to the P1P mqtt. I added the explicit device//report (for in) and /request (for out) since the P1P doesn’t support general access. Does mosquitto perhaps not handle the fact the P1P doesn’t behave normally?

What’s the status of your integration not needing to use an bridge? That would make the integration much easier to configure anyway.

Ah, just found your separate HACS repo. I hadn’t realized it was separate from your devtest one.

Yeah, my suspicion is that most of the commands to get status work with p1p too. Wonder if there is one that can trigger all the data to come back, either as individual messages or single. I’d begin to be worried for regularly polling for all the data though if the ESP is powerful enough with the printer. Might be best to have a stripped down one that only gets the changing updates the P1P reports, + any AMS stuff.

Could poll for versions on an hourly basis (and on connection probably), you pretty much always get temperature changes as individual messages (unless stable), not sure when the AMS stuff comes in, probably whenever it does an action.

I think with the custom integration it should be possible to configure it for both a P1P, X1 and X1C, probably need a config flow dropdown to select which one (X1 and X1C basically the same, just naming of stuff will be different), where P1P will only get a subset of sensors and likely not update as often. To add onto this, I’m pretty sure you really need to know the correct topic and can’t scan for them on the P1P so likely would be beneficial to add SerialNumber to the config flow for all printers, rather than rely on auto detection of topic.

I got @greghesp’s HACS integration installed and tried to modify it to pass the serial up front to subscribe to the specific report channel as the P1P mqtt requires (rather than wildcard) but as best I can tell I’m not getting any messages back during the initial connection attempt even with that change. I see the ‘On Connected: Connected to Broker’ on a background thread but no messages arrive in the 5 seconds before it gives up on the attempt. Kinda stumped.

Also is there a way to make test changes without having to restart home assistant or test outside of home assistant for a more rapid inner loop as I learn how this works?

If you use Docker, then just clone my repo into a folder somewhere. I put mine in a folder called Custom Components: GitHub - greghesp/ha-bambulab

I then have another folder somewhere called ha-dev and in there I have a structure that looks like this:

Then in the docker-compose file I have

version: "3.3"
  image: homeassistant/home-assistant:beta
  container_name: homeassistant
  restart: unless-stopped # To reboot the container when the host comes back up from restarts.
   - 8123:8123
   - ./hass_dev:/config
   - ../Custom Components/ha-bambulab/custom_components/bambu_lab:/config/custom_components/bambu_lab

Then to run docker-compose up in that folder. This will then map the hass_dev folder to the home assistant config folder, and also map the cloned ha-bambulab repo into the custom components folder.

When you make changes, you can just restart the Docker container which will only take a few seconds

1 Like

Repeating my mqtt explorer setup I see it defaulted to adding some channels to the connection and it gets immediately disconnected with those specified. Remove them and it can stay connected but doesn’t receive anything and I can’t see any option to subscribe to a topic after the fact - only in the initial advanced settings for the connection.

So I suspect that the mqtt being used in the integation is trying to do things that a normal mqtt server would handle but the stripped down custom P1P mqtt server can’t. I need to work out if there’s an equivalent on_disconnect callback I can use to confirm I’m getting immediately disconnected.

You should be able to add in an on_disconnect method and pass it a callback function

How do I find the expected parameters for on_disconnect? How did you learn about / how to use the HA mqtt APIs?

I have it all set up and functioning as it should, the only thing i don’t see is the custom svg file for filament on my phone (android) dashboard, i see it on my computer dashboard and its the same dashboard.
Thank you for all your hard work

Probably a caching issue then. I’d suggest clearing the app cache then restarting it. If not, it will probably work at some point. Ran into this issue myself, darn HA caching!