Open Hardware Monitor Sensor reconnect (#28052)

* raise PlatformNotReady

* Don't show errors on reconnect
This commit is contained in:
Nikolay Vasilchuk 2019-10-23 09:17:34 +03:00 committed by Paulus Schoutsen
parent b4054add61
commit 62a3dc1a94
1 changed files with 4 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.exceptions import PlatformNotReady
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
@ -38,6 +39,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Open Hardware Monitor platform."""
data = OpenHardwareMonitorData(config, hass)
if data.data is None:
raise PlatformNotReady
add_entities(data.devices, True)
@ -130,7 +133,7 @@ class OpenHardwareMonitorData:
response = requests.get(data_url, timeout=30)
self.data = response.json()
except requests.exceptions.ConnectionError:
_LOGGER.error("ConnectionError: Is OpenHardwareMonitor running?")
_LOGGER.debug("ConnectionError: Is OpenHardwareMonitor running?")
def initialize(self, now):
"""Parse of the sensors and adding of devices."""