How To Automate Initial Onboarding/Set-Up?

Hi, I don’t know if I’m missing something obvious, but I’d like to be able to configure a Home Assistant installation automatically, i.e. without using the GUI, following the initial installation.

I’m always spinning up HA dev/test instances, and finding myself performing the same set-up steps over and over again. Like adding the MQTT add-on and configuring MQTT, configuring my tasmota devices, enabling automations, etc.

But I’m not sure if or how these steps can be automated?

I’m mostly using the VirtualBox Linux image instance, if that makes a difference.

Any ideas? Thanks.

Hi! I faced this problem a year ago. I have put this task aside but found that during onboarding HA creates some files in .storage dir. You can look there and try to generate the same jsons. User IDs - are random strings, and the generation of password hashes I found in python code. If you continue with this - let me know, maybe I can assist you and we’ll create some ansible modules for Home Assistant onboarding process. Unfortunately can’t say anything about tasmota devices

I’m working on a way to accomplish this. I will share the results if successful. My main goal is to find a way to go through the onboarding process without needing to access the onboarding GUI.

Option 1: Follow @andkuzmich’s method to copy known files and update them, so Home Assistant skips the onboarding.
Option 2: Simulate onboarding requests.
Option 3: Simulate a web browser and user input.

If someone else already know a way to do this, please let us know.

I made some progress,
The files that need to be added, either fully or sparsely, to skip the onboarding process have not been thoroughly checked yet. However, if you complete the onboarding process once, all files except the ones listed below can be removed from the config folder of Hass.

.
└── .storage
    ├── auth
    ├── core.analytics
    ├── core.config
    ├── core.uuid
    ├── onboarding
    └── person

if you want to change the password befor starting it up, auth_provider.homeassistan need to have a user and hashed password. to got started, i use the hash code that hass use. and just put that in the config file in the correct structure.
to change the a user password outside the hass system. here a sniped.

from homeassistant.auth.providers.homeassistant import Data 
import json

password = ""
username = ""
hash = Data.hash_password(self = None, password = password, for_storage=True).decode()

path = "hassconfig/.storage/auth_provider.homeassistant"

print(hash)


user = {
    "username": f"{username}",
    "password": f"{hash}"
}

If I have more I will update.