Question on JS rule builder

Hello. I would like to trigger a certain KNX scene whenever an “ON” command is received on a certain item. I would like to use the JS rule builder.

Now I can use changed().toOn(), but I believe that this does not trigger the scene repeatedly when the state is ON already - yet this is what I want.

I can use receivedCommand() but then how can I access the command (ON/OFF) that was actually received? Is there support for this?

Restricting the command trigger to specific commands is possible:

rules.when().item(/* Item name*/).receivedCommand().toOn().then(() => {
  // do stuff

Instead of toOn() you can also use to(), with the command as argument.

1 Like

Ah great, let me try that! Thanks!

1 Like