Initial state for switches, lights or other components

This may be a silly question, but can’t find an answer for it in the forum.
Is there an easy way to set up the state of a component at Home Assitant startup? I’m thinking something similar to what is done with automations:

initial_state: 'on'

Of course, it could be done with automations, but isn’t there an easier way?

If the components don’t have an initial_state attribute you can use an automation that runs at start up to set them to the state you want.

- id: hass_startup
  alias: 'Hass startup'
  trigger:
   - platform: homeassistant
     event: start
  action:
  - service: switch.turn_on
    entity_id: [your switch id]
  - service: switch.turn_on
    entity_id: [your switch id]
4 Likes

OK, I’ll do this then as it’s not nearly as tricky as I thought. Thanks for the code!

I can confirm this works fine. Thanks @tom_l