Thanks for that. I just tried out pyscript. I found it a lot more pleasant to write automation in a real programming language. It also more or less addresses my complaint about needing multiple rules. In the tutorial, [1] the motion_light_rear example addresses this via sleeping + task.unique. It's not the approach I imagined, but it's aimed at the same problem.
[1] https://hacs-pyscript.readthedocs.io/en/stable/tutorial.html