Spoolman Updater – Automate Filament Tracking

I’m seriously confused what we are trying to run here.
It doesn’t change counts, nor change the loaded rolls.
Most of this I think is already realized here with automations

It isnt that hard to configure. You probably forgot something in the manual. You have to change the loaded spools yourself because the printer doesnt know all brands and colors. So the github repo you sent will only work with brands like esun and bambu, other brands wont work. Mine works brand independent.

  1. Nope, it used to set the spools from spoolman updater to the ams but Bambu killed that in their api. Now you will have to set it in spoolman updater and in the printer
  2. Yes, if its not known. But here you can see the problem with using other than Bambu brands. The printer doesnt know which brand it is if you dont use the brands they acknowledge
  3. The weight is sent to spoolman after tray change. So it will work with multiple color print
  4. This should count as a tray change, didnt test that tho. But yeah it should work
  5. Usage counter? You mean meter? Thats not optional for the automation no
  6. The camera icon is so you can scan the spool you are about to load. This only works when you host spoolman-updater is https for security reasons with the camera. Your phone browser will force that

My guess is you didnt set the spool in the correct tray in the GUI

Nope, it doesnt use the rfid because that will only work with Bambu spools.

So i just tried the automation and everytime i get the following error.

 Error. Url: http://10.150.175.10:8088/Spools/spool. Status code 404. Payload: b'{\n "name": "",\n "material": "",\n "tag_uid": "",\n "used_weight": ,\n "color": "",\n "active_tray_id": "a1_03919d510504942_active_tray_3"\n}' 

and

Template variable warning: 'name' is undefined when rendering '{ "name": "{{ name }}", "material": "{{ material }}", "tag_uid": "{{ tag_uid }}", "used_weight": {{ used_weight }}, "color": "{{ color }}", "active_tray_id": "{{ filament_active_tray_id }}" }'
Template variable warning: 'material' is undefined when rendering '{ "name": "{{ name }}", "material": "{{ material }}", "tag_uid": "{{ tag_uid }}", "used_weight": {{ used_weight }}, "color": "{{ color }}", "active_tray_id": "{{ filament_active_tray_id }}" }'
Template variable warning: 'tag_uid' is undefined when rendering '{ "name": "{{ name }}", "material": "{{ material }}", "tag_uid": "{{ tag_uid }}", "used_weight": {{ used_weight }}, "color": "{{ color }}", "active_tray_id": "{{ filament_active_tray_id }}" }'
Template variable warning: 'used_weight' is undefined when rendering '{ "name": "{{ name }}", "material": "{{ material }}", "tag_uid": "{{ tag_uid }}", "used_weight": {{ used_weight }}, "color": "{{ color }}", "active_tray_id": "{{ filament_active_tray_id }}" }'
Template variable warning: 'color' is undefined when rendering '{ "name": "{{ name }}", "material": "{{ material }}", "tag_uid": "{{ tag_uid }}", "used_weight": {{ used_weight }}, "color": "{{ color }}", "active_tray_id": "{{ filament_active_tray_id }}" }'

I just changed the sensors to match my printer.

alias: Bambulab - Update Spool When Print Finishes or Tray Switches
description: ""
triggers:
  - trigger: state
    entity_id:
      - sensor.a1_03919d510504942_active_tray_index
conditions:
  - condition: template
    value_template: "{{ trigger.from_state.state not in ['unknown', 'unavailable'] }}"
  - condition: template
    value_template: "{{ trigger.from_state.state | int > 0 }}"
actions:
  - variables:
      tray_number: >-
        {{ trigger.from_state.state if trigger.entity_id ==
        'sensor.a1_03919d510504942_active_tray_index' else
        states('sensor.a1_03919d510504942_active_tray_index') }}
      tray_sensor: sensor.a1_03919d510504942_active_tray_{{ tray_number }}
      tray_weight: >-
        {{ states('sensor.bambulab_filament_usage_meter') | float(0) | round(2)
        }}
      tag_uid: "{{ state_attr(tray_sensor, 'tag_uid') }}"
      material: "{{ state_attr(tray_sensor, 'type') }}"
      name: "{{ state_attr(tray_sensor, 'name') }}"
      color: "{{ state_attr(tray_sensor, 'color') }}"
  - data:
      filament_name: "{{ name }}"
      filament_material: "{{ material }}"
      filament_tag_uid: "{{ tag_uid }}"
      filament_used_weight: "{{ tray_weight }}"
      filament_color: "{{ color }}"
      filament_active_tray_id: "{{ tray_sensor | replace('sensor.', '') }}"
    action: rest_command.update_spool
  - action: utility_meter.calibrate
    data:
      value: "0"
    target:
      entity_id: sensor.bambulab_filament_usage_meter
alias: Bambulab - Update Spool When Print Finishes or Tray Switches
description: ""
triggers:
  - trigger: state
    entity_id:
      - sensor.a1_03919d510504942_active_tray_index
conditions:
  - condition: template
    value_template: "{{ trigger.from_state.state not in ['unknown', 'unavailable'] }}"
  - condition: template
    value_template: "{{ trigger.from_state.state | int > 0 }}"
actions:
  - variables:
      tray_number: >-
        {{ trigger.from_state.state if trigger.entity_id ==
        'sensor.a1_03919d510504942_active_tray_index' else
        states('sensor.a1_03919d510504942_active_tray_index') }}
      tray_sensor: sensor.a1_03919d510504942_active_tray_{{ tray_number }}
      tray_weight: >-
        {{ states('sensor.bambulab_filament_usage_meter') | float(0) | round(2)
        }}
      tag_uid: "{{ state_attr(tray_sensor, 'tag_uid') }}"
      material: "{{ state_attr(tray_sensor, 'type') }}"
      name: "{{ state_attr(tray_sensor, 'name') }}"
      color: "{{ state_attr(tray_sensor, 'color') }}"
  - data:
      filament_name: "{{ name }}"
      filament_material: "{{ material }}"
      filament_tag_uid: "{{ tag_uid }}"
      filament_used_weight: "{{ tray_weight }}"
      filament_color: "{{ color }}"
      filament_active_tray_id: "{{ tray_sensor | replace('sensor.', '') }}"
    action: rest_command.update_spool
  - action: utility_meter.calibrate
    data:
      value: "0"
    target:
      entity_id: sensor.bambulab_filament_usage_meter

Also since someone else asked it above.
I just canceld a print an it did not update the tray index

1 Like

Ah thnx for testing! Tbf the automation is responsible for call the api so maybe we can find a solution for the cancelling :slight_smile:

How does your rest command look?

Accidentally sent the Automation twice. :smiley:
The “Spoolman-Updater” Part of my Config.yaml

# Spoolman Updater      
rest_command:
  update_spool:
    url: "http://10.150.175.10:8088/Spools/spool"
    method: POST
    headers:
      Content-Type: "application/json"
    payload: >
      {
        "name": "{{ name }}",
        "material": "{{ material }}",
        "tag_uid": "{{ tag_uid }}",
        "used_weight": {{ used_weight }},
        "color": "{{ color }}",
        "active_tray_id": "{{ filament_active_tray_id }}"
      }
sensor:
  - platform: template
    sensors:
      bambulab_filament_usage:
        unique_id: b954300e-d3a2-44ab-948f-39c30b2f0c00
        friendly_name: "Bambu Lab Filament Usage"
        value_template: "{{ states('sensor.a1_03919d510504942_print_weight') | float(0) / 100 * states('sensor.a1_03919d510504942_print_progress') | float(0) }}"
        availability_template: "{% if is_state('sensor.a1_03919d510504942_print_weight', 'unknown') or is_state('sensor.a1_03919d510504942_print_weight', 'unavailable') %} false {% else %} true {%- endif %}"
utility_meter:
  bambulab_filament_usage_meter:
    unique_id: 148d1e2d-87b2-4883-a923-a36a2c9fa0ac
    source: sensor.bambulab_filament_usage
    cycle: weekly

Wow, this was apparently never updated in the readme. The rest command must be:

rest_command:
  update_spool:
    url: "http://<your-server>:8088/Spools/spool"
    method: POST
    headers:
      Content-Type: "application/json"
    payload: >
      {
        "name": "{{ filament_name }}",
        "material": "{{ filament_material }}",
        "tag_uid": "{{ filament_tag_uid }}",
        "used_weight": {{ filament_used_weight | int }},
        "color": "{{ filament_color }}",
        "active_tray_id": "{{ filament_active_tray_id }}"
      }

nope :wink:

The new version has this implemented

I see, thanks search works well… when for automatic detection of original filaments?

That wont be in it. Because like it said, it only works for original Bambu spools, esun and sunlu?, and my API is brand independent. Als long as you set the spool in the correct ams slot via the GUI it will update the spool in spoolman.

Ofcourse the automation must be working correctly in HA.
When I got the time i will look to make it working without Home Assistant, but i dont think that will be anytime soon

your app is fantastic, and have great potential.
i understand that it would only work with bambu spools but why you don’t think to “suggest” the spool that is correctly recognized also if it is only bambu brand? for example my bambu spools are 85% and many users like me can have a great advantage with this little functionality.

On what would you make the comparison in spoolma n? There is only one way to do this correctly for all brands, the ams slot its in, and thats how the API does it.

The problem is Bambulab, it doesnt support all brands

Off-topic: why are you paying for overpriced spools from Bambu Lab? Sunlu is the same quality

if you see Rdiger-36 app work on serial number, and the filament name/color when It is recognized ask to pair or do it automatically. if homeassistant send filament type/brand/color that is recognized on the list of spoolman filament, you can “suggest” filament. this can be an easy way to avoid selection of all filaments.

I buy bambu because they costs me the same price (13,99 for a recharge) against 2 euro less for sunlu…

Serial only works for Bambu, like I said many times now. And filament name/color isnt unique enough.

maybe I wasn’t able to make myself understood and I apologize, my English is not the best.
I understood perfectly that it would only work with the bambulab coils, but don’t you think it would be a help to not always fill in the fields at least in the case of using these coils? if you don’t use them you certainly don’t care but to me who use them it is a very convenient function.

You have to set it every time you load a spool anyways. So the first time isnt that much extra effort.