1
mirror of https://github.com/home-assistant/core synced 2024-07-27 18:58:57 +02:00

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

View File

@ -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."""