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

Hi Norman,

I think it depends on the way how a Number item stores the value internally. It uses a data type to represent integer and decimals in the same way.

Hi Christoph,

Well, thanks for the explanation. I changed my Item declaration to String for the buttonstate and lastupdate (instead of Number and DateTime). I also changed the JS script, so the value given back is a string:

return parseInt(json["state"]["buttonevent"]).toString();

Now it is working as expected again. I am still a total newbie with all this, so it is “learning by doing”. Please tell me if I did something totally wrong or if there’d be another, better solution.

Oh, I forgot, the Luminance from the Motion sensor also gives a very large number like 44.9676301176907 - I assume this is because of the conversion from the raw value to lux. Any idea how to round it to a simple Integer which can then be handled in rules? It is not very important for the rule itself but it sizes up the log files and makes it more complex and slower to calculate in rules internally.

You can use the Math.round() method (see my second post for an example) in both cases. I can give you some hints, you have to decide what’s the best way for your purpose.

Hi Christoph,

Thanks, I’ll try the math function, must have overlooked it somehow. Have a nice sunday.


A brave .toFixed() did the job, values are now as expected (ger.: kurz und knackig)

Sounds good. You’re welcome. Have a nice Sunday too.

Works great, but why not incorporating bidirectional using the http binding (as for the readings) to monitor as well deactivation of a sensor e.g. by third-party hue apps?

Of course. That should be possible. Feel free to post an updated example.

I will feel free, if I find some time during the next days ;-). In between, maybe someone could give me a hint, if a HTTP POST will do the job as well, since the HTTP binding seems to support only POSTs but not PUTs.

Ok, I did half the way:
Defining an Item

Switch BathRoomMotionSensorStatus { http="<hueMotionSensorPresence:3000:JS(getHueMotionStatus.js)]" }

and using the following script for getHueMotionStatus.js

(function(i) {
    var json = JSON.parse(i);
    return ((json['config']['on'])) == true ? "ON" : "OFF";

does the job for external updates. Did not check so far how to setup PUT outputs with the http binding

If I use this with a hue motion sensor to trigger an action would there be a delay?

Yes, there will be a delay with at least the amount of milliseconds specified in the updateInterval of the HTTP cache item (max. 5000ms in my example).

So this is essentially polling every 5 seconds? Would it ever be possible to push events from the hue bridge?

That is true. But you can change it to a lower frequency if you like.

Yes, after we found a volunteer to solve it.

@cweitkamp When you refer to <id>, do you mean uniqueid? Not sure I know which string I need.

I’m new at this but want to learn…thanks for this helpful post.

it’s the capability ID of the HUE sensor:



1 Like

Thank you @KurtS!

Not sure I get how to enable/make sure this is “active”.

Hi Julio,

The complete HowTo is based an those cached items. If you will follow it you will use them automatically.

I will add some example responses to my the tutorial. I will keep you posted.

Will it be too much to ask if you could post a sample rule using these services/items/transforms? :blush:

I’m so new at this that I am now struggling with how to write the rule that triggers when motion is detected so I can send a Pushover a notification (I’ve already configured the Pushover action).