Fix broken tellstick and systemmonitor sensors

This commit is contained in:
Paulus Schoutsen 2015-03-21 22:26:41 -07:00
parent 49d7901585
commit ec557f8d44
2 changed files with 10 additions and 2 deletions

View File

@ -50,7 +50,7 @@ class SystemMonitorSensor(Entity):
self.argument = argument
self.type = sensor_type
self._state = None
self.unit_of_measurement = SENSOR_TYPES[sensor_type][1]
self._unit_of_measurement = SENSOR_TYPES[sensor_type][1]
self.update()
@property
@ -62,6 +62,10 @@ class SystemMonitorSensor(Entity):
""" Returns the state of the device. """
return self._state
@property
def unit_of_measurement(self):
return self._unit_of_measurement
def update(self):
if self.type == 'disk_use_percent':
self._state = psutil.disk_usage(self.argument).percent

View File

@ -99,7 +99,7 @@ class TellstickSensor(Entity):
def __init__(self, name, sensor, datatype, sensor_info):
self.datatype = datatype
self.sensor = sensor
self.unit_of_measurement = sensor_info.unit or None
self._unit_of_measurement = sensor_info.unit or None
self._name = "{} {}".format(name, sensor_info.name)
@ -112,3 +112,7 @@ class TellstickSensor(Entity):
def state(self):
""" Returns the state of the device. """
return self.sensor.value(self.datatype).value
@property
def unit_of_measurement(self):
return self._unit_of_measurement