mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
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
This commit is contained in:
parent
e96635b5c1
commit
f858938ada
@ -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.<br />'
|
||||
'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 = []
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user