1 parent
0100f87ff2
commit
47e31dc9ee
143 files changed
+1584
-1761
No files matched your search
@@ -1,16 +1,21 @@
|
||||
"""Support for Open Hardware Monitor Sensor Platform."""
|
||||
"""
|
||||
Support for Open Hardware Monitor Sensor Platform.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.openhardwaremonitor/
|
||||
"""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
import requests
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.util.dt import utcnow
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -37,7 +42,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the Open Hardware Monitor platform."""
|
||||
"""Set up the Open Hardware Monitor platform."""
|
||||
data = OpenHardwareMonitorData(config, hass)
|
||||
add_devices(data.devices, True)
|
||||
|
||||
@@ -124,9 +129,8 @@ class OpenHardwareMonitorData(object):
|
||||
|
||||
def refresh(self):
|
||||
"""Download and parse JSON from OHM."""
|
||||
data_url = "http://%s:%d/data.json" % (
|
||||
self._config.get(CONF_HOST),
|
||||
self._config.get(CONF_PORT))
|
||||
data_url = "http://{}:{}/data.json".format(
|
||||
self._config.get(CONF_HOST), self._config.get(CONF_PORT))
|
||||
|
||||
try:
|
||||
response = requests.get(data_url, timeout=30)
|
||||
@@ -135,7 +139,7 @@ class OpenHardwareMonitorData(object):
|
||||
_LOGGER.error("ConnectionError: Is OpenHardwareMonitor running?")
|
||||
|
||||
def initialize(self, now):
|
||||
"""Initial parsing of the sensors and adding of devices."""
|
||||
"""Parse of the sensors and adding of devices."""
|
||||
self.refresh()
|
||||
|
||||
if self.data is None:
|
||||
@@ -173,11 +177,7 @@ class OpenHardwareMonitorData(object):
|
||||
fullname = ' '.join(child_names)
|
||||
|
||||
dev = OpenHardwareMonitorDevice(
|
||||
self,
|
||||
fullname,
|
||||
path,
|
||||
unit_of_measurement
|
||||
)
|
||||
self, fullname, path, unit_of_measurement)
|
||||
|
||||
result.append(dev)
|
||||
return result
|
||||
Reference in new issue
Block a user