Increase timeout for setup of rfxtrx (#43003)

* Increase timeout and remove reload

* Use asyncio.TimeoutError

* Remove import

* Add logging

* Minor tweak

* Fix black

* Update homeassistant/components/rfxtrx/__init__.py

Co-authored-by: Joakim Plate <elupus@ecce.se>
This commit is contained in:
Rob Bierbooms 2020-11-10 00:30:15 +01:00 committed by GitHub
parent 5541721899
commit f09004acf5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,7 +36,6 @@ from homeassistant.const import (
VOLT,
)
from homeassistant.core import callback
from homeassistant.exceptions import ConfigEntryNotReady
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.restore_state import RestoreEntity
@ -191,7 +190,14 @@ async def async_setup_entry(hass, entry: config_entries.ConfigEntry):
hass.data[DOMAIN][DATA_CLEANUP_CALLBACKS] = []
await async_setup_internal(hass, entry)
try:
await async_setup_internal(hass, entry)
except asyncio.TimeoutError:
# Library currently doesn't support reload
_LOGGER.error(
"Connection timeout: failed to receive response from RFXtrx device"
)
return False
for domain in DOMAINS:
hass.async_create_task(
@ -263,11 +269,8 @@ async def async_setup_internal(hass, entry: config_entries.ConfigEntry):
config = entry.data
# Initialize library
try:
async with async_timeout.timeout(5):
rfx_object = await hass.async_add_executor_job(_create_rfx, config)
except asyncio.TimeoutError as err:
raise ConfigEntryNotReady from err
async with async_timeout.timeout(30):
rfx_object = await hass.async_add_executor_job(_create_rfx, config)
# Setup some per device config
devices = _get_device_lookup(config[CONF_DEVICES])