{"id":26516281,"url":"https://github.com/marcokreeft87/spoolman-updater","last_synced_at":"2025-06-25T03:38:45.044Z","repository":{"id":282280430,"uuid":"947502339","full_name":"marcokreeft87/spoolman-updater","owner":"marcokreeft87","description":"The Spoolman Updater API provides endpoints to manage spool updates, including tracking filament usage and material details. This API is designed to work with Home Assistant and other automation systems.","archived":false,"fork":false,"pushed_at":"2025-03-20T18:10:11.000Z","size":127,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T19:38:53.104Z","etag":null,"topics":["bambulab","home-assistant","spoolman"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcokreeft87.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-12T19:40:08.000Z","updated_at":"2025-03-20T18:09:01.000Z","dependencies_parsed_at":"2025-03-20T19:29:27.136Z","dependency_job_id":null,"html_url":"https://github.com/marcokreeft87/spoolman-updater","commit_stats":null,"previous_names":["marcokreeft87/spoolman-updater"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcokreeft87%2Fspoolman-updater","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcokreeft87%2Fspoolman-updater/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcokreeft87%2Fspoolman-updater/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcokreeft87%2Fspoolman-updater/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcokreeft87","download_url":"https://codeload.github.com/marcokreeft87/spoolman-updater/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244752361,"owners_count":20504256,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bambulab","home-assistant","spoolman"],"created_at":"2025-03-21T07:16:40.570Z","updated_at":"2025-06-25T03:38:45.029Z","avatar_url":"https://github.com/marcokreeft87.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spoolman Updater API\n\n## Overview\n\nThe Spoolman Updater API provides endpoints to manage spool updates, including tracking filament usage and material details. This API is designed to work with Home Assistant and other automation systems.\n\nTo facilitate API development and testing, the Spoolman Updater API utilizes Swagger for interactive API documentation. You can access the Swagger UI at http://\u003cyour-server\u003e:8088/swagger, which allows you to explore and test the available endpoints.\n\n\u003e [!TIP]\n\u003e The new UI add abilities to set which spool is in which tray of the AMS. Also there is a scan button (top right) that allows you to scan a barcode/qrcode on a spool and that will lead to a page where you can set in which tray the spool is.\n\n## Base URL\n\n```\nhttp://\u003cyour-server\u003e:8088\n```\n\n## Environment Variables\n\nThe API requires the following environment variables to be set:\n\n| Variable Name                                | Type          | Example                             | Description                                      |\n| -----------------                            | ------------- | ----------------------------------- | ------------------------------------------------ |\n| APPLICATION__HOMEASSISTANT__URL              | string        | \u003chttps://192.169.1.1:8123\u003e            | The URL to Home Assistant, with portnumber       |\n| APPLICATION__HOMEASSISTANT__TOKEN            | string        |                                     | The Home Assistant Long-lived access token [more info](https://community.home-assistant.io/t/how-to-get-long-lived-access-token/162159/5?u=marcokreeft87)       |\n| APPLICATION__HOMEASSISTANT__AMSENTITIES__0   | string        | X1C_00xxxxxxxxxxxxx_AMS_1           | The Device ID of your AMS, when there are multiples AMS in your configuration just add another var and replace the _0 with_1 and so on       |\n| APPLICATION__HOMEASSISTANT__TRAYENTITIES__0   | string        | X1C_00xxxxxxxxxxxxx_AMS_1_tray_1          | The tray sensors of your AMS trays. If you want to use this, remove APPLICATION__HOMEASSISTANT__AMSENTITIES or leave empty. Same as in AMSENTITIES replace __0 with 1 and so on for more tray sensors    |\n| APPLICATION__HOMEASSISTANT__EXTERNALSPOOLENTITY | string        | sensor.x1x_externalspool_external_spool | The URL to Home Assistant, with portnumber       |\n| APPLICATION__SPOOLMAN__URL                   | string        | \u003chttps://192.169.1.1:7912\u003e             | The URL to Spoolman, with portnumber       |\n\n## Running with Docker\n\n### **Run the container**\n\n```\ndocker run -d -p 8088:8080 \\\n  -e APPLICATION__HOMEASSISTANT__URL=http://homeassistant.local:8123 \\\n  -e APPLICATION__HOMEASSISTANT__TOKEN=your-token \\\n  -e APPLICATION__SPOOLMAN__URL=http://spoolman.local:7912 \\\n  -e APPLICATION__HOMEASSISTANT__AMSENTITIES__0=x1c_ams_1 \\\n  -e APPLICATION__HOMEASSISTANT__EXTERNALSPOOLENTITY=sensor.x1c_external_spool \\\n  --name spoolman-updater spoolman-updater\n```\n\nor\n\n```\ndocker run -d -p 8088:8080 \\\n  -e APPLICATION__HOMEASSISTANT__URL=http://homeassistant.local:8123 \\\n  -e APPLICATION__HOMEASSISTANT__TOKEN=your-token \\\n  -e APPLICATION__SPOOLMAN__URL=http://spoolman.local:7912 \\\n  -e APPLICATION__HOMEASSISTANT__TRAYENTITIES__0=sensor.x1c_ams_1_tray_1 \\\n  -e APPLICATION__HOMEASSISTANT__TRAYENTITIES__1=sensor.x1c_ams_1_tray_2 \\\n  -e APPLICATION__HOMEASSISTANT__TRAYENTITIES__2=sensor.x1c_ams_1_tray_3 \\\n  -e APPLICATION__HOMEASSISTANT__TRAYENTITIES__3=sensor.x1c_ams_1_tray_4 \\\n  -e APPLICATION__HOMEASSISTANT__EXTERNALSPOOLENTITY=sensor.x1c_external_spool \\\n  --name spoolman-updater spoolman-updater\n```\n\n## Using with Home Assistant\n\nThe Spoolman Updater API can be integrated into Home Assistant automations to track filament usage automatically.\n\n### **1. Define a REST Command in `configuration.yaml`**\n\nAdd the following to your `configuration.yaml` to create a REST command that updates the spool:\n\n```yaml\nrest_command:\n  update_spool:\n    url: \"http://\u003cyour-server\u003e:8088/Spools/spool\"\n    method: POST\n    headers:\n      Content-Type: \"application/json\"\n    payload: \u003e\n      {\n        \"name\": \"{{ filament_name }}\",\n        \"material\": \"{{ filament_material }}\",\n        \"tag_uid\": \"{{ filament_tag_uid }}\",\n        \"used_weight\": {{ filament_used_weight | int }},\n        \"color\": \"{{ filament_color }}\",\n        \"active_tray_id\": \"{{ filament_active_tray_id }}\"\n      }\n```\n### **2. Create the sensors**\n\n```yaml\nutility_meter:\n  bambulab_filament_usage_meter:\n    unique_id: 148d1e2d-87b2-4883-a923-a36a2c9fa0ac\n    source: sensor.bambulab_filament_usage\n    cycle: weekly\n\n```\nand \n\n```yaml\nsensor:\n  - platform: template\n    sensors:\n      bambulab_filament_usage:\n        unique_id: b954300e-d3a2-44ab-948f-39c30b2f0c00\n        friendly_name: \"Bambu Lab Filament Usage\"\n        value_template: \"{{ states('sensor.bambu_lab_p1s_gewicht_van_print') | float(0) / 100 * states('sensor.bambu_lab_p1s_printvoortgang') | float(0) }}\"\n        availability_template: \"{% if is_state('sensor.bambu_lab_p1s_gewicht_van_print', 'unknown') or is_state('sensor.bambu_lab_p1s_gewicht_van_print', 'unavailable') %} false {% else %} true {%- endif %}\"\n```\n\nDon't forget to change the sensor ids to your own :)\n\n### **3. Create an Automation**\n\nThe following automation updates the spool when a print finishes or when the AMS tray switches:\n\n```yaml\nalias: Bambulab - Update Spool When Print Finishes or Tray Switches\ndescription: \"\"\ntriggers:\n  - trigger: state\n    entity_id:\n      - sensor.x1c_active_tray_index\nconditions:\n  - condition: template\n    value_template: \"{{ trigger.from_state.state not in ['unknown', 'unavailable'] }}\"\n  - condition: template\n    value_template: \"{{ trigger.from_state.state | int \u003e 0 }}\"\nactions:\n  - variables:\n      tray_number: \u003e-\n        {{ trigger.from_state.state if trigger.entity_id ==\n        'sensor.x1c_active_tray_index' else\n        states('sensor.x1c_active_tray_index') }}\n      tray_sensor: sensor.x1c_00m09c422100420_ams_1_tray_{{ tray_number }}\n      tray_weight: \u003e-\n        {{ states('sensor.bambulab_filament_usage_meter') | float(0) | round(2)\n        }}\n      tag_uid: \"{{ state_attr(tray_sensor, 'tag_uid') }}\"\n      material: \"{{ state_attr(tray_sensor, 'type') }}\"\n      name: \"{{ state_attr(tray_sensor, 'name') }}\"\n      color: \"{{ state_attr(tray_sensor, 'color') }}\"\n  - data:\n      filament_name: \"{{ name }}\"\n      filament_material: \"{{ material }}\"\n      filament_tag_uid: \"{{ tag_uid }}\"\n      filament_used_weight: \"{{ tray_weight }}\"\n      filament_color: \"{{ color }}\"\n      filament_active_tray_id: \"{{ tray_sensor | replace('sensor.', '') }}\"\n    action: rest_command.update_spool\n  - action: utility_meter.calibrate\n    data:\n      value: \"0\"\n    target:\n      entity_id: sensor.bambulab_filament_usage_meter\n\n```\n\nThis automation ensures that the filament usage is automatically updated in Spoolman when a print is completed or the AMS tray is changed.\n\n---\n\n### Setting the active tray in the UI when switching spools\n\nWhen you switch your spool in the AMS, you will need to tell spoolman which tray the new spool is in. You can do this in the UI of Spoolman updater.\nJust go to the base of the URL of the API. So for example if your API url is \u003chttp://192.168.1.1:8088/spools\u003e you go to \u003chttp://192.168.1.1:8088/\u003e\n\n![alt text](image.png)\n\nHere you can set which spool is in which tray.\n\n## Contributing\n\nPull requests are welcome! Please follow the standard GitHub workflow:\n\n1. Fork the repository\n2. Create a feature branch\n3. Submit a pull request\n\n## License\n\nMIT License. See `LICENSE` file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcokreeft87%2Fspoolman-updater","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcokreeft87%2Fspoolman-updater","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcokreeft87%2Fspoolman-updater/lists"}