My Bambu Lab X1C Dashboard & Automations

No, I finally put it on the to do list for another time.

Ah, those are in my main configuration.yaml

  - sensor:
      - name: "Tray 1 Remaining Filament Percentage"
        unique_id: "tray_1_remain_percent"
        unit_of_measurement: "%"
        state: >
          {% set total_capacity = 100 %}
          {{ (state_attr('sensor.p1s_01p00c470401372_ams_1_tray_1', 'remain') / total_capacity) * 100 | round(1) }}

      - name: "Tray 2 Remaining Filament Percentage"
        unique_id: "tray_2_remain_percent"
        unit_of_measurement: "%"
        state: >
          {% set total_capacity = 100 %}
          {{ (state_attr('sensor.p1s_01p00c470401372_ams_1_tray_2', 'remain') / total_capacity) * 100 | round(1) }}

      - name: "Tray 3 Remaining Filament Percentage"
        unique_id: "tray_3_remain_percent"
        unit_of_measurement: "%"
        state: >
          {% set total_capacity = 100 %}
          {{ (state_attr('sensor.p1s_01p00c470401372_ams_1_tray_3', 'remain') / total_capacity) * 100 | round(1) }}

      - name: "Tray 4 Remaining Filament Percentage"
        unique_id: "tray_4_remain_percent"
        unit_of_measurement: "%"
        state: >
          {% set total_capacity = 100 %}
          {{ (state_attr('sensor.p1s_01p00c470401372_ams_1_tray_4', 'remain') / total_capacity) * 100 | round(1) }}

I have the same problem. Have an X1C and an AMS2pro. It gets the name of the filament. And if I use the template editor and type in the code for the color, it shows me the color-Hex-Name.

{{state_attr('sensor.x1c_ams_slot_1', 'color') }} ==> #00AE42FF;

I don’t know, how to solve the problem.

Worked for me too. Thank you! :slight_smile:

Made some changes for my AMS overview card.
Now it fetches the filament color name too.
And I got rid of the sensors in configuration.yaml

I use embedded nuts in some of my prints, so I made an automation that pauses the print at a predetermined layer and sends me a notification. It’s come in pretty handy

Hi, I just added all the codes. Everything is showing except the colors of the filaments in the AMS. In the integration, I don’t see colors being exposed. How did you all make the card to show the filament colors?

Thanks in advance.

Hi,
you can change from “–paper-item-icon-color:” to “–state-icon-color:”

1 Like

Hello,

I got my 1st Bambu lab printer a few days a go and I’m trying to implement the same configuration as you ( Great job and thanks a ton for sharing).

I’ve replaced all your entites with mine but I’m facing an error when trying to save, It says: Unknown type encounter: sections

I’m running version 2025.9.3 so was expecting “sections” to be supported and recognized but that seems to be the case.

Also when trying @benji setup, I can get the colors to display, regardless of using the --paper-item-icon-color: or the –state-icon-color:

Any idea on how to get this sorted or if any one else has an idea that it would be highly appreciated

Thanks in advance

Would it be possible to get your code for the AMS? It looks perfect! :heart_eyes:
What do you use for keeping track of your remaining filament?

The printer keeps track of remaining filament.

You need to create a file in /homeassistant/custom_templates/ and name it: cols.jinja
Put this code in the file

