Skip to content

fix crash when HMS error fires before device is registered (X2D)#2019

Open
WrathPak wants to merge 1 commit into
greghesp:mainfrom
WrathPak:fix-hms-error-none-device
Open

fix crash when HMS error fires before device is registered (X2D)#2019
WrathPak wants to merge 1 commit into
greghesp:mainfrom
WrathPak:fix-hms-error-none-device

Conversation

@WrathPak
Copy link
Copy Markdown

@WrathPak WrathPak commented May 24, 2026

ran into this on my X2D. when it throws an HMS code right as HA is connecting, _update_printer_error blows up because the device isn't in the registry yet so hadevice is None:

File "/config/custom_components/bambu_lab/coordinator.py", line 748, in _update_printer_error
    "device_id": hadevice.id,
                 ^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'id'

_update_print_error has the same hadevice.id pattern so i added a guard there too. if the device lookup comes back None i just log + return and let the next cycle handle it once it's registered. error's gone for me after this.

timing thing mostly, my X2D had a pending HMS code (0300_2E00_...) on startup so it hit every reconnect. didn't dig into why the X2D specifically registers later than the error arrives but the None guard seemed like the safe fix regardless of model.

lmk if you'd rather handle it differently but wanted to take a stab at helping :)

my X2D throws AttributeError: 'NoneType' object has no attribute 'id'
in _update_printer_error when it fires an HMS code during the initial
connect, before the device is registered in HA. same pattern in
_update_print_error. just bail out of those two if hadevice is None.
@docs-page
Copy link
Copy Markdown

docs-page Bot commented May 24, 2026

To view this pull requests documentation preview, visit the following URL:

docs.page/greghesp/ha-bambulab~2019

Documentation is deployed and generated using docs.page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant