I have several automations that use data from the weather_forecast sensor. The sensor is configured as below (including a forced update on HAss restart).
However, when HAss restarts, there seems to be a short interval in which the sensor values are not populated. Which means that all my automations/code that use the sensor crash.
However, state_attr still seems to return values for unavailable entities, so I assume it will still crash on that [0] index. My question is more on “how do I check if there is anything in the list?”
Haven’t used either of these, but based on the docs the following events seem promising for your usecase:
Use the homeassistant_started event instead of the dedicated homeassistant_start trigger. This seems to imply that the event will only fire after the entire startup process is complete, rather than firing when it’s started.
Use the component_loaded event for your weather service. However note the below warning, so you might need to add a delay for that specific trigger.
Thus this event can not be used to run automations during startup as it would have missed these events