HTTP Refreshrate and how to compare strings in rules

Hi, I have a hue motion sensor, unfortunately this is not implemnted in a binding yet, which means it does not push notifications when its triggered, instead I need to call it all the time, so how often can I call it?
every 1000ms? Seems like my RPI struggles with more frequent updates, and 1s is long time to wait for light to go on…

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

how can I map motion to a contact instead of string, how todo this?

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

Can I somehow make the detection angle smaller of the sensor(like tape parts of the reflector?)?

So my rule that does not work because the motion sensor is a string and not contact is:

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

This should work:

item

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

transform

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

rule

rule "Update bathroom light when motion happens"
when
    Item HueMotion changed from CLOSED to OPEN
then
	if (Light_Bathroom.state == OFF) {
		Light_Bathroom.sendCommand(ON)
	}
	
end
1 Like

What about the refresh rate, how can I pull motion from 6 motion sensor with high speed without overloading the pi?
Can we read the length of the reply instead, if it changes then run json parsing? (false and true differs by 1 character)

Or is it an url to get deeper down in the hue bridge…
http="<[http://192.168.0.xx/api/NBxxxxxxxxxxxxxxxcxxxKA440Pr/sensors/3/

Polling is going to be unsatisfactory if the binding can be imoroved to support sensors without polling. I doubt that polling more frequently than once per second will work very well due to the overhead. Also, by default the HTTP binding’s granularity is one second, so that would also have to be shortened. I would instead suggest to see if anything could be done to help the binding properly support the feature.

@watou In Habmin it states the huemotion item as NULL, are you sure you can map string “OPEN”/“CLOSED” to a contact item?

I updated the HTTP binding in November to allow it update any item type (even though Contact items were I think already supported). If you are using an older version of the HTTP binding, you might want to upgrade it to the 1.9.0 release version or later.

Installed it yesterday through paperUI, so should be latest iteration…

Got it to work! Thanks, was a typo, it is a bit unstable, but good enough for now… I hope they will integrate it in the hue binding at some point…

Hi, what did you do to get it work?

Regards. PJH