mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Allow scrape sensor to retry setting up platform if initial setup fails (#19498)
This commit is contained in:
parent
30841ef4da
commit
3a3d488de3
@ -17,6 +17,7 @@ from homeassistant.const import (
|
|||||||
CONF_PASSWORD, CONF_AUTHENTICATION, HTTP_BASIC_AUTHENTICATION,
|
CONF_PASSWORD, CONF_AUTHENTICATION, HTTP_BASIC_AUTHENTICATION,
|
||||||
HTTP_DIGEST_AUTHENTICATION)
|
HTTP_DIGEST_AUTHENTICATION)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['beautifulsoup4==4.6.3']
|
REQUIREMENTS = ['beautifulsoup4==4.6.3']
|
||||||
@ -73,8 +74,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
rest.update()
|
rest.update()
|
||||||
|
|
||||||
if rest.data is None:
|
if rest.data is None:
|
||||||
_LOGGER.error("Unable to fetch data from %s", resource)
|
raise PlatformNotReady
|
||||||
return False
|
|
||||||
|
|
||||||
add_entities([
|
add_entities([
|
||||||
ScrapeSensor(rest, name, select, attr, value_template, unit)], True)
|
ScrapeSensor(rest, name, select, attr, value_template, unit)], True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user