Maintenance 2nd (#4106)
* Add link to docs * Fix link * Update line breaks * Update ordering * Align vera platofrm to only use add_devices (instead od add_devices_callback) * Remove line break * Use consts * Update ordering * Update ordering * Use const, create default name, use string formatting * Update ordering * Use const * Update import style * Update ordering and line breaks * update line breaks * Set default port * Set defaults and update ordering * Update ordering * Minor style updates * Update ordering, defaults, line breaks, and readability * Use constants * Add line breaks * use string formatting * Update line breaks * Update logger
This commit is contained in:
1 parent
e6ece4bf6d
commit
9f2aae1357
28 files changed
+272
-271
No files matched your search
@@ -9,7 +9,8 @@ import logging
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (CONF_RESOURCES, STATE_OFF, STATE_ON)
|
||||
from homeassistant.const import (
|
||||
CONF_RESOURCES, STATE_OFF, STATE_ON, CONF_TYPE)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
import homeassistant.util.dt as dt_util
|
||||
@@ -43,7 +44,7 @@ SENSOR_TYPES = {
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Optional(CONF_RESOURCES, default=['disk_use']):
|
||||
vol.All(cv.ensure_list, [vol.Schema({
|
||||
vol.Required('type'): vol.In(SENSOR_TYPES),
|
||||
vol.Required(CONF_TYPE): vol.In(SENSOR_TYPES),
|
||||
vol.Optional('arg'): cv.string,
|
||||
})])
|
||||
})
|
||||
@@ -56,7 +57,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
for resource in config[CONF_RESOURCES]:
|
||||
if 'arg' not in resource:
|
||||
resource['arg'] = ''
|
||||
dev.append(SystemMonitorSensor(resource['type'], resource['arg']))
|
||||
dev.append(SystemMonitorSensor(resource[CONF_TYPE], resource['arg']))
|
||||
|
||||
add_devices(dev)
|
||||
|
||||
@@ -66,7 +67,7 @@ class SystemMonitorSensor(Entity):
|
||||
|
||||
def __init__(self, sensor_type, argument=''):
|
||||
"""Initialize the sensor."""
|
||||
self._name = SENSOR_TYPES[sensor_type][0] + ' ' + argument
|
||||
self._name = '{} {}'.format(SENSOR_TYPES[sensor_type][0], argument)
|
||||
self.argument = argument
|
||||
self.type = sensor_type
|
||||
self._state = None
|
||||
|
||||
Reference in new issue
Block a user