working with callbacks
This commit is contained in:
parent
517c987b6d
commit
9073d60858
3 changed files with 162 additions and 121 deletions
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue