Motion , Light sensor and colour


im super new to home assistant and the node red flows so please forgive my absolute noobishness. This is my very ever first automation in node red . Please be kind lol.

i THINK i have created something that i couldn’t find elsewhere and im hoping that it either A helps people or B someone can maybe explain an easier way to do this and if the desired actions work.

I have a Hue sensor in what i call “the computer room”.

when i walk in to the room and motion is detected then it should check…

if its light then the light should stay off regardless of motion (by lux value)
if its dark the light comes on ( by lux value)
if its dark and its between 7am and 11pm the light is bright else its dimmed .

if i walk into the room and its light but i close the curtains which causes a sudden change in light value then the light must come on immediately if motions detected ( which it should as im in the room ) and vise versa, if the curtains are closed and the light levels suddenly change then the lights turn off instantly.

i have done it this way because i found that if u walk in the room and “motion is detected” and i shut the blinds but the motion still says “detected” then it wont turn the light on. It will only change once it goes to “clear” then back to detected. Hopefully this works?

i know i dont have a manual override for this yet or a way to keep this on as i want to ensure that it works before i start playing and adding more stuff.

thoughts if you think this works. I can share the code if its just a matter of exporting?