mirror of
https://github.com/home-assistant/core
synced 2024-09-06 10:29:55 +02:00
Open Hardware Monitor Sensor reconnect (#28052)
* raise PlatformNotReady * Don't show errors on reconnect
This commit is contained in:
parent
b4054add61
commit
62a3dc1a94
@ -7,6 +7,7 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||||
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
@ -38,6 +39,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
"""Set up the Open Hardware Monitor platform."""
|
"""Set up the Open Hardware Monitor platform."""
|
||||||
data = OpenHardwareMonitorData(config, hass)
|
data = OpenHardwareMonitorData(config, hass)
|
||||||
|
if data.data is None:
|
||||||
|
raise PlatformNotReady
|
||||||
add_entities(data.devices, True)
|
add_entities(data.devices, True)
|
||||||
|
|
||||||
|
|
||||||
@ -130,7 +133,7 @@ class OpenHardwareMonitorData:
|
|||||||
response = requests.get(data_url, timeout=30)
|
response = requests.get(data_url, timeout=30)
|
||||||
self.data = response.json()
|
self.data = response.json()
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
_LOGGER.error("ConnectionError: Is OpenHardwareMonitor running?")
|
_LOGGER.debug("ConnectionError: Is OpenHardwareMonitor running?")
|
||||||
|
|
||||||
def initialize(self, now):
|
def initialize(self, now):
|
||||||
"""Parse of the sensors and adding of devices."""
|
"""Parse of the sensors and adding of devices."""
|
||||||
|
Loading…
Reference in New Issue
Block a user