greghesp / ha-bambulab

A Home Assistant Integration for Bambu Lab Printers
995 stars 85 forks source link

[Bug] Cannot change from LAN mode to cloud mode ('ConfigEntry' object has no attribute 'get') #380

Closed simonszu closed 10 months ago

simonszu commented 10 months ago

Describe the bug

I have a working LAN mode setup. Due to https://github.com/greghesp/ha-bambulab/issues/174 and myself wanting to set up an Xtouch for my P1S i want to change the integration connection to cloud mode, but after i check the button and click on "Next" i get "Unknown error occurred".

To Reproduce

  1. Add printer via LAN mode
  2. Verify its working
  3. Go to the integration setting page, click on "Configure"
  4. Change the mode from LAN to Cloud
  5. Click "Next"

Expected Behaviour

The next step of the wizard opens and guides me through the cloud setup.

What device are you using?

P1S

Diagnostic Output

Dragging files in does apparently not work with Firefox on MacOS :(

Log Extracts

2023-12-31 18:15:35.721 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 227, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 63, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 234, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 293, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 389, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/bambu_lab/config_flow.py", line 342, in async_step_init
    return await self.async_step_Bambu(None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/bambu_lab/config_flow.py", line 396, in async_step_Bambu
    default_region = self.config_entry.get('region', '') if user_input is None else user_input.get('region', '')
                     ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ConfigEntry' object has no attribute 'get'

Other Information

I had cloud mode successfully set up on an older release of this integration but switched to LAN mode beacuse of the camera sensor not sending any image in this mode. I upgraded to the most recent version with LAN mode enabled.

AdrianGarside commented 10 months ago

Thanks for reporting this. Should be fixed in: https://github.com/greghesp/ha-bambulab/releases/tag/v2.0.4

Please let me know if you hit further issues - testing these configuration transitions is very difficult because it's hard to setup correct starting states.