{% macro hex2name(hex,name_only=True) -%}
{% set cols = {
    "Indian Red":            "#cd5c5c", "Light Coral":      "#f08080",
    "Salmon":               "#fa8072", "Dark Salmon":      "#e9967a",
    "Light Salmon":          "#ffa07a", "Red":             "#ff0000",
    "Crimson":              "#dc143c", "Fire Red":       "#b22222",
    "Dark Red":              "#8b0000", "Pink":            "#ffc0cb",
    "Light Pink":            "#ffb6c1", "Hot Pink":         "#ff69b4",
    "Deep Pink":             "#ff1493", "Medium Violet Red": "#c71585",
    "Pale Violet Red":        "#db7093", "Coral":           "#ff7f50",
    "Tomato":               "#ff6347", "Orange Red":       "#ff4500",
    "Dark Orange":           "#ff8c00", "Orange":          "#ffa500",
    "Gold":                 "#ffd700", "Yellow":          "#ffff00",
    "Light Yellow":          "#ffffe0", "Lemon Chiffon":    "#fffacd",
    "Light Golden Rod Yellow": "#fafad2", "Papaya Whip":      "#ffefd5",
    "Moccasin":             "#ffe4b5", "Peach Puff":       "#ffdab9",
    "Pale Golden Rod":        "#eee8aa", "Khaki":           "#f0e68c",
    "Dark Khaki":            "#bdb76b", "Lavender":        "#e6e6fa",
    "Thistle":              "#d8bfd8", "Plum":            "#dda0dd",
    "Violet":               "#ee82ee", "Orchid":          "#da70d6",
    "Fuchsia":              "#ff00ff", "Magenta":         "#ff00ff",
    "Medium Orchid":         "#ba55d3", "Medium Purple":    "#9370db",
    "Blue Violet":           "#8a2be2", "Dark Violet":      "#9400d3",
    "Dark Orchid":           "#9932cc", "Dark Magenta":     "#8b008b",
    "Purple":               "#800080", "Indigo":          "#4b0082",
    "Dark Slate Blue":        "#483d8b", "Slate Blue":       "#6a5acd",
    "Medium Slate Blue":      "#7b68ee", "Rebecca Purple":   "#663399",
    "Green Yellow":          "#adff2f", "Chartreuse":      "#7fff00",
    "Lawn Green":            "#7cfc00", "Lime":            "#00ff00",
    "Lime Green":            "#32cd32", "Pale Green":       "#98fb98",
    "Light Green":           "#90ee90", "Spring Green":     "#00ff7f",
    "Medium Spring Green":    "#00fa9a", "Medium Sea Green":  "#3cb371",
    "Sea Green":             "#2e8b57", "Forest Green":     "#228b22",
    "Green":                "#008000", "Dark Green":       "#006400",
    "Yellow Green":          "#9acd32", "Olive Drab":       "#6b8e23",
    "Olive":                "#808000", "Dark Olive Green":  "#556b2f",
    "Medium Aquamarine":     "#66cdaa", "Dark Sea Green":    "#8fbc8f",
    "Light Sea Green":        "#20b2aa", "Dark Cyan":        "#008b8b",
    "Teal":                 "#008080", "Aqua":            "#00ffff",
    "Cyan":                 "#00ffff", "Light Cyan":       "#e0ffff",
    "Pale Turquoise":        "#afeeee", "Aquamarine":      "#7fffd4",
    "Turquoise":            "#40e0d0", "Medium Turquoise": "#48d1cc",
    "Dark Turquoise":        "#00ced1", "Cadet Blue":       "#5f9ea0",
    "Steel Blue":            "#4682b4", "Light Steel Blue":  "#b0c4de",
    "Powder Blue":           "#b0e0e6", "Light Blue":       "#add8e6",
    "Sky Blue":              "#87ceeb", "Light Sky Blue":    "#87cefa",
    "Deep Sky Blue":          "#00bfff", "Dodger Blue":      "#1e90ff",
    "Cornflower Blue":       "#6495ed", "Royal Blue":       "#4169e1",
    "Blue":                 "#0000ff", "Medium Blue":      "#0000cd",
    "Dark Blue":             "#00008b", "Navy":            "#000080",
    "Midnight Blue":         "#191970", "Cornsilk":        "#fff8dc",
    "Blanched Almond":       "#ffebcd", "Bisque":          "#ffe4c4",
    "Navajo White":          "#ffdead", "Wheat":           "#f5deb3",
    "Burlywood":            "#deb887", "Tan":             "#d2b48c",
    "Rosy Brown":            "#bc8f8f", "Sandy Brown":      "#f4a460",
    "Golden Rod":            "#daa520", "Dark Golden Rod":   "#b8860b",
    "Peru":                 "#cd853f", "Chocolate":       "#d2691e",
    "Saddle Brown":          "#8b4513", "Sienna":          "#a0522d",
    "Brown":                "#a52a2a", "Maroon":          "#800000",
    "White":                "#ffffff", "Snow":            "#fffafa",
    "Honeydew":             "#f0fff0", "Mint Cream":       "#f5fffa",
    "Azure":                "#f0ffff", "Alice Blue":       "#f0f8ff",
    "Ghost White":           "#f8f8ff", "White Smoke":      "#f5f5f5",
    "Sea Shell":             "#fff5ee", "Beige":           "#f5f5dc",
    "Old Lace":              "#fdf5e6", "Floral White":     "#fffaf0",
    "Ivory":                "#fffff0", "Antique White":    "#faebd7",
    "Linen":                "#faf0e6", "Lavender Blush":   "#fff0f5",
    "Misty Rose":            "#ffe4e1", "Gainsboro":       "#dcdcdc",
    "Light Gray":            "#d3d3d3", "Light Grey":       "#d3d3d3",
    "Silver":               "#c0c0c0", "Dark Gray":        "#a9a9a9",
    "Dark Grey":             "#a9a9a9", "Gray":            "#808080",
    "Grey":                 "#808080", "Dim Gray":         "#696969",
    "Dim Grey":              "#696969", "Light Slate Gray":  "#778899",
    "Light Slate Grey":       "#778899", "Slate Gray":       "#708090",
    "Slate Grey":            "#708090", "Dark Slate Gray":   "#2f4f4f",
    "Dark Slate Grey":        "#2f4f4f", "Black":           "#000000",
    "Bambu Green":            "#00AE42", "Misteltoe Green":   "#3F8E43",
    "Cyan":                 "#0086D6", "Magenta":           "#EC008C",
    "Orange":               "#F75403", "Gold":               "#E5B03D", 
    "Red":              "#C12E1F"
} -%}
{% set ns = namespace(distance=0,name="") -%}
{% set hex = hex|lower|select('in','0123456789abcdef')|join -%}
{% if hex|length == 3 -%}
{% set hex = hex[0]*2~hex[1]*2~hex[2]*2 -%}
{% endif -%}
{% if hex|length != 6 -%}
{% else -%}
{% set rgb = {'r':hex[0:2]|int(base=16),'g':hex[2:4]|int(base=16),'b':hex[4:6]|int(base=16)} -%}
{% for c in cols -%}
{% set crgb = {'r':cols[c][1:3]|int(base=16),'g':cols[c][3:5]|int(base=16),'b':cols[c][5:7]|int(base=16)} -%}
{% set cdist = sqrt((rgb['r']-crgb['r'])**2 + (rgb['g']-crgb['g'])**2 + (rgb['b']-crgb['b'])**2) -%}
{% if ns.name == "" or ns.distance > cdist -%}
{% set ns.name, ns.distance = c, cdist -%}
{% endif -%}
{% endfor -%}
{% if name_only -%}
{{ ns.name -}}
{% else -%}
{{ {"name": ns.name, "distance": ns.distance}|to_json -}}
{% endif -%}
{% endif -%}
{% endmacro -%}

This is the dashboard code for 1 AMS:

type: vertical-stack
cards:
  - type: custom:mod-card
    card_mod:
      style:
        hui-horizontal-stack-card $: |
          div#root > :last-child > * {
            width: 100%;
            flex: auto; 
          }
    card:
      type: horizontal-stack
      cards:
        - type: custom:mushroom-chips-card
          chips:
            - type: template
              entity: binary_sensor.x1c_00m09d470100819_online
              content: AMS A
              card_mod:
                style: |
                  ha-card {
                    background: none !important;
                    border: none;
                    font-size: 4rem !important;
                  }
            - type: spacer
            - type: entity
              entity: sensor.x1c_00m09d470100819_ams_1_remaining_drying_time
            - type: entity
              entity: sensor.x1c_00m09d470100819_ams_1_temperature
            - type: entity
              entity: sensor.x1c_00m09d470100819_ams_1_humidity
            - type: entity
              entity: sensor.x1c_00m09d470100819_ams_1_humidity_index
              icon: mdi:water-opacity
  - type: horizontal-stack
    cards:
      - type: vertical-stack
        cards:
          - type: markdown
            card_mod:
              style: |
                :host {
                  max-width:100px !important;
                  border:none;
                  margin: 0px 0px 0px 0px !important;
                  padding: 0px 0px 0px 0px !important;
                }
                ha-markdown {
                  padding: 0px 0px 0px 0px !important;
                  margin: 0px 0px 0px 0px !important;
                  width: 100%;
                  line-height:1.5;
                  height: 100%;
                  justify-content: center !important;
                }
                ha-card {
                  {%- set active = state_attr('sensor.x1c_00m09d470100819_ams_1_tray_1', 'active') %}
                  {%- if active == 1 %}
                    --ha-card-border-color: darkorange;
                  {%- else %}
                  {%- endif %}
                  border-radius: 20px;
                }
            content: >-
              <table width=100%><td align=center><font size="2" color=#FFFFFF>{{
              state_attr('sensor.x1c_00m09d470100819_ams_1_tray_1', 'name') |
              replace('Bambu ', '') | replace('For PLA/PETG', '') | replace('
              Basic', '')}}</font>  <table width=100%><td align=center><font
              size="2"> {% if
              ((state_attr('sensor.x1c_00m09d470100819_ams_1_tray_1',
              'remain')/100)*335) <= 0 %}
                Empty spool
              {% else %}
                <font color=#959595>{{ (state_attr('sensor.x1c_00m09d470100819_ams_1_tray_1', 'remain')*10) }}g <font color=#FFFFFF> | </font><font color=#959595>{{ ((state_attr('sensor.x1c_00m09d470100819_ams_1_tray_1', 'remain')/100)*335) | round(0) }}m
              {% endif %}</td> </tr></table>

              <font
              color={{state_attr('sensor.x1c_00m09d470100819_ams_1_tray_1',
              'color') [0:7] }}> <ha-icon icon="phu:3d-filament"></ha-icon> 
              <table width=100%><td align=center><font size="2" color=#FFFFFF>{%
              from 'cols.jinja' import hex2name %}{{
              hex2name(state_attr('sensor.x1c_00m09d470100819_ams_1_tray_1',
              'color') [1:7]) }}</font></td></tr></table>
      - type: vertical-stack
        cards:
          - type: markdown
            card_mod:
              style: |
                :host {
                  max-width:100px !important;
                  border:none;
                  margin: 0px 0px 0px 0px !important;
                  padding: 0px 0px 0px 0px !important;
                }
                ha-markdown {
                  padding: 0px 0px 0px 0px !important;
                  margin: 0px 0px 0px 0px !important;
                  width: 100%;
                  line-height:1.5;
                  height: 100%;
                  justify-content: center !important;
                }
                ha-card {
                  {%- set active = state_attr('sensor.x1c_00m09d470100819_ams_1_tray_2', 'active') %}
                  {%- if active == 1 %}
                    --ha-card-border-color: darkorange;
                  {%- else %}
                  {%- endif %}
                  border-radius: 20px;
                }
            content: >-
              <table width=100%><td align=center><font size="2" color=#FFFFFF>{{
              state_attr('sensor.x1c_00m09d470100819_ams_1_tray_2', 'name') |
              replace('Bambu ', '') | replace('For PLA/PETG', '') | replace('
              Basic', '')}}</font>  <table width=100%><td align=center><font
              size="2"> {% if
              ((state_attr('sensor.x1c_00m09d470100819_ams_1_tray_2',
              'remain')/100)*335) <= 0 %}
                Empty<br>spool
              {% else %}
                <font color=#959595>{{ (state_attr('sensor.x1c_00m09d470100819_ams_1_tray_2', 'remain')*10) }}g <font color=#FFFFFF> | </font><font color=#959595>{{ ((state_attr('sensor.x1c_00m09d470100819_ams_1_tray_2', 'remain')/100)*335) | round(0) }}m
              {% endif %}</td> </tr></table>

              <font
              color={{state_attr('sensor.x1c_00m09d470100819_ams_1_tray_2',
              'color') [0:7] }}> <ha-icon icon="phu:3d-filament"></ha-icon> 
              <table width=100%><td align=center><font size="2" color=#FFFFFF>{%
              from 'cols.jinja' import hex2name %}{{
              hex2name(state_attr('sensor.x1c_00m09d470100819_ams_1_tray_2',
              'color') [1:7]) }}</font></td></tr></table>
      - type: vertical-stack
        cards:
          - type: markdown
            card_mod:
              style: |
                :host {
                  max-width:100px !important;
                  border:none;
                  margin: 0px 0px 0px 0px !important;
                  padding: 0px 0px 0px 0px !important;
                }
                ha-markdown {
                  padding: 0px 0px 0px 0px !important;
                  margin: 0px 0px 0px 0px !important;
                  width: 100%;
                  line-height:1.5;
                  height: 100%;
                  justify-content: center !important;
                }
                ha-card {
                  {%- set active = state_attr('sensor.x1c_00m09d470100819_ams_1_tray_3', 'active') %}
                  {%- if active == 1 %}
                    --ha-card-border-color: darkorange;
                  {%- else %}
                  {%- endif %}
                  border-radius: 20px;
                }
            content: >-
              <table width=100%><td align=center><font size="2" color=#FFFFFF>{{
              state_attr('sensor.x1c_00m09d470100819_ams_1_tray_3', 'name') |
              replace('Bambu ', '') | replace('For PLA/PETG', '') | replace('
              Basic', '')}}</font>  <table width=100%><td align=center><font
              size="2"> {% if
              ((state_attr('sensor.x1c_00m09d470100819_ams_1_tray_3',
              'remain')/100)*335) <= 0 %}
                Empty spool
              {% else %}
                <font color=#959595>{{ (state_attr('sensor.x1c_00m09d470100819_ams_1_tray_3', 'remain')*10) }}g <font color=#FFFFFF> | </font><font color=#959595>{{ ((state_attr('sensor.x1c_00m09d470100819_ams_1_tray_3', 'remain')/100)*335) | round(0) }}m
              {% endif %}</td> </tr></table>

              <font
              color={{state_attr('sensor.x1c_00m09d470100819_ams_1_tray_3',
              'color') [0:7] }}> <ha-icon icon="phu:3d-filament"></ha-icon> 
              <table width=100%><td align=center><font size="2" color=#FFFFFF>{%
              from 'cols.jinja' import hex2name %}{{
              hex2name(state_attr('sensor.x1c_00m09d470100819_ams_1_tray_3',
              'color') [1:7]) }}</font></td></tr></table>
      - type: vertical-stack
        cards:
          - type: markdown
            card_mod:
              style: |
                :host {
                  max-width:100px !important;
                  border:none;
                  margin: 0px 0px 0px 0px !important;
                  padding: 0px 0px 0px 0px !important;
                }
                ha-markdown {
                  padding: 0px 0px 0px 0px !important;
                  margin: 0px 0px 0px 0px !important;
                  width: 100%;
                  line-height:1.5;
                  height: 100%;
                  justify-content: center !important;
                }
                ha-card {
                  {%- set active = state_attr('sensor.x1c_00m09d470100819_ams_1_tray_4', 'active') %}
                  {%- if active == 1 %}
                    --ha-card-border-color: darkorange;
                  {%- else %}
                  {%- endif %}
                  border-radius: 20px;
                }
            content: >-
              <table width=100%><td align=center><font size="2" color=#FFFFFF>{{
              state_attr('sensor.x1c_00m09d470100819_ams_1_tray_4', 'name') |
              replace('Bambu ', '') | replace('For PLA/PETG', '') | replace('
              Basic', '')}}</font>  <table width=100%><td align=center><font
              size="2"> {% if
              ((state_attr('sensor.x1c_00m09d470100819_ams_1_tray_4',
              'remain')/100)*335) <= 0 %}
                Empty<br>spool
              {% else %}
                <font color=#959595>{{ (state_attr('sensor.x1c_00m09d470100819_ams_1_tray_4', 'remain')*10) }}g <font color=#FFFFFF> | </font><font color=#959595>{{ ((state_attr('sensor.x1c_00m09d470100819_ams_1_tray_4', 'remain')/100)*335) | round(0) }}m
              {% endif %}</td> </tr></table>

              <font
              color={{state_attr('sensor.x1c_00m09d470100819_ams_1_tray_4',
              'color') [0:7] }}> <ha-icon icon="phu:3d-filament"></ha-icon> 
              <table width=100%><td align=center><font size="2" color=#FFFFFF>{%
              from 'cols.jinja' import hex2name %}{{
              hex2name(state_attr('sensor.x1c_00m09d470100819_ams_1_tray_4',
              'color') [1:7]) }}</font></td></tr></table>

Super, I’m having some initial problems, but I’ll solve it sooner or later. :upside_down_face:

Mange tak!

1 Like

It works!!! I tried so over dozen changes, and nothing worked until this :point_up_2:t2: one. Thank you so much!

1 Like

OMG 4 AMS units. One of these days I’ll use this thing to print something besides benchys…

One of these days I need to print a benchy :stuck_out_tongue_winking_eye:
Been 3D printing for 8 years, and never printed one

1 Like

Does anyone gave a sensor or automation to get the elapsed time on a notification? I tried using the start time + now when sending the notification but no luck.

Nice card and code.

  • Have to replace the naming of all the printer model and ams for those hitting issue not showing up. e.g sensor.x1c_xxxxx with your printer entity name in home assistant.
  • For the feed, need to turn on under Bambu Printer Settings>Lan Only> Lan Only Live View.
  • Have added my 2nd AMS as I have two but not able to align together as too much code to read.
  • Only filament colours are facing issue for me and the replace “paper-icon” to “state-icon” works.