Open the closed Rollershutter after Window opens


i want, that a closed rollershutter opens, after i opened the window.
And if i close the Window again, the rollershutter should also close again.

With my actual Knowledge, this will be a massiv rule.

I would make a rule for each Window to merge the contact with the right rollershutter.

Is there another possebility to make a logical Connection between a contakt and the Rollershutter?

i hope you can give me some advices.


The logic is quite simple:

rule "Window state changed"
    Item MyWindow changed
    if(MyWindow.state ==OPEN) MyRollerShutter.sendCommand(UP)
    else MyRollerShutter.sendCommand(DOWN)

By applying the design patterns you can make this generic for lots of windows.

rule "A window state changed"
    Item Window_1 changed or
    Item Window_2 changed or
    val winNum ="_").get(1)
    var cmd = if(triggeringItem.state == OPEN)  ON else OFF
    sendCommand("Rollershutter_"+winNum, cmd)

Thanks for Reply.

Do i have to put all contacts in a Group (and command “when Group Change”), or each Window contact?

But how do my items have to look like?
Now all my Items have different Names not Numbers.

for example:

Contact Kontakt_SZ_gekippt “Schlafzimmer gekippt” (OG_Schlafzimmer, Kontakt)

Rollershutter Rollo_OG_Schlafzimmer “Rollo Schlafzimmer” (OG_Schlafzimmer, Rollo)

Do i have to put a number after each item?

I don´t understand how the value winNum with the"_").get(1) command has to look like, to make my rollershutter go up and down.

I acually don´t understand what the command do, so i don´t understand the whole rule.

Sorry for beeing annoying, but now i have many and partially big rules and i think, after i know how rules with design Patterns works that would be much easier.

i hope you can help me.

thx a lot

To use triggeringItem you must (for now) put each Item as a separate trigger.

To use the second more generic Rule you have to name your Items so that you can parse the name (the split above) and use the result to build the name of the other associated Item. See the Design Pattern link for details.

Again, see the link to the DP. It is all explained there.

Thanks for help.

I renamend now 2 items just to the test rule.

Rollershutter Rollershutter_19
Contact Kontakt_19

and here your rule:

    Item Kontakt_19 changed

    val winNum ="_").get(1)
    var cmd = if(triggeringItem.state == OPEN)  ON else OFF
    sendCommand("Rollershutter_"+winNum, cmd)

But i get an error at triggeringItem (cannot be resolved to an item or type)

And if the Type cmd at the sendcommand is without quotes i get the error:

cannot convert from OnOffType to String

what i am doing wrong?


Are you running OH 2.2?

I made an upgrade and now i am running 2.2.

Now i get different error:

An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(java.lang.String,java.lang.String) on instance: null

Add some logging to make sure that “Rollershutter_”+winNum is actually the correct name for your Rollershutter Item.

the values are correct. It seems that a space is missing.

But to insert a space didn´t work.
Do you have an advise?

Here ist the log entry:

2018-02-22 18:46:17.623 [DEBUG] [clipse.smarthome.model.script.rollok] - Rollershutter_19UP


Show your current code

Here it is:

    Item Kontakt_19 changed


    val winNum ="_").get(1)
    var cmd = if(triggeringItem.state == OPEN)  UP else DOWN
    logDebug("rollok","Rollershutter_"+winNum + cmd)
    sendCommand("Rollershutter_"+winNum, cmd)

To get the space in the log you need to actually add a space.

logDebug("rollok","Rollershutter_"+winNum + " " + cmd)

And as with the ON/OFF, put the UP/DOWN in quotes:

val cmd = if(triggeringItem.state == OPEN)  "UP" else "DOWN"

The quotes at UP and Down was the Problem.

Now the rule works, big thanks for your help.

But there is still al litte Problem.
If the rollershutter is up and i open a window, the rollershutter is closing, after i Close the window again.
But the rule should match only when the rollershutter is closed.

How do i get the actual rollershutterstate with the calculated winNUM?

I´ll tried out (although it will not work) to put a && with the rollershutter + winNum after i query the open state of the window.

Here is the rule i tried out. (according to the log cmd is sending “null”)

    Item Kontakt_1 changed or
    Item Kontakt_2 changed or
    Item Kontakt_3 changed or
    Item Kontakt_4 changed or
    Item Kontakt_5 changed or
    Item Kontakt_6 changed or
    Item Kontakt_7 changed or
    Item Kontakt_8 changed or
    Item Kontakt_9 changed or
    Item Kontakt_10 changed or
    Item Kontakt_11 changed or
    Item Kontakt_12 changed or
    Item Kontakt_13 changed or
    Item Kontakt_14 changed

    val winNum ="_").get(1)
    var cmd = if(triggeringItem.state == OPEN && "Rollo_" +winNum == DOWN)  "UP" else "DOWN"
    sendCommand("Rollo_"+winNum, cmd)

i hope you can help me one more time.


Change the rule to:

  val winNum ="_").get(1)
  if (triggeringItem.state == OPEN && "Rollo_"+winNum == DOWN)
    sendCommand("Rollo_"+winNum, UP)

This rule only sends the UP-command if the roller shutter is down and the window opens.
If you shut the window, nothing happens.


yes, but i need both.

The rule, should recognize the rollershutter state.
So if the rollershutter was closed before, it should close again, after the window is closing again.
If the rollershutter is up nothing should happen.

Is that possible?

My Workaround would be, to Close the rollershutter (after the rule match) after 5 minutes anyway with a sleep command.

But this is not my preferred configuration.


This if command doesn´t match - it seems that the state DOWN is not recogniced.
I tried the value decimal, number, string but nothing works.

The rule never fires.

How do i get the actual state of a rollershutter?
My Rollershuter actuator sends active the state in decimal (so 100 is DOWN and 0 UP) but also sends DOWN and UP.

OH also Shows the right state in the Log Files, but how can i query the state in the rule?

best regards

"Rollo_"+winNum+".state" == DOWN


thanks for help, but i was not able to get a state out of the changing winNum.

So i solved it with a different way.
That woks fine, but you have to make one rule for each window/rollershutter.

It looks like this:

rule "open Rollershutter with contact "

	Item Kontakt_1 changed
	if 		(Kontakt_1.state == OPEN && Rollo_1.state == 100){             /*If the rollershutter is down and the window opens*/
			Rollo_Dummy_1.sendCommand(ON)}                                    /*you have to make a dummy item each rollershutter to store the value*/
	if 		(Kontakt_1.state == CLOSED && Rollo_Dummy_1.state == ON) {    /*if the dummy value is "on" the Rollershutter is Closing again*/
			Rollo_Dummy_1.sendCommand(OFF)		                                    /*The value reset  to Off*/	              

I have also a rule to open all Rollershutters in the morning a the same time.
With that rule i also reset all Rollershutter Dummy states to OFF (e.g Rollo_Dummy_1.sendCommand(OFF) Rollo_Dummy_2.sendCommand(OFF) so on…)

So wrong values would not be stored.

Best regards