Then you want an automation platform that uses a continuous-polling model, not Home Assistant’s event-based model.
Just for clarity’s sake, in HA automations conditions are checked immediately, they do not wait or poll multiple times… so the concept of a “While” condition is kind of non-nonsensical.
I’d be fine if, under the hood, HA would turn on the fan on event X, then turn it off on event Y. Continuous polling is not mandatory. What I don’t want is having to manually set two conditions for on and off. I’d like one condition that understands what I want.
If you are interested in other approaches, there is also a “While” trigger available in Spook. It’s a little closer to what you asked for, but, as I understand, it still isn’t reload/restart-safe.
Nice template. Elegant. I would have probably made some much more wordy if loop, but this is nicer. One thing for the OP to be aware of: it also turns off the fan if the heating goes unavailable or undefined. I don’t know if that is what the OP wants but it is easily adjusted.
What if I’d like to turn the heating on only if my solar array yields a certain amount of power (say 2000W) and turn it off if it’s getting below (shadow/cloud) that power level ?
Related to this, I recall struggling with an automation some time ago, was looking for a while condition or at least the possibility to manually define a “system wide” boolean state variable that I could read in some other conditional checks - thus, simulating a “while” loop. I also documented the issue here in the forum (it was about starting/stopping the recording on some surveillance cameras based on triggering events) and got no replies ever since. In this respect HA is really limited… a pity.
Edit - found the thread with the cameras I referred to
And upvote this feature request (or add its own WTH if it doesn’t already exist) to add wait_for_condition which is one I’ve been wanting personally for a very long time .
While not native, and still pretty new, I created an app using AI that does something like it, for the same reason - persist across reboots and make sure the state is always synced. I can’t promise that there won’t be breaking changes as it matures, but I use it now and it’s been working flawlessly