Add trigger for frontend started

I am trying out the 0.111 beta, which has a great feature where the frontend becomes available earlier in the startup process which avoids the issue of failing integrations stopping the frontend from loading.

However, this causes problems if you use an automation like this which uses the start event of the homeassistant integration to set the backend theme:

- id: set_theme
  alias: Set Theme on Startup
  description: Set theme on startup
  trigger:
  - platform: homeassistant
    event: start
  action:
  - data:
      name: My Theme
    service: frontend.set_theme

Since the frontend starts early, the theme won’t be set until some time after the frontend and until that happens the default theme will be used.

To resolve that, I believe we should have a start event for the frontend integration, and then we could just replace the trigger in the automation with:

trigger:
  - platform: frontend
    event: start

Damn. This is definitely an issue you should raise in the beta chat.

Don’t forget to vote for your own request.

If the system require to start FE before backend, then definitely there is something wrong with system architecture. one way or another it will fail due to this fact

Maybe a better feature here would be the ability to set your own default theme? That way an automation isn’t needed? I voted but personally its still a workaround to me to add another event here. Unless there is a use case I missed?

1 Like

That wont work for setting the default theme at start up based on the time of day (dark theme at night, light theme during the day) as I currently do.

2 Likes

Maybe the solution is to implement state restoration for the default theme the same as we have for entities, sich as lights, switches, etc…

This would mean that whenever Home Assistant restarts, the backend selected theme would default to whatever it was when it last shutdown.

1 Like

Going from the discussion over on Discord, it looks like a frontend started event isn’t going to help since automations won’t be loaded until after the frontend which means that there won’t be anything to listen to the event.

I never even knew about a frontend start event and I do use an automation to set the theme on HA start not frontend. That is working fine. I do get the white screen for maybe 20 or 30 seconds and then the correct theme is loaded.

same problem here, i would like to set_state when homeassistant start, but now it’s not working more