Lux automation

Hello
Im trying to create a automation that checks if Lux-value in sensor.lux_pimproad9 is less or equal to a input_number.lux_dusk (helper) and if it is then save the time in another helper and turn on the light.

The problem is when using state-node it responds to every change that happens in the sensor and triggers it to turn on light.
What other node should I use and how? Or do someone have a better way to do it?

My code:

[{"id":"4b6097aba3969151","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"19dbbe459d7d514f","type":"api-call-service","z":"4b6097aba3969151","name":"Turn on light","server":"a72a7bde.9c5648","version":5,"debugenabled":false,"domain":"switch","service":"turn_on","areaId":[],"deviceId":[],"entityId":["switch.kontor_fonster"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":830,"y":260,"wires":[[]]},{"id":"0bec88edfccfc861","type":"function","z":"4b6097aba3969151","name":"Save date and time","func":"var today = new Date();\nvar isoDate = today.toISOString();\nmsg.payload = isoDate;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":850,"y":220,"wires":[["45bfbb357af92720"]]},{"id":"6f52b3a95d38e2e0","type":"api-call-service","z":"4b6097aba3969151","name":"Save to input_datetime","server":"a72a7bde.9c5648","version":5,"debugenabled":false,"domain":"input_datetime","service":"set_datetime","areaId":[],"deviceId":[],"entityId":["input_datetime.daylight_lux_dusk"],"data":"{\"datetime\":\"{{payload}}\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":1320,"y":220,"wires":[[]]},{"id":"45bfbb357af92720","type":"moment","z":"4b6097aba3969151","name":"","topic":"","input":"","inputType":"msg","inTz":"ETC/UTC","adjAmount":"2","adjType":"hours","adjDir":"add","format":"","locale":"C","output":"","outputType":"msg","outTz":"Europe/Stockholm","x":1080,"y":220,"wires":[["6f52b3a95d38e2e0"]]},{"id":"0592061c356a8735","type":"api-current-state","z":"4b6097aba3969151","name":"Checks set Lux-level and compares","server":"ee6480c8.d1c6b","version":3,"outputs":2,"halt_if":"payload","halt_if_type":"msg","halt_if_compare":"gte","entity_id":"input_number.lux_dusk","state_type":"num","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":540,"y":240,"wires":[["0bec88edfccfc861","19dbbe459d7d514f"],[]]},{"id":"417807a130e7f6c2","type":"server-state-changed","z":"4b6097aba3969151","name":"Checks current state of Lux outside","server":"a72a7bde.9c5648","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.lux_pimproad9","entityidfiltertype":"exact","outputinitially":true,"state_type":"num","haltifstate":"","halt_if_type":"num","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":"","forType":"minute","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":200,"y":240,"wires":[["0592061c356a8735"]]},{"id":"a72a7bde.9c5648","type":"server","name":"Home Assistant","addon":true},{"id":"ee6480c8.d1c6b","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

Thought I had it but no.
Someone must have something similar.

[{"id":"70983b641f40a505","type":"tab","label":"Lux-automation","disabled":false,"info":"","env":[]},{"id":"64719c72.7a1b28","type":"api-call-service","z":"70983b641f40a505","name":"Turn on light","server":"a72a7bde.9c5648","version":5,"debugenabled":false,"domain":"switch","service":"turn_on","areaId":[],"deviceId":[],"entityId":["switch.kontor_fonster"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":1530,"y":60,"wires":[[]]},{"id":"d8f59e83.0f0188","type":"function","z":"70983b641f40a505","name":"Save date and time","func":"var today = new Date();\nvar isoDate = today.toISOString();\nmsg.payload = isoDate;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1090,"y":120,"wires":[["2897b3340f352a0b"]]},{"id":"b84f7281.caaef","type":"api-call-service","z":"70983b641f40a505","name":"Save to input_datetime","server":"a72a7bde.9c5648","version":5,"debugenabled":false,"domain":"input_datetime","service":"set_datetime","areaId":[],"deviceId":[],"entityId":["input_datetime.daylight_lux_dusk"],"data":"{\"datetime\":\"{{payload}}\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":1560,"y":120,"wires":[[]]},{"id":"2897b3340f352a0b","type":"moment","z":"70983b641f40a505","name":"","topic":"","input":"","inputType":"msg","inTz":"ETC/UTC","adjAmount":"2","adjType":"hours","adjDir":"add","format":"","locale":"C","output":"","outputType":"msg","outTz":"Europe/Stockholm","x":1320,"y":120,"wires":[["b84f7281.caaef"]]},{"id":"dca7780db7dbf153","type":"api-current-state","z":"70983b641f40a505","name":"Checks set Lux-level and compares","server":"ee6480c8.d1c6b","version":3,"outputs":2,"halt_if":"payload","halt_if_type":"msg","halt_if_compare":"gt","entity_id":"input_number.lux_dusk","state_type":"num","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":500,"y":100,"wires":[["dbb6ce14.6fcba8"],[]]},{"id":"430851c009593ed1","type":"server-state-changed","z":"70983b641f40a505","name":"Checks current state of Lux outside","server":"a72a7bde.9c5648","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.lux_pimproad9","entityidfiltertype":"exact","outputinitially":true,"state_type":"num","haltifstate":"","halt_if_type":"num","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":"","forType":"minute","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":180,"y":100,"wires":[["dca7780db7dbf153"]]},{"id":"dbb6ce14.6fcba8","type":"api-current-state","z":"70983b641f40a505","name":"Check lux switch helper state","server":"a79fc2f2.96939","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.lux_switch_helper","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":800,"y":100,"wires":[["8a27f5a5.77ce88","d8f59e83.0f0188"],[]]},{"id":"8a27f5a5.77ce88","type":"api-call-service","z":"70983b641f40a505","name":"Turn off lux switch helper","server":"a79fc2f2.96939","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_off","areaId":[],"deviceId":[],"entityId":["input_boolean.lux_switch_helper"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":1110,"y":60,"wires":[["64719c72.7a1b28"]]},{"id":"db8f0b2fb2556054","type":"api-call-service","z":"70983b641f40a505","name":"Turn OFF light","server":"a72a7bde.9c5648","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.kontor_fonster"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":1540,"y":240,"wires":[[]]},{"id":"60920d7bb5bb1efa","type":"function","z":"70983b641f40a505","name":"Save date and time","func":"var today = new Date();\nvar isoDate = today.toISOString();\nmsg.payload = isoDate;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1090,"y":300,"wires":[["e1bce95ab9530450"]]},{"id":"acf5eed52de6a3b7","type":"api-call-service","z":"70983b641f40a505","name":"Save to input_datetime","server":"a72a7bde.9c5648","version":5,"debugenabled":false,"domain":"input_datetime","service":"set_datetime","areaId":[],"deviceId":[],"entityId":["input_datetime.daylight_lux_dawn"],"data":"{\"datetime\":\"{{payload}}\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":1560,"y":300,"wires":[[]]},{"id":"e1bce95ab9530450","type":"moment","z":"70983b641f40a505","name":"","topic":"","input":"","inputType":"msg","inTz":"ETC/UTC","adjAmount":"2","adjType":"hours","adjDir":"add","format":"","locale":"C","output":"","outputType":"msg","outTz":"Europe/Stockholm","x":1320,"y":300,"wires":[["acf5eed52de6a3b7"]]},{"id":"6168af5def8937c8","type":"api-current-state","z":"70983b641f40a505","name":"Checks set Lux-level and compares","server":"ee6480c8.d1c6b","version":3,"outputs":2,"halt_if":"payload","halt_if_type":"msg","halt_if_compare":"lt","entity_id":"input_number.lux_dawn","state_type":"num","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":500,"y":280,"wires":[["84320e59cb4d6d49"],[]]},{"id":"eb907ca7f89ee55d","type":"server-state-changed","z":"70983b641f40a505","name":"Checks current state of Lux outside","server":"a72a7bde.9c5648","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.lux_pimproad9","entityidfiltertype":"exact","outputinitially":true,"state_type":"num","haltifstate":"","halt_if_type":"num","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":"","forType":"minute","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":180,"y":280,"wires":[["6168af5def8937c8"]]},{"id":"84320e59cb4d6d49","type":"api-current-state","z":"70983b641f40a505","name":"Check lux switch helper state","server":"a79fc2f2.96939","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.lux_switch_helper","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":800,"y":280,"wires":[["37a3a76fa0683650","60920d7bb5bb1efa"],[]]},{"id":"37a3a76fa0683650","type":"api-call-service","z":"70983b641f40a505","name":"Turn ON lux switch helper","server":"a79fc2f2.96939","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_on","areaId":[],"deviceId":[],"entityId":["input_boolean.lux_switch_helper"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","output_location":"","output_location_type":"none","x":1110,"y":240,"wires":[["db8f0b2fb2556054"]]},{"id":"0d58fbf31e4ad142","type":"comment","z":"70983b641f40a505","name":"Lux-belysning ON","info":"","x":130,"y":60,"wires":[]},{"id":"6666756113092299","type":"comment","z":"70983b641f40a505","name":"Lux-belysning OFF","info":"","x":130,"y":240,"wires":[]},{"id":"a72a7bde.9c5648","type":"server","name":"Home Assistant","addon":true},{"id":"ee6480c8.d1c6b","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"a79fc2f2.96939","type":"server","name":"Home Assistant","addon":true}]