[SOLVED] Switch On for 10 second

I need to turn on the switch1 for 10 seconds, them switch off. My rule is switch 1 - time after 10, next after 1 sec. Does anyone know how to write a procedure? I’m not a programmer :frowning_face:

My rule is

rule “switch1ON10”


Item switch1 received command





Not sure if I get your question completely, but the fundamental issue is that you are creating a loop here:
Item switch1 received a command, then you want 10 seconds (or you sleep actually, way worse: Why have my Rules stopped running? Why Thread::sleep is a bad idea) and then you send a command again to switch 1, which then receives a command, waits 10 seconds, sends another command, and so on…

I’m guessing, but that is just guessing, that you want something like this:

rule "switch1ON10"
    Item switch1 received command ON
    createTimer(now.plusSeconds(10))[| switch1.sendCommand(OFF) ]

Thanks, your syntax works :slight_smile:

That’s even easier if you don’t want to use a rule.