Run script on startup of hass

Since many entities like command switches, arduino, etc cannot remember state, is there a way to run a script on startup to set state programmatically.

For example I would like to create a python script with assumed values:

api = remote.API(‘localhost’, ‘’)
remote.set_state(api, ‘switch.refridgerator’, new_state=STATE_ON)

and have this run at startup

You could create a custom component to set states. See this example.

Add the ‘group’ component to your dependencies to ensure all device related components are initialized before your custom component.

Thanks balloob I will try that.