ah - the colon. You'd think I might know that trick by now.
The colon enabled the script. However, it revealed a new issue. The script not only didn't execute the last line and turn the device off, the script seems to be constantly running, watching the device: it won't let me turn it off.. When I independently turn the light off, it comes back on. I had to stop the server to be able to turn the light off..
It was my understanding that once the 'while' condition was met, the script would stop. Instead, I need some way to exit the while loop. Perhaps I could do that with an If statement? There must me some elegant way to exit the loop.
- Code: Select all
import time
while not dev.onState:
indigo.device.turnOn(21376882)
time.sleep(2)
indigo.device.turnOff(21376882)