Hue dimmer switch rule not working

Hi all,

I’m using openHab 1.8.
My goal is to turn off multiple lights when a specific button on the hue dimmer switch is pressed.

I’m relatively new to openHAB and I think the problem is the rule I’ve created.

I have the following two items in the items file:

String HueTasteSchlafzimmerZeit "Zeit [%s]" (Wohnzimmer){ http="<[http://-huebridgeip-/api/-SecretID-/sensors/10:2000:JS(HueSwitchDatumTransformation.js)]" }
String HueTasteSchlafzimmerTyp "[%s]" (Wohnzimmer) { http="<[http://-huebridgeip-/api/-SecretID-/sensors/10:2000:JS(HueSwitchTasteTransformation.js)]" }

And the corresponding transformations:


(function(i) {
    var json = JSON.parse(i);
    return json['state']['lastupdated'];


(function(i) {
    var json = JSON.parse(i);
    return json['state']['buttonevent'];

The first item shows the exact time of when the button was pressed the last time.
The second item shows which button has been pressed.

The strings and the transformations work perfectly. I can see the values in the OpenHAB app and they update when i press a button.

Now the rule. I want a simple rule that turns off multiple lights (for the example I used only one bulb) when the OFF button on the dimmer switch is pressed long and then released. (buttonevent = “4003”).

My rule looks like this:

rule "AlleLichterAus"
		item HueTasteSchlafzimmerZeit changed
    if (HueTasteSchlafzimmerTyp == "4003")
	{sendCommand(huewz1, OFF)}

Can anyone help me with this issue?

Thanks in advance for any help.

You must use .state to get the “value” of an Item.

Case matters. The “item” in your when clause should be capitolized.

Also, and this isn’t a problem but something to be aware of. It is better to use the sendCommand methods on Items rather than the sendCommand action.

Therefore your rule should be:

rule "AlleLichterAus"
    Item HueTasteSchlafzimmerZeit changed
    if(HueTasteSchlafzimmerTyp.state.toString == "4003") {

If you are going to have more than one light controlled by this switch, you should put them all into the same Group. Then you can MyLightGroup.sendCommand(OFF) and all members of the Group will get the OFF command. That way you can change which lights are controlled by the switch without ever needing to modify the rule again.

Finally, please please please use Designer. Each and every one of the errors I just pointed out to you would have been identified by Designer before you ever ran the rule.

Thanks for the tipps. It’s working now. I’ve noticed the stupid mistakes a few hours after my post.

I’ve used the Designer, but I’ve used this app only for a few hours now.

Your help is highly appreciated :slight_smile: