Movement sensor with lux condition

I have a movement sensor who controls the lightning.
but i want a condition that says if the lightning level is above 300 lux, the lightning will not turn on.
does anybody have a good script for this?
This will work fine. Paste this inside the sensor switch object, change those group addresses which are marked 'x/x/x'.

value = event.getvalue() -- Value of current object
LUX = grp.getvalue('x/x/x') -- change this to group address of your LUX sensor

if (value == false) then -- turns off the light
     grp.write('x/x/x', false) -- Change this to your light object group address

if (value == true  and LUX < 300) then -- condition to turn the light on when level of LUX is under 300.
     grp.write('x/x/x', true) -- Also change this to your light group address object

Also, if you are by any chance using Auro by Basalte, you don't need script at all, everything can be set-up in your ETS project.

Forum Jump: