Fix missing async for lutron_caseta timeout (#45812)

This commit is contained in:
J. Nick Koston 2021-01-31 23:15:20 -10:00 committed by GitHub
parent 91a54eecb3
commit e0bf18986b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -104,16 +104,16 @@ async def async_setup_entry(hass, config_entry):
hostname=host, keyfile=keyfile, certfile=certfile, ca_certs=ca_certs hostname=host, keyfile=keyfile, certfile=certfile, ca_certs=ca_certs
) )
except ssl.SSLError: except ssl.SSLError:
_LOGGER.error("Invalid certificate used to connect to bridge at %s.", host) _LOGGER.error("Invalid certificate used to connect to bridge at %s", host)
return False return False
timed_out = True timed_out = True
try: try:
with async_timeout.timeout(BRIDGE_TIMEOUT): async with async_timeout.timeout(BRIDGE_TIMEOUT):
await bridge.connect() await bridge.connect()
timed_out = False timed_out = False
except asyncio.TimeoutError: except asyncio.TimeoutError:
_LOGGER.error("Timeout while trying to connect to bridge at %s.", host) _LOGGER.error("Timeout while trying to connect to bridge at %s", host)
if timed_out or not bridge.is_connected(): if timed_out or not bridge.is_connected():
await bridge.close() await bridge.close()

View File

@ -228,19 +228,19 @@ class LutronCasetaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
) )
except ssl.SSLError: except ssl.SSLError:
_LOGGER.error( _LOGGER.error(
"Invalid certificate used to connect to bridge at %s.", "Invalid certificate used to connect to bridge at %s",
self.data[CONF_HOST], self.data[CONF_HOST],
) )
return False return False
connected_ok = False connected_ok = False
try: try:
with async_timeout.timeout(BRIDGE_TIMEOUT): async with async_timeout.timeout(BRIDGE_TIMEOUT):
await bridge.connect() await bridge.connect()
connected_ok = bridge.is_connected() connected_ok = bridge.is_connected()
except asyncio.TimeoutError: except asyncio.TimeoutError:
_LOGGER.error( _LOGGER.error(
"Timeout while trying to connect to bridge at %s.", "Timeout while trying to connect to bridge at %s",
self.data[CONF_HOST], self.data[CONF_HOST],
) )