HowTo: Use Philips Hue sensors (Motion Sensor / Dimmer Switch)


I bought myself a Hue motion sensor, for the measurement of the ambiant light.
Unfortunatly Openhab is unable to find the sensor.

When I look on the Openhab Docs it states it is supported and this tutorial confirms this.

I am running OH2.3 Stable and updated the system through the openhabian-config tool.
Unfortunatly it didn’t help.
I’ve got the feeling the binding should be version 2.4 but is still 2.4, did the update fail or aren’t bindings updated until there is a new 2.4.0 stable version?

I found and testen a 0.10.0.jar version downloaded via a link somewhere in this thread.
But this is a test version, if I.m correct and doesn’t work with my version.

If I need version 2.4.0 binding, where can I find the update file and is it correct that it is just a drop of a .jar file into the addons folder?

Thank you for your help.


Hi Edwin,

The new feature will be part of OH 2.4 which will be released in a few days (December 17th). The linked version (.jar file) will not work with OH2.3. If you cannot wait any longer I recommend to update to a milestone or snapshot version.

This is a great thread that helped me to use my Hue sensors in openhab 2.3.

Now with openhab 2.4 the Hue sensors are supported by the Hue binding and sensors are auto-discovered.

Maybe this should be added to the start of the main post.


Hello Christoph, thank you for this awesome enhancement. :slightly_smiling_face: I’ve installed snapshot version yesterday.

Everything works great. I have two “Hue Motion Sensors” and one “Hue Dimmer Switch”.

Unfortunately there is a little error in Documentation


DateTime MotionSensorLastUpdate   { channel="hue:0107:motion-sensor:last_update" }

You missed a “d” in the word “last_updated”, so it should be:

DateTime MotionSensorLastUpdate   { channel="hue:0107:motion-sensor:last_updated" }

One hint for “Hue Dimmer Switch”:

I’ve created a transformation, with the following content:

1001=Button(ON) HOLD
2001=Button(DIM UP) HOLD
3001=Button(DIM DOWN) HOLD
4001=Button(OFF) HOLD

and the corresponding item looks like:

Number 		HueDimmerSwitchButton		"Hue Dimmer Switch Button pressed [MAP(]"	{ channel="hue:0820:xxxxxxxxxxxx:15:dimmer_switch" }

Now button state is “readable”.


1 Like

Thanks for the hint. I will take care of that.

Great map. Just in case: here you can find an example on how to use the dimmer_switch_event in a rule.

1 Like

I’m trying to get rid of the “.0” behind the events received from the Tap and Dimmer switches. (@cweitkamp: may I suggest to fix that in the binding? :smiley:)

This is my first attempt at using a profile to transform a value received, so I may have misinterpreted the OH2 documentation here.

The file content:

16=Button TopLeft
17=Button BottomLeft
34=Button TopRight
18=Button BottomRight

The Item with a transform profile:

String TS_Kitchen "Tap kitchen" (gKitchen) {channel="hue:0830:xxxxxxxxxxxx:tap_kitchen:tap_switch" [profile="transform:MAP", function="", sourceFormat="%.0f"]}

To be sure, I’ve also tried with sourceFormat="%d", but it always generates an error stating it cannot transform:

[al.profiles.MapTransformationProfile] - Could not transform state '16.0' with function '' and format '%.0f'

It looks like the map transform function is called before the source format function. Or… what am I missing here?

Yes, of course. Unfortunately this is part of OH2.4 stable thus it will be a breaking change.

Personally I would omit the “sourceFormat” in this case.

Indeed, it works without sourceFormat parameter and a transform of for instance ‘16.0=xxx’. It makes me wonder how sourceFormat is supposed to work, but that’s no topic for this Philips Hue sensors thread.

I get that, but I hope it can become part of 2.5 (and of course you could introduce a ‘legacy’ parameter if you want to go all fancy… :sunglasses:).

I just noticed: when starting OH the last Dimmer and Tap events are fired again, just like the button was pressed.

