1 from Components.Sensors import sensors
3 from enigma import eTimer
5 from Source import Source
7 class SensorSource(Source):
8 def __init__(self, update_interval = 500, sensorid = None):
9 self.update_interval = update_interval
10 self.sensorid = sensorid
13 if sensorid is not None:
14 self.update_timer = eTimer()
15 self.update_timer.callback.append(self.updateValue)
16 self.update_timer.start(self.update_interval)
19 if self.sensorid is not None:
20 return sensors.getSensorValue(self.sensorid)
24 return sensors.getSensorUnit(self.sensorid)
26 def updateValue(self):
27 self.changed((self.CHANGED_POLL,))
30 if self.sensorid is not None:
31 self.update_timer.callback.remove(self.updateValue)