working examples feature complete

This commit is contained in:
Øyvind Saltvik 2012-08-10 20:37:16 +02:00
parent 9073d60858
commit c5c64435cf
4 changed files with 70 additions and 88 deletions

View file

@ -2,27 +2,27 @@ 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"
while True:
result = telldus.tdSensor()
if not result:
break
else:
protocol, model, sensorId, dataTypes = result
print "Protocol: %s,\tModel: %s,\tSensorId: %i\nDataTypes: %i" % (protocol, model, sensorId, dataTypes)
tdClose()
# 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%sC\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"
telldus.tdClose()