To turn on the light using sensor only once

Hello, I’m new in Home Assistant. I really need help in Node Red automation.

My objective is to turn on the light only ONCE when the maindoor is open.

For example, when my house maindoor is open, the living room light will automatically on. But I don’t want everytime I open the maindoor, my living room light keep getting turning on so I want the light on will occur only once in the morning. Ofcourse, my maindoor has a sensor.

Fyi, all automation in house using entities.

Make a boolean (toggle) helper and then set that to off at midnight with an automation.
Then check if it is off when your sensor wants to turn on the living room lights.
If it is off, then turn on the living room lights and set it to on.
If it is on, then do nothing.

[{"id":"ae23607ed5ab96dd","type":"trigger-state","z":"878e74c2.7f39c8","name":"Main door sensor on?","server":"9405c3fe.d0a6c","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"main door sensor","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"},{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is_not","comparatorValueDatatype":"prevEntity","comparatorValue":"state"},{"targetType":"this_entity","targetValue":"","propertyType":"previous_state","propertyValue":"old_state.state","comparatorType":"is_not","comparatorValueDatatype":"str","comparatorValue":"unavailable"},{"targetType":"this_entity","targetValue":"","propertyType":"previous_state","propertyValue":"old_state.state","comparatorType":"is_not","comparatorValueDatatype":"str","comparatorValue":"unknown"}],"inputs":1,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":true,"x":560,"y":2060,"wires":[["1e1d156591ae0bd5"],[]]},{"id":"44fa756ba834d2ea","type":"change","z":"878e74c2.7f39c8","name":"enable","rules":[{"t":"set","p":"payload","pt":"msg","to":"enable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":2040,"wires":[["ae23607ed5ab96dd"]]},{"id":"7eac9369312879e7","type":"change","z":"878e74c2.7f39c8","name":"dis","rules":[{"t":"set","p":"payload","pt":"msg","to":"disable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":2080,"wires":[["ae23607ed5ab96dd"]]},{"id":"1e1d156591ae0bd5","type":"api-call-service","z":"878e74c2.7f39c8","name":"living room on","server":"9405c3fe.d0a6c","version":5,"debugenabled":false,"domain":"","service":"","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":780,"y":2060,"wires":[["2ebdece9f35f0981"]]},{"id":"2ebdece9f35f0981","type":"link out","z":"878e74c2.7f39c8","name":"link out 51","mode":"link","links":["b802cd3e479fdb57"],"x":905,"y":2060,"wires":[]},{"id":"b802cd3e479fdb57","type":"link in","z":"878e74c2.7f39c8","name":"link in 17","links":["2ebdece9f35f0981"],"x":305,"y":2080,"wires":[["7eac9369312879e7"]]},{"id":"4fd13ce57d614d2d","type":"inject","z":"878e74c2.7f39c8","name":"at 00:00","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":2040,"wires":[["44fa756ba834d2ea"]]},{"id":"9405c3fe.d0a6c","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}]