This is a good example of the XY Problem.
What you really want is a light that stays on a certain amount of time after the last sensor reading. This is a common problem and well solved problem. For one example see Design Pattern: Motion Sensor Timer.
This approach is very similar to what you have. Perhaps comparing them will reveal the problem. I don’t see anything besides the problem Marcel pointed out. You should be seeing errors on that line from VSCode and in openhab.log on that line.