Hue Motion Sensor and Node Red?

I’ve got a Phillips Hue Motion Sensor that I’d like to use for a flow in Node Red, but it’s not as straightforward as I’d initially thought it would be. I’m starting with just a simple sensor to switch on a light.

What Node should I be using for the sensor, and what should I use for the output - string, or boolean? I’ve trying ‘events:state’ node for the sensor, feeding into a ‘call service’ node for the light, but can’t make sense of the logic.

Also, if the sensor is triggered, does it automatically reset, or does it need to be done programmatically?

I’d be grateful if users of this sensor with Node Red could let me know their working setup, please.
Jim

It is very straight forward. You use the events_state node to catch the event of the sensor. This you then connect to the call_service node where you call the service to turn on your light.
When you have made this connection work, you can start making more complicated things (like different service calls when the sensor is on/off).

Can you post your current not working flow please?

Thanks for the reply ‘AlmostSerious’.

What’s the approved way of posting a Node Red flow, please?

Jim

I recommend marking your flow in NodeRed, then click on Export.
After that, scrub it with this tool of your HomeAssistant Server:

Then post it with 3x

`

in front and 3x

`

after the code.

1 Like

Thanks for the reply.
Here’s the code I’m struggling with. I want a light to come on for 10 seconds if motion is detected after sunset, and motion detection go off at dawn. It seems that the ‘eztimer’ settings are ignored, with the motion detected signal passing straight through, regardless as to whether it’s sunset or not.

[{"id":"16d45c1a.b3db7c","type":"tab","label":"Motion Detector Test","disabled":false,"info":""},{"id":"dca4a7e0.77f6d8","type":"api-call-service","z":"16d45c1a.b3db7c","name":"Lohas Bulb2 On","version":1,"debugenabled":true,"service_domain":"light","service":"turn_on","entityId":"light.lohas_bulb2","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":580,"y":220,"wires":[[]]},{"id":"6e898821.44b57","type":"server-state-changed","z":"16d45c1a.b3db7c","name":"Motion Sensor","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.hue_motion_sensor_2_motion","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":130,"y":240,"wires":[["d65e036d.9ac66"],["1511c8a0.11de87"]]},{"id":"536d60e0.64ba7","type":"api-call-service","z":"16d45c1a.b3db7c","name":"Lohas Bulb2 off","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.lohas_bulb2","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":580,"y":280,"wires":[[]]},{"id":"1511c8a0.11de87","type":"trigger","z":"16d45c1a.b3db7c","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"10","extend":false,"units":"s","reset":"","bytopic":"all","outputs":1,"x":370,"y":280,"wires":[["536d60e0.64ba7"]]},{"id":"d65e036d.9ac66","type":"eztimer","z":"16d45c1a.b3db7c","name":"Sunset","debug":false,"autoname":"sunsetStart - dawn","tag":"eztimer","suspended":false,"sendEventsOnSuspend":false,"timerType":"1","startupMessage":false,"ontype":"1","ontimesun":"sunsetStart","ontimetod":"17:00","onpropertytype":"msg","onproperty":"payload","onvaluetype":"str","onvalue":"on","onoffset":0,"onrandomoffset":0,"onsuppressrepeats":false,"offtype":"1","offtimesun":"dawn","offtimetod":"dusk","offduration":"00:01:00","offpropertytype":"msg","offproperty":"payload","offvaluetype":"str","offvalue":"off","offoffset":0,"offrandomoffset":0,"offsuppressrepeats":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":360,"y":220,"wires":[["dca4a7e0.77f6d8"]]}]

I’d be very grateful for any advice, please.
Jim

From what I can see, you need to put in your coordinated into the EZTimer. However, in your case it might be easier to just use the time range node. Also @ timerange you need to put your coordinates.
If you simply want the light to turn off 10sec after being triggered, you may also just connect it to the same time range node. Instead of a trigger node, you should probably use the delay node.
Please see below:

[{"id":"a01a594c.311b48","type":"api-call-service","z":"39f6a24a.c420be","name":"Lohas Bulb2 On","version":1,"debugenabled":true,"service_domain":"light","service":"turn_on","entityId":"light.lohas_bulb2","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":620,"y":200,"wires":[[]]},{"id":"def9da8e.4be0c8","type":"server-state-changed","z":"39f6a24a.c420be","name":"Motion Sensor","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.hue_motion_sensor_2_motion","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":150,"y":200,"wires":[["79b23bfa.4af504"],[]]},{"id":"257690b8.04e1d","type":"api-call-service","z":"39f6a24a.c420be","name":"Lohas Bulb2 off","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.lohas_bulb2","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":780,"y":260,"wires":[[]]},{"id":"79b23bfa.4af504","type":"time-range-switch","z":"39f6a24a.c420be","name":"","startTime":"sunsetStart","endTime":"dawn","startOffset":"","endOffset":"","x":370,"y":200,"wires":[["a01a594c.311b48","7d7296b9.25fc28"],[]]},{"id":"7d7296b9.25fc28","type":"delay","z":"39f6a24a.c420be","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":600,"y":260,"wires":[["257690b8.04e1d"]]}]
2 Likes

Thanks Marcus - very helpful.
Jim