parent
a12fa0383b
commit
0382d628a3
|
@ -71,10 +71,11 @@ class HueBridge:
|
||||||
|
|
||||||
async def async_initialize_bridge(self) -> bool:
|
async def async_initialize_bridge(self) -> bool:
|
||||||
"""Initialize Connection with the Hue API."""
|
"""Initialize Connection with the Hue API."""
|
||||||
|
setup_ok = False
|
||||||
try:
|
try:
|
||||||
async with asyncio.timeout(10):
|
async with asyncio.timeout(10):
|
||||||
await self.api.initialize()
|
await self.api.initialize()
|
||||||
|
setup_ok = True
|
||||||
except (LinkButtonNotPressed, Unauthorized):
|
except (LinkButtonNotPressed, Unauthorized):
|
||||||
# Usernames can become invalid if hub is reset or user removed.
|
# Usernames can become invalid if hub is reset or user removed.
|
||||||
# We are going to fail the config entry setup and initiate a new
|
# We are going to fail the config entry setup and initiate a new
|
||||||
|
@ -95,6 +96,9 @@ class HueBridge:
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
self.logger.exception("Unknown error connecting to Hue bridge")
|
self.logger.exception("Unknown error connecting to Hue bridge")
|
||||||
return False
|
return False
|
||||||
|
finally:
|
||||||
|
if not setup_ok:
|
||||||
|
await self.api.close()
|
||||||
|
|
||||||
# v1 specific initialization/setup code here
|
# v1 specific initialization/setup code here
|
||||||
if self.api_version == 1:
|
if self.api_version == 1:
|
||||||
|
|
Loading…
Reference in New Issue