From f858938adad94439c9d333be5fc70d31b2ec4c94 Mon Sep 17 00:00:00 2001 From: mrosseel Date: Mon, 10 Sep 2018 16:19:17 +0200 Subject: [PATCH] Make the Qnap sensor more resilient if server is not reachable (#16445) * add CONF_ALLOW_UNREACHABLE option, retry connection if allowed * fix linting errors * Removing the config option, just using PlatformNotReady --- homeassistant/components/sensor/qnap.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/sensor/qnap.py b/homeassistant/components/sensor/qnap.py index 29eb8cd6749..a6a9c6e30d0 100644 --- a/homeassistant/components/sensor/qnap.py +++ b/homeassistant/components/sensor/qnap.py @@ -15,6 +15,7 @@ from homeassistant.const import ( CONF_HOST, CONF_USERNAME, CONF_PASSWORD, CONF_PORT, CONF_SSL, ATTR_NAME, CONF_VERIFY_SSL, CONF_TIMEOUT, CONF_MONITORED_CONDITIONS, TEMP_CELSIUS) from homeassistant.util import Throttle +from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv REQUIREMENTS = ['qnapstats==0.2.7'] @@ -107,14 +108,9 @@ def setup_platform(hass, config, add_entities, discovery_info=None): api = QNAPStatsAPI(config) api.update() + # QNAP is not available if not api.data: - hass.components.persistent_notification.create( - 'Error: Failed to set up QNAP sensor.
' - 'Check the logs for additional information. ' - 'You will need to restart hass after fixing.', - title=NOTIFICATION_TITLE, - notification_id=NOTIFICATION_ID) - return False + raise PlatformNotReady sensors = []