JavaScript (ECMA 2021) Rules which is triggered by a motion sensor but only runs once a day

The workaround would be to store the state in a switch item which will be set to OFF at midnight and set to ON after the last successful run. But I wonder that I cannot use the context “this” to store the last execution which I set to “now” after the last successful run. I know that this way would not “survive” a restart or changes of the rule - which is stated here - OH 3 Examples: Writing and using JavaScript Libraries in MainUI created Rules