Zigbee scene switch rule

hi i just bought sigbee scene switch and add thing scene_sw1 with item scene_sw1_button (string) when i press one of 4 buttons it receive state 1_single 2_single etc, now i think i need a rule to :

  1. when i press the button (receive update)
    2 if state = 1_singe and
    3 if pokoj_1 is on send command Pokoj_1(off) if Pokoj_1 is off send command(on) - change state of light01.
    Can somemone help me to start this rule ?

rule “scena2”
Item scena_sw1 received update
if scena_sw1=1_single
if Pokoj_1=On

if scena_sw1=2_single


im too noob to start this :confused:

I strongly recommend using Blockly instead of Rules DSL. You don’t need to know the syntax of the code that way. It’s all just blocks.

If you insist on writing rules in Rules DSL in .rules files, please review the Rules documentation including all the links therein. Don’t just guess at the syntax, you’ll waist a ton of time.

For example, this shows how to create an if statement.

With Blockly, you just need to drag the “if” block over to the page.


thx ill try but for me blocky is strange i dont know when it start the rule like “status update”

Please review https://openhab.org/docs/concepts/rules.html and https://openhab.org/docs/tutorial/rules_blockly.html and return if you still have questions.

OH is large and complex and built upon lots of layers of abstraction. If you skip the docs and fail to understand certain key concepts, you will end up waisting a ton of time in frustration. You are unlikely to be successful if you just jump in and try random stuff.

i know what you tell me :wink: just copy this blocks looks strange for me :wink:

But it works :smiley:

Just i need 16x IF

There are of course alternative approaches that could take less copy and paste. Or at a minimum shorten this a bit.

For example, you can create a function called “toggle” which encapsulates the “if ON send command OFF else send command ON” part.

Then in your if statements all you need to do is call this function with the name of the Item that goes with the scene.


1 Like