:10.356 [INFO ] [el.script.HUErule.DimmerSwitch.Event] - HUE Dimmer switch event hue:0820:xxxxxxxxxxxx:dim_hall:dimmer_switch_event triggered 4003.0
:10.356 [INFO ] [el.script.HUErule.DimmerSwitch.Event] - HUE Dimmer switch event hue:0820:xxxxxxxxxxxx:dim_bedright:dimmer_switch_event triggered 4002.0
:10.357 [INFO ] [el.script.HUErule.DimmerSwitch.Event] - Dimmer Button 4 short released
:10.357 [INFO ] [el.script.HUErule.DimmerSwitch.Event] - Dimmer Button 4 long released
:10.357 [INFO ] [el.script.HUErule.DimmerSwitch.Event] - Dimmer Button 4 short released
:10.358 [INFO ] [model.script.HUErule.TapSwitch.Event] - HUE Tap Remote switch event hue:0830:xxxxxxxxxxxx:tap_kitchen:tap_switch_event triggered 17.0
:10.359 [INFO ] [model.script.HUErule.TapSwitch.Event] - Tap Button 2 triggered
:10.359 [INFO ] [el.script.HUErule.DimmerSwitch.Event] - HUE Dimmer switch event hue:0820:xxxxxxxxxxxx:dim_toilet:dimmer_switch_event triggered 4002.0
:10.360 [INFO ] [el.script.HUErule.DimmerSwitch.Event] - Dimmer Button 4 short released
:10.360 [INFO ] [el.script.HUErule.DimmerSwitch.Event] - HUE Dimmer switch event hue:0820:xxxxxxxxxxxx:dim_outdoor:dimmer_switch_event triggered 4003.0
:10.363 [INFO ] [el.script.HUErule.DimmerSwitch.Event] - Dimmer Button 4 long released
:10.359 [INFO ] [el.script.HUErule.DimmerSwitch.Event] - HUE Dimmer switch event hue:0820:xxxxxxxxxxxx:dim_bedleft:dimmer_switch_event triggered 4002.0
:10.365 [INFO ] [el.script.HUErule.DimmerSwitch.Event] - Dimmer Button 4 short released
:10.364 [INFO ] [model.script.HUErule.TapSwitch.Event] - HUE Tap Remote switch event hue:0830:xxxxxxxxxxxx:tap_dining:tap_switch_event triggered 34.0
:10.370 [INFO ] [model.script.HUErule.TapSwitch.Event] - Tap Button 1 triggered

This could lead to unexpected behaviour, for instance when a button was pressed last night and another event/trigger changed the lights in the mean time.

My dimmer switch items are type number and not string…

I see. Nice catch. That happened because the Hue API does not forget. During restart of OH2 the item’s values are NULL and after the first polling of the API they change to last known state.

Question is what can we do? I have a possible solution in my mind. As we are aware of the polling interval we can check against the last_updated timestamp and dispatch the event only if the difference is lower than the polling interval (or twice the polling interval). Wdyt?

I currently have no Items defined for the Tap and Dimmer switches, only rules that trigger when a button press/release event fires. I’m still in testing phase… :grin:

The messages shown are generated in the rule with a logInfo function call based on a switch statement.

IMHO a check against twice (or even three times to be very very safe) the polling interval should do the trick. This is a special case and (re)starting OH or loading the binding does not happen in such a short timeframe.

thank you for the dimmer switch and motions sensor feature in the Hue Binding.

I’m trying to use the Hue motion sensor in a room to turn on the lights. This is my rule (thank’s to rlkoshak):

var Timer timer = null

