mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
fixed style errors
This commit is contained in:
parent
b42b680ef5
commit
828c78cb1f
@ -12,7 +12,7 @@ from homeassistant.const import (
|
|||||||
import psutil
|
import psutil
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
sensor_types = {
|
SENSOR_TYPES = {
|
||||||
'disk_use_percent': ['Disk Use', '%'],
|
'disk_use_percent': ['Disk Use', '%'],
|
||||||
'disk_use': ['Disk Use', 'GiB'],
|
'disk_use': ['Disk Use', 'GiB'],
|
||||||
'disk_free': ['Disk Free', 'GiB'],
|
'disk_free': ['Disk Free', 'GiB'],
|
||||||
@ -24,31 +24,32 @@ sensor_types = {
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Sets up the sensors """
|
""" Sets up the sensors """
|
||||||
|
|
||||||
devices = []
|
dev = []
|
||||||
for resource in config['resources']:
|
for resource in config['resources']:
|
||||||
if 'arg' not in resource:
|
if 'arg' not in resource:
|
||||||
resource['arg'] = ''
|
resource['arg'] = ''
|
||||||
if resource['type'] not in sensor_types:
|
if resource['type'] not in SENSOR_TYPES:
|
||||||
_LOGGER.error('Sensor type: "%s" does not exist', resource['type'])
|
_LOGGER.error('Sensor type: "%s" does not exist', resource['type'])
|
||||||
else:
|
else:
|
||||||
devices.append(SystemMonitorSensor(resource['type'], resource['arg']))
|
dev.append(SystemMonitorSensor(resource['type'], resource['arg']))
|
||||||
|
|
||||||
add_devices(devices)
|
add_devices(dev)
|
||||||
|
|
||||||
|
|
||||||
class SystemMonitorSensor(Device):
|
class SystemMonitorSensor(Device):
|
||||||
""" A system monitor sensor """
|
""" A system monitor sensor """
|
||||||
|
|
||||||
def __init__(self, type, argument=''):
|
def __init__(self, type, argument=''):
|
||||||
self._name = sensor_types[type][0] + ' ' + argument
|
self._name = SENSOR_TYPES[type][0] + ' ' + argument
|
||||||
self.argument = argument
|
self.argument = argument
|
||||||
self.type = type
|
self.type = type
|
||||||
self._state = None
|
self._state = None
|
||||||
self.unit_of_measurement = sensor_types[type][1]
|
self.unit_of_measurement = SENSOR_TYPES[type][1]
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user