How to use the new Hue Motion Sensors in OH1?

hi @homer , how quick does it detect motion? I want my lights to turn on immediately:)

String HueMotionEvent "Hue Motion Detected [%s]" <present> (Motion, Sensors) { http="<[http://_HueHubIP_/api/_SecretID_/sensors/3:5000:JS(getHueMotionEvent.js)]" }

Second the HUE does not have humidity sensor or? At least not in the API…

And mainly is that I can not get any values from the motion sensor, I defined my sitemap like this :

Frame label="Motion" {
	Text label="Motion" icon="groundfloor"{
		Text item= HueMotionEvent
		Text item= HueMotionEventDate
		Text item= HueLight
		Text item= HueDark
		Text item= HueDay
		Text item= HueTemp icon="temperature"
		
	}
} 

I added the http binding in paper UI, and the json transform, the hue bridge does appear in the hue binding, what am I missing?

The light switches immediately.
The hue has no humidity sensor.
Just to be sure… You have the .map in the transform folder and the transformations javascript / json / map installed?
Sometimes also restarting helps.

Homer

The light switches immediately.

I just saw that you set refresh rate to 5000, so thats why I was confused

The hue has no humidity sensor

I thought maybe it was dht22, and that hue currently in software did not display it.

You have the .map

What should be in the.map file?

javascript / json / map

Yes

Sometimes also restarting helps.

Will do as soon as my GF is gone to bed…

Sorry I meant .js file.
Maybe you can also send your api
/api//sensors
Because I had a difference with the api of iWPL.

If the time for switching is too long you can make the time shorter. I have to admit that I programmed the light with the hue app not with OH for testing. I want to use the motion sensor mainly for temperature, light level for the rollershutters and motion for alarm.

Homer

How short can I make it, without overloading the RPI?

I think mine is the same as yours…
{
“1”: {
“state”: {
“daylight”: null,
“lastupdated”: “none”
},
“config”: {
“on”: true,
“configured”: false,
“sunriseoffset”: 30,
“sunsetoffset”: -30
},
“name”: “Daylight”,
“type”: “Daylight”,
“modelid”: “PHDL00”,
“manufacturername”: “Philips”,
“swversion”: “1.0”
},
“2”: {
“state”: {
“temperature”: 2135,
“lastupdated”: “2017-02-01T21:24:35”
},
“config”: {
“on”: true,
“battery”: 100,
“reachable”: true,
“alert”: “none”,
“ledindication”: false,
“usertest”: false,
“pending”:
},
“name”: “Hue temperature sensor 1”,
“type”: “ZLLTemperature”,
“modelid”: “SML001”,
“manufacturername”: “Philips”,
“swversion”: “6.1.0.18912”,
“uniqueid”: “00:17:88:01:02:03:25:6f-02-0402”
},
“3”: {
“state”: {
“presence”: false,
“lastupdated”: “2017-02-01T20:48:07”
},
“config”: {
“on”: true,
“battery”: 100,
“reachable”: true,
“alert”: “lselect”,
“ledindication”: false,
“usertest”: false,
“sensitivity”: 2,
“sensitivitymax”: 2,
“pending”:
},
“name”: “Hallway sensor”,
“type”: “ZLLPresence”,
“modelid”: “SML001”,
“manufacturername”: “Philips”,
“swversion”: “6.1.0.18912”,
“uniqueid”: “00:17:88:01:02:03:25:6f-02-0406”
},
“4”: {
“state”: {
“lightlevel”: 18774,
“dark”: false,
“daylight”: false,
“lastupdated”: “2017-02-01T21:26:08”
},
“config”: {
“on”: true,
“battery”: 100,
“reachable”: true,
“alert”: “none”,
“tholddark”: 16000,
“tholdoffset”: 7000,
“ledindication”: false,
“usertest”: false,
“pending”:
},
“name”: “Hue ambient light sensor 1”,
“type”: “ZLLLightLevel”,
“modelid”: “SML001”,
“manufacturername”: “Philips”,
“swversion”: “6.1.0.18912”,
“uniqueid”: “00:17:88:01:02:03:25:6f-02-0400”
},
“5”: {
“state”: {
“status”: 0,
“lastupdated”: “2017-02-01T20:48:07”
},
“config”: {
“on”: true,
“reachable”: true
},
“name”: “MotionSensor 3.Companion”,
“type”: “CLIPGenericStatus”,
“modelid”: “PHA_STATE”,
“manufacturername”: “Philips”,
“swversion”: “1.0”,
“uniqueid”: “MotionSensor 3.Companion”,
“recycle”: true
}
}

Now it works… numbers were wrong!!

I will upload all my items, rules, transform etc as soon as i get all setup correctly,

String HueMotionEvent "Hue Motion Detected [%s]" <present> (Group_Motion, Group_Sensors) { http="<[http://192.168.0.xx/api/NBxxxxxxxxxxxxx5OcClIGuPNI8JF2KA440Pr/sensors/3:500:JS(getHueMotionEvent.js)]" }

how can I map motion to a switch instead of string?

(function(i) {
    var json = JSON.parse(i);
    return ((json['state']['presence'])) == true ? "ON" : "OFF";
})(input)

My rule looks like this:

rule "Update bathroom light when motion happens"
when
    Item HueMotion changed from OFF to ON  
then

	if(Light_Bathroom.state == OFF){
		sendCommand(Light_Bathroom,ON)
	}
	
end

Ok good. I would blank out the unique id.
Why would you need the motion on a switch?
If you need an additional switch you can simply add it and make a new rule. Or switch the switch for the light with your rule.

I kinda blanked out the unique id, replaced it with xxxxxxxxxx in there…

I couldnt get my rule to trigger, i am on to it now though… How can i check if a string changes from OFF to ON?

@Homer can you kindly post your .js files?
After hour i got temperature working thanks to your getHueTemp.js!

I am not at home now. But you can see my lightlevel .js above. You can just copy this and replace “lightlevel” with the names in the api clip for example “presence” like in Skatuns file. Maybe that helps for now.

True! I’ve got lightlevel now. I’ll test other parameters in the afternoon. Thank you

@skatun you can type

tail -20 /var/log/openhab2/events.log

this command will show you last 20 events. Of course if you change row number, you’ll get more events.
If you configured correctly your motion sensor, you’ll get events like:

2017-02-04 16:43:29.483 [ItemStateChangedEvent ] - HueMotionEvent changed from OFF to ON

and THEORETICALLY you should trigger something with a rule like:

rule “test”
when
item HueMotionEvent changed to ON
then
var DecimalType hue = new DecimalType(240) // 0-360; 0=red, 40=yellow; 120=green, 240=blue, 360=red(again)
var PercentType sat = new PercentType(100) // 0-100
var PercentType bright = new PercentType(50) // 0-100
var HSBType light = new HSBType(hue,sat,bright)
sendCommand(corr_salotto, light)
end

And that’s the point. Why my rule isn’t firing?
If i trigger the rule with a condition like:

Time cron “*/10 * * * * ?”

each ten seconds the bulb is powered on. Seems event generated by motion sensor isn’t “read” from OH.

Ok just realized that rule is not firing because the item that triggers the event is a STRING and not a switch as in other case in my installation.
Now: i must understand how to trigger from strings :wink:

For me the following rule is working:

rule "Light ON when movement is true"

when 
      Item HueMotionEvent changed
then	
	if (Hue_lamp3.state == OFF && HueMotionEvent.state == "true") {
	sendCommand(Hue_lamp3, ON)
}	
end

Then a time cron to switch off the light after some time…

I have my Hue Motion sensor set up on my OpenHAB2 system as described above. Everything appears to be working fine. The only problem is I am continuously receiving the following error messages in my logs. Can someone tell me where to look to fix it.
Update: I got it working. I was missing the javascript transformation.

==> /var/log/openhab2/openhab.log <==
2017-05-03 16:23:31.234 [WARN ] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type JS
2017-05-03 16:23:31.235 [WARN ] [ab.binding.http.internal.HttpBinding] - couldn't transform response because transformationService of type 'JS' is unavailable
2017-05-03 16:23:31.248 [WARN ] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type JS
2017-05-03 16:23:31.250 [WARN ] [ab.binding.http.internal.HttpBinding] - couldn't transform response because transformationService of type 'JS' is unavailable
2017-05-03 16:23:31.263 [WARN ] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type JS
2017-05-03 16:23:31.264 [WARN ] [ab.binding.http.internal.HttpBinding] - couldn't transform response because transformationService of type 'JS' is unavailable
2017-05-03 16:23:31.277 [WARN ] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type JS
2017-05-03 16:23:31.278 [WARN ] [ab.binding.http.internal.HttpBinding] - couldn't transform response because transformationService of type 'JS' is unavailable
2017-05-03 16:23:36.293 [WARN ] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type JS
2017-05-03 16:23:36.295 [WARN ] [ab.binding.http.internal.HttpBinding] - couldn't transform response because transformationService of type 'JS' is unavailable
2017-05-03 16:23:36.308 [WARN ] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type JS
2017-05-03 16:23:36.309 [WARN ] [ab.binding.http.internal.HttpBinding] - couldn't transform response because transformationService of type 'JS' is unavailable

Maybe there is another thread dealing with this, but as I am working with the Hue stuff - how do I get the time stamp to properly show local summertime/wintertime. Currently I receive UTC from the sensors.

%1$td: day
%1$tm: month
%1$tY: year
%1$tR: time without seconds

Thx

Uwe