tdsensor
This commit is contained in:
parent
71e13196f3
commit
d6fcd4a5dc
3 changed files with 104 additions and 12 deletions
28
bindings/python/native/example/poll.py
Normal file
28
bindings/python/native/example/poll.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
import telldus
|
||||
|
||||
telldus.tdInit()
|
||||
|
||||
while(1):
|
||||
result = telldus.tdSensor()
|
||||
if not result:
|
||||
break
|
||||
else:
|
||||
protocol, model, sensorId = result
|
||||
print "%s,\t%s,\t%i\n" % (protocol, model, sensorId)
|
||||
|
||||
# Retrieve the values the sensor supports
|
||||
if (dataTypes & telldus.TELLSTICK_TEMPERATURE):
|
||||
result = telldus.tdSensorValue(protocol, model, sensorId, telldus.TELLSTICK_TEMPERATURE)
|
||||
if result:
|
||||
value, timestamp = result
|
||||
print "Temperature:\t%sº\t(%s)\n" % (value, str(timestamp))
|
||||
|
||||
if (dataTypes & telldus.TELLSTICK_HUMIDITY):
|
||||
result = telldus.tdSensorValue(protocol, model, sensorId, telldus.TELLSTICK_HUMIDITY)
|
||||
if result:
|
||||
value, timestamp = result
|
||||
print "Humidity:\t%s\t(%s)\n" % (value, str(timestamp))
|
||||
|
||||
print "\n"
|
||||
|
||||
tdClose();
|
Loading…
Add table
Add a link
Reference in a new issue