working with callbacks

This commit is contained in:
Øyvind Saltvik 2012-08-10 19:25:24 +02:00
parent 517c987b6d
commit 9073d60858
3 changed files with 162 additions and 121 deletions

View file

@ -6,7 +6,7 @@ telldus.tdInit()
devices = telldus.tdGetNumberOfDevices()
print "Devices: %d\n" % devices
allMethods = telldus.TELLDUS_TURNON | telldus.TELLDUS_TURNOFF | telldus.TELLDUS_BELL | telldus.TELLDUS_DIM
allMethods = telldus.TELLSTICK_TURNON | telldus.TELLSTICK_TURNOFF | telldus.TELLSTICK_BELL | telldus.TELLSTICK_DIM
for i in xrange(devices):
deviceid = telldus.tdGetDeviceId(i)
@ -16,27 +16,35 @@ for i in xrange(devices):
methods = telldus.tdMethods(deviceid, allMethods)
if methods & telldus.TELLDUS_TURNON:
if methods & telldus.TELLSTICK_TURNON:
print " * TurnOn\n"
telldus.tdTurnOn(deviceid)
time.sleep(1)
if methods & telldus.TELLDUS_TURNOFF:
if methods & telldus.TELLSTICK_TURNOFF:
print " * TurnOff\n"
telldus.tdTurnOff(deviceid)
time.sleep(1)
if methods & telldus.TELLDUS_BELL:
if methods & telldus.TELLSTICK_BELL:
echo " * Bell\n"
telldus.tdBell(deviceid)
time.sleep(1)
if methods & telldus.TELLDUS_TOGGLE:
if methods & telldus.TELLSTICK_TOGGLE:
print " * Toggle\n"
if methods & telldus.TELLDUS_DIM:
if methods & telldus.TELLSTICK_DIM:
print " * Dim\n"
telldus.tdDim(deviceid, 128)
time.sleep(1)
telldus.tdClose()
telldus.tdClose()
import time
time.sleep(30)
for i in xrange(20):
telldus.tdTurnOn(3)
telldus.tdTurnOff(3)