Use lux level to turn on light

I am starting with using Node Red in HA just today. I got a fibaro dimmer unit and a fibaro multisensor. I have a flow which turn on the light when the sensor senses movement and turns the light off after 10 minutes of no movement.

No I want to add a second part and that it only turn the light on when the lux leven of the sensor i below a certan value. I tried a trigger and a current_state block but cannot get it working. Can some one point me in the right direction ?

I know the trigger is not connected, but it is just for showing what block I tried.

Use a trigger-state node with the constraints motion is on and lux < min value.

[{"id":"c019fd50.0aa82","type":"trigger","z":"5eb3594f.d294b8","op1":"","op2":"{\"service\": \"turn_off\"}","op1type":"nul","op2type":"json","duration":"10","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":454,"y":1664,"wires":[["c4182203.1f63c"]]},{"id":"c4182203.1f63c","type":"api-call-service","z":"5eb3594f.d294b8","name":"","server":"ef067c6f.620e6","service_domain":"homeassistant","service":"turn_on","data":"{\"entity_id\":\"light.light\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":664,"y":1616,"wires":[[]]},{"id":"f9982d5c.12412","type":"trigger-state","z":"5eb3594f.d294b8","name":"","server":"ef067c6f.620e6","entityid":"binary_sensor.motion","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"nbuicl2lbff","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"},{"id":"neh75y7uqrg","targetType":"entity_id","targetValue":"sensor.lux","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"<","comparatorValueDatatype":"num","comparatorValue":"60"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":220,"y":1616,"wires":[["c4182203.1f63c","c019fd50.0aa82"],[]]}]

The above might produce a weird result if the light being on makes the lux sensor go above the threshold and the light would still turn off even if there is movement.

[{"id":"e4115216.aaf69","type":"server-state-changed","z":"5eb3594f.d294b8","name":"","server":"ef067c6f.620e6","entityidfilter":"binary_sensor.motion","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is_not","outputs":2,"output_only_on_state_change":false,"x":182,"y":1744,"wires":[["13812865.e1dba8","581c7a10.cf2b74"],[]]},{"id":"13812865.e1dba8","type":"api-current-state","z":"5eb3594f.d294b8","name":"","server":"ef067c6f.620e6","outputs":2,"halt_if":"60","halt_if_type":"num","halt_if_compare":"gte","override_topic":false,"entity_id":"sensor.lux","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","x":494,"y":1744,"wires":[["82676daf.33ff2"],[]]},{"id":"82676daf.33ff2","type":"api-call-service","z":"5eb3594f.d294b8","name":"","server":"ef067c6f.620e6","service_domain":"homeassistant","service":"turn_on","data":"{\"entity_id\":\"light.light\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":776,"y":1744,"wires":[[]]},{"id":"581c7a10.cf2b74","type":"trigger","z":"5eb3594f.d294b8","op1":"","op2":"{\"service\": \"turn_off\"}","op1type":"nul","op2type":"json","duration":"10","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":502,"y":1792,"wires":[["82676daf.33ff2"]]}]

I new to node red and maybe I think wrong. I am testing this flow:
image
I got this setting on the current_state item image

I would thought if the lux level would be below 10 I would get the debug msg 1 and if its above 10 I would get a debug msg 2. But I always get a debug msg 2.

Update the home-assistant nodes you have a version where half if logic isn’t fully loaded which could be causing the error