rule "Flur Bewegungsmelder"
    Item Flur_MotionSensorPresence received update
    if(timer === null || timer.hasTerminated) {
        logInfo("Motion Flur", "Bewegung erkannt -> Licht an")
        timer = createTimer(now.plusSeconds(30), [ |
            timer = null
            logInfo("Motion Flur", "Seit 30 Sekunden keine Bewegung mehr erkannt -> Licht aus")
    else {
        logInfo("Motion Flur", "Bewegung erneut erkannt -> Timer verlängert ")

This is a part of my openhab log file:

2019-01-19 19:56:51.906 [vent.ItemStateChangedEvent] - Flur_MotionSensorPresence changed from OFF to ON
2019-01-19 19:56:51.908 [INFO ] [e.smarthome.model.script.Motion Flur] - Bewegung erkannt -> Licht an
2019-01-19 19:56:51.908 [ome.event.ItemCommandEvent] - Item 'FlurSchalter' received command ON
2019-01-19 19:57:21.910 [INFO ] [e.smarthome.model.script.Motion Flur] - Seit 30 Sekunden keine Bewegung mehr erkannt -> Licht aus
2019-01-19 19:57:21.911 [ome.event.ItemCommandEvent] - Item 'FlurSchalter' received command OFF
2019-01-19 19:57:31.184 [vent.ItemStateChangedEvent] - Flur_MotionSensorPresence changed from ON to OFF
2019-01-19 19:57:31.184 [INFO ] [e.smarthome.model.script.Motion Flur] - Bewegung erkannt -> Licht an
2019-01-19 19:57:31.185 [vent.ItemStateChangedEvent] - Flur_MotionSensorLastUpdate changed from 2019-01-19T19:56:51.000+0100 to 2019-01-19T19:57:31.000+0100
2019-01-19 19:57:31.186 [ome.event.ItemCommandEvent] - Item 'FlurSchalter' received command ON
2019-01-19 19:58:01.187 [INFO ] [e.smarthome.model.script.Motion Flur] - Seit 30 Sekunden keine Bewegung mehr erkannt -> Licht aus

My problem is, at 19:56:51 I moved at the room and the light turned on. Im moved around a bit for 20 seconds to update the timer. Then I left the room, but ten seconds (19:57:21) later the light turned off. After this I didn’t went back to the room.

I’m a little bit confused…

1 Like

Hi Sebastian,

What happens if you stay longer than 30 seconds in the room? Will the light remain on? From my personal feeling you somehow should consider the current state of the Flur_MotionSensorPresence item because a rule triggered by received updated will be invoked for every update independently if it is ON or OFF or whatever.

1 Like

Hi Christoph,
Thank’s for your help. . When I stay longer in the room, the light will turn off after the first 30 seconds.

But I think if I want to use ON as trigger (“changed to ON”) it won’t work, because when I move around in the room the item won’t change to OFF and then ON…

Is that the goal you want to reach? I guess not. Please correct me if I am wrong but I would wrap up your user-story like this: “When someone enters the room (motion detected) -> turn the lights on, after everyone leaves the room (no motion detected) -> wait 30s, then turn the lights off.”?

Thus I propose to check for the current states of Flur_MotionSensorPresence. When it changed to ON send ON to your lights, When it changed to OFF start timer, and so on.

1 Like

Thank you. This is exactly what I want to do.

I’ll try it and post the result here.

// Update:

This are my new rules:

var Timer timer = null
rule "Flur Motion Sensor ON" 
    Item Flur_MotionSensorPresence changed from OFF to ON
    if(timer === null || timer.hasTerminated) {
        timer = null
        logInfo("Motion Flur", "Bewegung erkannt -> Licht an")
    else {
        timer = null

rule "Flur Motion Sensor OFF"
    Item Flur_MotionSensorPresence changed from ON to OFF
    logInfo("Motion Flur", "Keine Bewegung mehr erkannt -> Timer gestellt")
    timer = createTimer(now.plusSeconds(10), [ |
        timer = null
        logInfo("Motion Flur", "Timer abgelaufen -> Licht aus")

I hope it will work :wink:

By the way: is it possible to implement Hue scenes in a future version?

Looks nice. I would add an timer.cancel in the rule for OFF to ON.

Definitely , Yes. But my priority is to start working on the group support first.

1 Like