Bambu Lab X1 X1C MQTT

@greghesp I’m trying to learn how to push to github so I can create a pull request for my changes for review. I have a local topic branch but when I try and push that I get an access denied error. I think I have the personal access token set up properly but honestly I’m mostly guessing.

remote: Permission to greghesp/ha-bambulab.git denied to AdrianGarside.

You need to fork the repo to your own account, make your changes and then submit a push request

1 Like

Ah, that’s a different workflow than I’m used to at my company with a close source repo. Submitted the pull request.

How do you develop this locally? Initially I set it up the integration via HACS and since I didn’t want to overwrite my changes I cloned into a separate directory. But I’m thinking I want to move the clone to be the HACS directory instead so I can code / test / push all from one place.

HA’s developer docs are pretty straightforward: https://developers.home-assistant.io/

For addons and such, I use their docker-in-docker dev environment setup. I’ve never used it for HACS work, though. HACS seems to have some pretty good documentation, plus their own dev environment:

With all of that, you should be able to get started. I’d never advocate developing on my live/production instance.

Thank you for all your help, here’s my setup so far, still have to figure out the preview image in the center and remaining time I added in the screen to have format: 0 hours 55 minutes instead of 58:00

1 Like

What risks am I missing by using my existing live system? Worst case that I can see is that I break the integration I’m working on.

I don’t use the Devcontainers, the Home Assistant one seems to be rather slow for me. I found it easier to just dockerise HA itself, and then map volumes out to my custom components.

That allows me to keep my repos locally all in separate folders so its easy to push/pull to git, without needing submodules etc.

It’s a little annoying having to restart the container after every change to reload the component, but it only takes about 5s to restart it

It could crash it. Personally I use the dev container approach, but instead use a command to copy the folder to the docker dev container anytime I update it then restart that HA right after, takes 10-30 seconds tops.

One thing we did find was that there were bugs in the code that broke home-assistant that was via the dev container (I believe it runs HA-Core like I do normally) but didn’t break it through other means if they replicate HASSOS I think. So it seems for developing it to be “stable”, the dev container / HA-Core may be best.

Seeing how active this forum can get sometimes and how the gists keep updating, I think I’m going to spend this coming weekend making an online configurator for the gist flows and HA yaml with the same instructions, but pulls it live from the gists and such. It will make it much easer for people to update and/or get going for the first time if they use the NR MQTT approach.

1 Like

So that big dump of state is each time I load up the Bambu Handy app. Somehow, probably through the cloud, it’s poking the machine to dump all state. Sadly it’s not obvious how. Wire shark shows very little traffic to the printer and definitely not any plain text mqtt Publish that I could use to easily trigger it myself. I was really hoping it would be that!

If you connect via MQTT explorer can you see if anything is pushed to the device/serialnum/request topic when you open the Handy app? I tried that in my debugging but could not see if Handy triggered any MQTT request on the X1C because it outputs every 1s that big status (in addition to a ton of mc_print messages).

If something comes in there, then that will be the command to get the status publish to trigger.

Haven’t made one for the companion/advanced flow, or the HA dashboard YAML, but figured this would be a good start.

Hopefully this can work as a good starting point for whenever people need to set this up, and not need to spend an hour or two going through a few forums posts or gist comments.

This page will help you do all the steps needed to setup the basic printer → nodered → mqtt → home assistant setup, and offers a configurator for the nodered flow json as well. Still requires manually setting the MQTT credentials though.

2 Likes

I’ll give that a go but I’m not sure the p1p will let me monitor the request topic. But I’m doubly not hopeful as the wire shark network trace definitely has no plain text mqtt publish going to the printer. I do see an SSDP discovery request but it seems unlikely that would trigger the big dump.

I’m wondering if lan mode with the X1 would use mqtt publish commands to get the big dump state when the app first connects? Lan mode should take the Bambu servers out of the picture.

No joy. If I try to connect to device//request with my P1P via mqtt explorer it immediately closes the connection on me.

Ich denke schon, dass ich es einigermassen hingekriegt habe. :slight_smile:

Thank you.

Are the filament colors synced from the ams? How did you do that? neat

That’s from the HA YAML snippet originally I have a gist for. It also highlights the current one in use during a print. I believe the specific one they have is a slightly altered one from Cryd with a different icon and has the temp/humidity closer to the middle, and a different background image.

I’m currently working on another “Configurator” page for that as well, should be done within the next 24 hours I think. If you don’t want to wait, there’s my instructions for it here, go to step 3. For downloading the yaml, only do the custom_X1C_HA.yaml file.

I already have the setup thanks to you :smiley: but i was wondering how they changed the color of the filament itself and not only the icon. or if it’s just a image that isn’t really representing the current installed colors.

Are you going to add preview 3mf to the configurator? :wink: