For/While Loops?

Just to emphasize @rlkoshak 's point, in most cases with timer-scheduled actions and non-trivial timer-lengths, you WILL want to check something(s) at execution-time of the timer’s command, i.e. , the sendCommand clause (usually), viz,

timer = createTimer(now.plusSeconds(10)) [|
        sendCommand(LampBedRoom, OFF)
        ]

Search for “PROXY” or see this discussion Patterns/Proxy/Etc for multiple examples.