WTH, why don't (some) alerts alert on startup?

When HA starts/restarts, alerts sometimes don’t fire if the monitored state is already set. It seems like there is a race condition between the alert integration loading and the monitored state getting set - if the monitored state for the alert is set first, then when the alert integration loads no alert is fired.

This leads to some unexpected situations where I’d expect an alert to be firing, but it is not, and the only difference seems to be whether or not the monitored state was already set at startup or if it changed later.

One example is an alert based on an input_select. If the input_select changes while HA is running, the alert fires. But if HA is restarted after the input_select enters the alert condition, the alert does not fire when HA starts up - it instead shows as idle.

Here’s a gif of that alert after startup (idle when it should be on) vs after I manually re-trigger the state change. The alert condition is that scan status is offline.


See also:

PS: Thanks for HA, it is amazing! And thanks for running a “WTH” month :slight_smile: