Skip to content

Commit 4b6e5df

Browse files
author
greigs
committed
run forever, require graceful quit
1 parent 7e06278 commit 4b6e5df

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

disco.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import kasa
33
import random
44

5-
runtimeSeconds = 60 # how long should the disco last? (hint: forever is best)
65
searchTimeout = 10 # default is 5, but this seems more reliable
76

87
async def randomset(bulbs, t):
@@ -21,6 +20,7 @@ async def initBulb(ip):
2120

2221
async def main():
2322
print('Disco time. Searching for Kasa RGB bulbs...')
23+
print('Ctrl + C to exit at any time')
2424

2525
found_devices = await kasa.Discover.discover(timeout=searchTimeout)
2626
bulb_devices = []
@@ -32,10 +32,9 @@ async def main():
3232
if not bulb_devices:
3333
print('No Kasa RGB bulb devices found')
3434
else:
35-
for x in range(1, runtimeSeconds):
35+
while True:
3636
await randomset(bulb_devices, 1_000)
3737
await asyncio.sleep(1)
38-
print('Done')
3938

4039
loop = asyncio.get_event_loop()
4140
try:

0 commit comments

Comments
 (0)