sbidy / wiz_light

A WiZ Light integration for Home Assistant
MIT License
341 stars 68 forks source link

UnboundLocalError because of previous exception #213

Closed sbidy closed 2 years ago

sbidy commented 2 years ago

https://github.com/sbidy/wiz_light/blob/ff9167d7d510ab944122355eb0552ed22b0370ab/custom_components/wiz_light/config_flow.py#L47

If bulb is not reachable at setup.

homeassistant    | 2021-12-16 21:29:28 ERROR (MainThread) [aiohttp.server] Error handling request
homeassistant    | Traceback (most recent call last):
homeassistant    |   File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
homeassistant    |     resp = await request_handler(request)
homeassistant    |   File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
homeassistant    |     resp = await handler(request)
homeassistant    |   File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
homeassistant    |     return await handler(request)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
homeassistant    |     return await handler(request)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 220, in forwarded_middleware
homeassistant    |     return await handler(request)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
homeassistant    |     return await handler(request)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
homeassistant    |     return await handler(request)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 181, in auth_middleware
homeassistant    |     return await handler(request)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle
homeassistant    |     result = await result
homeassistant    |   File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 157, in post
homeassistant    |     return await super().post(request, flow_id)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper
homeassistant    |     result = await method(view, request, *args, **kwargs)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
homeassistant    |     result = await self._flow_mgr.async_configure(flow_id, data)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 252, in async_configure
homeassistant    |     result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 325, in _async_handle_step
homeassistant    |     result: FlowResult = await getattr(flow, method)(user_input)
homeassistant    |   File "/config/custom_components/wiz_light/config_flow.py", line 47, in async_step_user
homeassistant    |     await self.async_set_unique_id(mac)
homeassistant    | UnboundLocalError: local variable 'mac' referenced before assignment
bdraco commented 2 years ago

This can be closed as its confirmed fixed in the core version