diff --git a/homeassistant/components/vallox/__init__.py b/homeassistant/components/vallox/__init__.py index ebb1d56cf51..1c8bef1e3d1 100644 --- a/homeassistant/components/vallox/__init__.py +++ b/homeassistant/components/vallox/__init__.py @@ -6,6 +6,7 @@ import logging from vallox_websocket_api import PROFILE as VALLOX_PROFILE, Vallox from vallox_websocket_api.constants import vlxDevConstants +from vallox_websocket_api.exceptions import ValloxApiException import voluptuous as vol from homeassistant.const import CONF_HOST, CONF_NAME @@ -110,9 +111,13 @@ async def async_setup(hass, config): service_handler.async_handle, schema=schema) - # Fetch initial state once before bringing up the platforms. - await state_proxy.async_update(None) - + # The vallox hardware expects quite strict timings for websocket + # requests. Timings that machines with less processing power, like + # Raspberries, cannot live up to during the busy start phase of Home + # Asssistant. Hence, async_add_entities() for fan and sensor in respective + # code will be called with update_before_add=False to intentionally delay + # the first request, increasing chance that it is issued only when the + # machine is less busy again. hass.async_create_task( async_load_platform(hass, 'sensor', DOMAIN, {}, config)) hass.async_create_task( @@ -164,7 +169,7 @@ class ValloxStateProxy: self._profile = await self._client.get_profile() self._valid = True - except OSError as err: + except (OSError, ValloxApiException) as err: _LOGGER.error("Error during state cache update: %s", err) self._valid = False @@ -187,7 +192,7 @@ class ValloxServiceHandler: await self._client.set_profile(STR_TO_PROFILE[profile]) return True - except OSError as err: + except (OSError, ValloxApiException) as err: _LOGGER.error("Error setting ventilation profile: %s", err) return False @@ -201,7 +206,7 @@ class ValloxServiceHandler: {METRIC_KEY_PROFILE_FAN_SPEED_HOME: fan_speed}) return True - except OSError as err: + except (OSError, ValloxApiException) as err: _LOGGER.error("Error setting fan speed for Home profile: %s", err) return False @@ -215,7 +220,7 @@ class ValloxServiceHandler: {METRIC_KEY_PROFILE_FAN_SPEED_AWAY: fan_speed}) return True - except OSError as err: + except (OSError, ValloxApiException) as err: _LOGGER.error("Error setting fan speed for Away profile: %s", err) return False @@ -229,7 +234,7 @@ class ValloxServiceHandler: {METRIC_KEY_PROFILE_FAN_SPEED_BOOST: fan_speed}) return True - except OSError as err: + except (OSError, ValloxApiException) as err: _LOGGER.error("Error setting fan speed for Boost profile: %s", err) return False diff --git a/homeassistant/components/vallox/fan.py b/homeassistant/components/vallox/fan.py index 483d5649c76..bc51e0be61a 100644 --- a/homeassistant/components/vallox/fan.py +++ b/homeassistant/components/vallox/fan.py @@ -42,7 +42,7 @@ async def async_setup_platform(hass, config, async_add_entities, client, hass.data[DOMAIN]['state_proxy']) - async_add_entities([device], update_before_add=True) + async_add_entities([device], update_before_add=False) class ValloxFan(FanEntity): diff --git a/homeassistant/components/vallox/manifest.json b/homeassistant/components/vallox/manifest.json index 1f3042342d5..4f9b0f4d126 100644 --- a/homeassistant/components/vallox/manifest.json +++ b/homeassistant/components/vallox/manifest.json @@ -3,7 +3,7 @@ "name": "Vallox", "documentation": "https://www.home-assistant.io/components/vallox", "requirements": [ - "vallox-websocket-api==2.0.0" + "vallox-websocket-api==2.2.0" ], "dependencies": [], "codeowners": [] diff --git a/homeassistant/components/vallox/sensor.py b/homeassistant/components/vallox/sensor.py index 416d068f9bf..5348c84049e 100644 --- a/homeassistant/components/vallox/sensor.py +++ b/homeassistant/components/vallox/sensor.py @@ -90,7 +90,7 @@ async def async_setup_platform(hass, config, async_add_entities, ), ] - async_add_entities(sensors, update_before_add=True) + async_add_entities(sensors, update_before_add=False) class ValloxSensor(Entity): diff --git a/requirements_all.txt b/requirements_all.txt index 3059ac6ed51..d7f64453b33 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1855,7 +1855,7 @@ uscisstatus==0.1.1 uvcclient==0.11.0 # homeassistant.components.vallox -vallox-websocket-api==2.0.0 +vallox-websocket-api==2.2.0 # homeassistant.components.venstar venstarcolortouch==0.7