Rule for Fibaro WallPlug Color depending on state of windows - need help

I am playing around with a few topics, where I need some help.
My idea: when one or more windows are open, the color of one of my Fibaro wall plugs (the one next to the main entrance) should turn red. If all windows are closed it should turn green.
I have a group gWindows that contains all 11 Homematic window sensors. So now I need a rule that looks something like this:

Rule WallPlugColor-Windows-State

When “number of gWindows state=open”=0
set zwave:device:b791f207:node2:config_decimal_param41 to 5 /
//LED ring colour when device is ON; 5=green
Set zwave:device:b791f207:node2:config_decimal_param42 to 5
//LED ring colour when device is OFF

Else if
Then set zwave:device:b791f207:node2:config_decimal_param41 to 4
//LED ring colour when device is ON; 4=red
Set zwave:device:b791f207:node2:config_decimal_param42 to 4
//LED ring colour when device is OFF


Can anyone help me with building that rule?

First you need to create Items. Or if you have simple mode enabled you already have Items created for you. They will match the Thing’s Channel ID with the “:” replaced with “_”.

I’m assuming that config_decimal_param41 is a Channel listed in the Thing in PaperUI. If it is a parameter setting on the device then what you want to do is not possible I think.

How have you defined your Group? It should either be a Group:Number or a Group:Contact.

You will trigger the Rule on changes to gWindows. Inside the Rule check the state of the Group and if the state and send the proper command to the Items based on the state of the Group.

For proper syntax, please see

I think it’s not possible, you can’t change a parameter by rule. The only thing you can, is turn on or of the light (there’s a channel for this).

I hope it is possible with OpenHab. So far I am running most of my Fibaro/Z-Wave devices with the Fibaro HC2. I want to move all the devices over to OH2. With the Fibaro HC2 it is possible with setting up a virtual device to change the colour triggered by conditions in a scene (rule). I just struggel with writing rules in OH. On the Fibaro platform they have an excellent graphical editor to create rules. And there it is possible to convert these rules to LUA (which is the language) and add/modify the code to enhance the rule in a way that ist not possible with the graphical editor. This helped me a lot to get familiar with LUA.

Thanks Rich! I am impressed by the huge number of your answers!!!
This gives me a little bit better understanding of how to write a rule.
You are right. i just cope the config_decimal_param41 from another Wall Plug Thing where I haven´t added the item so far. I am not using the simple mode.
For the Groupe gFenster (means windows) I have set Base Type to “none”. Should I set up something different. Sorry for these beginner questions.

Assuming all the members are Contacts you would use

Group:Contact:OR(OPEN,CLOSED) gFenster

This will set gFenster is any one of the members are OPEN. Otherwise gFenster we’ll be closed.

In the Rule you can then

if(gFenster.state == OPEN) // at least one window is open

I think there is a way based on the direction @rikoshak pointed out: I have a FGWP102, exposing param41 and param42 (“LED ring colour when device is is on” and “…off” respectively, as channels of type number. Setting both channels in a rule would indicate the window state as desired, independently of the switched device.
I own a FGWP101 also, exposing the corresponding params 61 and 62 as channels as well. I don’t make use of these channels myself, but the fact they are defined should make it possible as intended by the OP.

@Knallfrosch, I had a bit of time and dabbled with this. And it worked as expected.
As an example I’ve created items for my wall plug:

Number Schlafen_Steckdose_Farbe_wenn_ein  "Schlafen Steckdose Farbe wenn eingeschaltet"  { channel="zwave:device:abcdefgh:node35:config_decimal_param41" }
Number Schlafen_Steckdose_Farbe_wenn_aus  "Schlafen Steckdose Farbe wenn ausgeschaltet"  { channel="zwave:device:abcdefgh:node35:config_decimal_param42" }
Number Schlafen_Steckdose_Farbe_Alarm     "Schlafen Steckdose Farbe bei Z-Wave-Alarm"    { channel="zwave:device:abcdefgh:node35:alarm_power"}

Using these items the rule looks like this:

rule "test fibaro wall-plug color-ring ON"
      Item TEST changed from OFF to ON
        sendCommand(Schlafen_Steckdose_Farbe_Alarm, 1)
        sendCommand(Schlafen_Steckdose_Farbe_wenn_ein, 5)
        sendCommand(Schlafen_Steckdose_Farbe_wenn_aus, 5)

rule "test fibaro wall-plug color-ring OFF"
        Item TEST changed from ON to OFF
        sendCommand(Schlafen_Steckdose_Farbe_Alarm, 1)
        sendCommand(Schlafen_Steckdose_Farbe_wenn_ein, 4)
        sendCommand(Schlafen_Steckdose_Farbe_wenn_aus, 4)

The setting for the “alarm_power” channel, repesented by item “Schlafen_Steckdose_Farbe_Alarm”, affects the way the LED ring controls the colors. Only when set to 1, the color will be set according to the color you set by the other two items. As this is a basic setting that needs to be done only once, the command shown here is better placed in an initialization rule at startup. I left it as part of the rules here for clarity.

For testing I used an artificial switch named TEST and put that on my sitemap, but only to avoid triggering rules that react to my real windows switches. Where TEST is used in my example, you would test for the status of “gFenster” (assuming you followed rikoshaks advise):

        Item gFenster changed from OPEN to CLOSED

There is a caveat: You can switch off illumination of the LED ring entirely as a basic setting on the plug itself. If this is done, the rules will have no effect. Refer to the manual to change that.

1 Like