What is the difference between using a delay_on vs trigger + for. Is there anything glaringly obvious that distinguishes them that I’m idiotically missing? Or something more subtle around perhaps restart behavior, etc? Thanks.
For example (you can assume that sensor.foo returns integers rather than floats in practice)
In the examples you posted there isn’t a whole lot of difference. They would have some differences following restart, but those differences could be eliminated by adding a restart trigger and additional templating to the trigger-based sensor or by setting up an availability template for the state-based sensor.
Thanks.
So why have two was to accomplish the same thing?
Is it just a matter of convenience as the delay_on approach tends to be much simpler to express the intent?
There are almost always multiple ways to accomplish anything in Home Assistant… usually it is just legacy functions being maintained.
Trigger-based template sensors have only been around for a few years. Prior to that we used to accomplish a similar function by using an automation to save a value to one of the input helpers (which can still be done).
Often when setting up a trigger-based template sensor you aren’t using the same entity in both the trigger and template.