Bambu Lab X1 X1C MQTT

I just wanted a “one page” solution for my mobile. I think it might be interesting for someone else, here a screenshot.

It is a bit messy but full of condensed info.
Thanks developers!

2 Likes

Nice! Also in case you’re interested, I did just update a few days ago the AMS and media files with the “new” humidity icons which are easier to read (and renamed now since both the HACs integration & my nodered one now invert the values like Bambu’s UI does), so you can grab them if you’d like.

Figured this may be helpful to others here, but I have just created a few basic automation blueprints for the printers.

  1. Automate bentobox fan/switch based on print state and active filament
  2. Send notification (HA, mobile app, desktop, alexa tts) on print end
  3. Send notification (HA, mobile app, desktop, alexa tts) on print error (only the same kind of errors handy app or printer will have a popup for, halting a print).

Very nice. I should learn how to make the blueprints and then I could share what I have set up with Discord - sure others have it or something similar.

My setup takes a snapshot & posts it with % complete and plate name at start, 25%, 50%, 75%, and finish.

Another automation takes a snapshot every 3 minutes during active print then compiles into a timelapse after finish and uploads it.

1 Like

I do something similar but I have to manually create the Timelapse after collecting all the snapshots. I’d love to see the yaml you use to create the Timelapse portion.

Surely… Below is for the timelapse.

To give credit where it is due, I started with this discussion: Send MJPEG still to discord notify - #3 by Corey_Johnson

I have 3 shell commands in my configuration.yaml:

create_time_lapse: 'ffmpeg -framerate 6 -pattern_type glob -i "/config/www/snapshots/X1CC/*.jpg" -c:v libx264 -r 6 -pix_fmt yuv420p /config/www/timelapse/X1CC_timelapse.mp4'
delete_snapshots: 'find /config/www/snapshots/X1CC/*.jpg -exec rm {} \;'
delete_timelapse: 'find /config/www/timelapse/*.mp4 -exec rm {} \;'

Here is the automation for the snapshots:

alias: X1CC Timelapse Snapshot
description: ""
trigger:
  - platform: time_pattern
    minutes: /3
condition:
  - condition: state
    entity_id: sensor.x1c_x1c_3dp_00m_110_print_status
    state: RUNNING
    enabled: true
    for:
      hours: 0
      minutes: 3
      seconds: 0
action:
  - service: camera.snapshot
    data:
      filename: >-
        /config/www/snapshots/X1CC/X1CC_cam_{{ now().strftime("%Y%m%d-%H%M%S")
        }}.jpg
    target:
      entity_id: camera.192_168_90_51

and then this, to create the timelapse, post to discord, and cleanup/delete all the images/video afterwards:

alias: X1CC Timelapse Video
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.x1c_x1c_3dp_00m_110_print_status
    to: FINISH
    for:
      hours: 0
      minutes: 0
      seconds: 1
    from: RUNNING
condition: []
action:
  - service: shell_command.create_time_lapse
    data: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: notify.homeassistant_app
    data:
      target: "useyourtarget"
      title: X1CC
      message: >-
        Timelapse of X1CC Print of
        {{states('sensor.x1c_x1c_3dp_00m_110_subtask')}}
        {{states('sensor.x1c_x1c_3dp_00m_110_plate_name')}}
      data:
        images:
          - /config/www/timelapse/X1CC_timelapse.mp4
    alias: WWE-Discord
  - delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
  - service: shell_command.delete_snapshots
    data: {}
  - service: shell_command.delete_timelapse
    data: {}

I would love to have the YAML for this if you would be willing. Thank you!

So @WolfwithSword I got your Node-RED put together on my system. (BTW awesome work) Connected to the cloud no problem. Now…I’ve got a rub it “looks” like MQTT is connected to the HQ Mosquitto MQTT Broker. But the initialize appears stuck at First Boot.

Also apologies if this isn’t the correct vehicle in which to be asking this question.

Not quite sure what you mean by it being stuck, a screenshot of the flow could help, just the top-left region should be good!.

It should be fine here but you can also reach me on discord @wolfwithsword if it’s easier!

Gotta say I need to make some alterations to the yaml node red scripts on the website you provided @WolfwithSword.

AMS part…
tray_0,1,2,3 is tray_1,2,3,4. humidity_level should be humidity_index and ams_temp should be ams_temperature

or these might be regional differences (Europe here). Now to figure out the fan sliders because there it looks to be even more of a mess.

That said it still is a massive source of help and inspiration.

Those differences are because you configured it with the “NodeRed Integration” selected but are using data from the “HACs Integration”. Reconfigure and select “HACS Integration” instead and those will be fixed. There are quite a few differences in naming between my nodered integration (which the yamls were first built for) and the hacs ha-bambulab integration (made compatible later via selection).

Also the HACs integration does not have all the fan or temp values changeable.

first HACs wouldn’t even load the scripts now it does… man this is getting weirder by the minute. So my previous comments seem to be incorrect.

Apart from this being a great source of inspiration.

If you’ve tried both side by side, you entered in the wrong data then into the configurator and used the hac’s entity name for printer name instead of the printer name / entity name for the nodered device. The HACs data has serial number in the printer device name, and my nodered one does not contain it.

Hello,
Does anyone know how to get and set AMS settings via MQTT?

You can check the bambustudio source, specifically in DeviceManager, if any of those options are documented.

For example, AMS Filament Backup aka filament_autoswitch is this:

{
    "print": {
        "sequence_id": "0",
        "command": "print_option",
        "auto_switch_filament": true/false
    }
}

Just send to the request topic and it’ll set the value. Do note that if you’re on P1 or A1 newer firmware, some control options only work if in lan mode, or if sent to the cloud mqtt broker instead. A similar change is likely to come to the X1 series down the road. I am unsure if this is one of the ones restricted or not.

Yeah, I finally found it, thank you!

Does anyone know why some fan are of a type “fan” and some of type “sensor”?
I’m using the MQTT integration and own a P1S.
To me it seems that the part fan needs to a Fan too. Where to change that? NR?


Can you try setting the cooling fan speed to something and seeing if it appears? And possibly restarting the MQTT Broker for HA as well and then waiting ~5min and trying to set that cooling speed one more time?

All three changeable fans in my nodered flow go through the same logic (Aux, Chamber, Part cooling) for creating both a sensor entity for the fan speed, and the fan entity to control said speed. But P1/A1 series are known for not sending all the data in MQTT all the time, so it is possible that the printer had not sent any update/data about the part cooling fan, and thus, the integration assumes it does not exist until it hears about it.

Also feel free to reach me on discord @wolfwithsword or make a github issue on my integration (linked in the configurator pages) if it persists!

@WolfwithSword Thanks for the initial dashboard - I added the camera image to the center of the printer, and I think that works quite well for me.

Also, I am using the google_generative_ai_conversation integration to detect print failures. This sends me a notification on suspected failure, and I added the info in a markdown box as seen in this screenshot.

2 Likes

If anyone is using my cloud login flow for nodered, or is experiencing other issues with connecting to the cloud API in their own third party integrations - Bambu has rolled out a change requiring email verification codes on login now be mandatory, and expiry times are now 3 months.

I’ve updated my cloud flow to v2.1.9 with a workaround for this (update and deploy, it will fail login and send email verification code, then you put it into the config node within the 5min and re-deploy, and it should stay logged in for a year or so 3 months or so, for token expiry unless your nodered does not keep variables between deploys).

1 Like