Fix automation failing to restore state #24390
There are two cases where it can happen that an automation was unable to restore their state, defaulting to turning the automation off.
Both cases will be addressed with this PR. An automation will now report as "on" during startup, even if they have not yet attached the listeners for the triggers. This will make sure that we will always restore the state correctly.
The reason that this bug was able to fly under the radar for so long, is that the Home Assistant test instance by default is up and running. This means that the "restore while starting up" part was not properly tested.
Pull request with documentation for home-assistant.io (if applicable): home-assistant/home-assistant.io#<home-assistant.io PR number goes here>
If the code does not interact with devices: