diff options
| author | thedoc <thedoc@atom.(none)> | 2009-12-11 13:01:26 +0100 |
|---|---|---|
| committer | thedoc <thedoc@atom.(none)> | 2009-12-11 13:01:26 +0100 |
| commit | 28dcf6be0ee22fedd728fef11ccff484f8a851e8 (patch) | |
| tree | 6fe8005db1e02409975316859c7a407a489f1f50 /lib/python/Components/Sources/Sensor.py | |
| parent | f239e0373a40522e9d3121bbe656e91fb6179099 (diff) | |
| parent | 74378b3ebe7dc0548cb4e4b6a0d54b0e871c0264 (diff) | |
| download | enigma2-28dcf6be0ee22fedd728fef11ccff484f8a851e8.tar.gz enigma2-28dcf6be0ee22fedd728fef11ccff484f8a851e8.zip | |
Merge branch 'fantempplugin' into experimental
Diffstat (limited to 'lib/python/Components/Sources/Sensor.py')
| -rw-r--r-- | lib/python/Components/Sources/Sensor.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/python/Components/Sources/Sensor.py b/lib/python/Components/Sources/Sensor.py new file mode 100644 index 00000000..e927bbf4 --- /dev/null +++ b/lib/python/Components/Sources/Sensor.py @@ -0,0 +1,31 @@ +from Components.Sensors import sensors + +from enigma import eTimer + +from Source import Source + +class SensorSource(Source): + def __init__(self, update_interval = 500, sensorid = None): + self.update_interval = update_interval + self.sensorid = sensorid + Source.__init__(self) + + if sensorid is not None: + self.update_timer = eTimer() + self.update_timer.callback.append(self.updateValue) + self.update_timer.start(self.update_interval) + + def getValue(self): + if self.sensorid is not None: + return sensors.getSensorValue(self.sensorid) + return None + + def getUnit(self): + return sensors.getSensorUnit(self.sensorid) + + def updateValue(self): + self.changed((self.CHANGED_POLL,)) + + def destroy(self): + if self.sensorid is not None: + self.update_timer.callback.remove(self.updateValue) |
