Using a below value in a template motion sensor

I want the motion sensor that turns on and off lights in the hallway to only turn on the lights if it's less than 300 lux outside, measured by a motion sensor outside on the same side as the hallway.

I can get the value in this template:

{{states("sensor.bevegelsessensor_ute_mellom_garasjen_og_hytta_illuminance") | float(0)}}

I just don't know how to get from there to use it as a condition in this motion sensor (that is triggered if the motion sensor light is activated with the boolean and any one sensor in the group "all motion sensors" in the hall is triggered)

{{ ('on' in states('input_boolean.bevegelsesstyrt_lys_i_ganga')) and ('on' in states('binary_sensor.alle_bevegelsessensorer_i_ganga')) and **('if the light outside is less than 300 lux')** }}

Can somebody please help me?

Mmm... Simply

... and states('sensor.bevegelsessensor_ute_mellom_garasjen_og_hytta_illuminance')  | float(0) < 300

Or I miss something in your question

No, you don't miss anything. Thank you! I should have understood that myself, but my head wasn't working right, I guess... :grin: