1+ # Author: https://github.com/jessebot
12import json
23from os import environ as env
34import requests
67class RunHomeAssistantOnboarding ():
78 """
89 Runs through home assistant onboarding to create a new user and disable registration
10+ Required environment variables:
11+
12+ INTERNAL_URL - if using k8s: name of k8s service, or if local you can use IP
13+ like this http://your-ip-here:8124
14+ EXTERNAL_URL - the url you use to access home assistant. if local, may be
15+ the same as INTERNAL_URL if using k8s with ingress, this is
16+ your ingress host, such as https://ha.yourhostname.tld/
17+ ADMIN_PASSWORD - string of password for initial owner user, not required, recommended
18+ default: "b33pB00p.d4Doop"
19+
20+ # optional environment variables
21+ DEBUG - print all api responses, WARNING includes sensitive data. set to "true"
22+ ADMIN_NAME - name of the first owner user, default: 'admin'
23+ ADMIN_USERNAME - login username of first owner user, default: 'admin'
24+ ADMIN_LANGUAGE - 2 character string of initial owner user's language, default "en"
925
1026 home assistant user onboarding urls found here:
1127 https://github.com/home-assistant/core/tree/dev/homeassistant/components/onboarding/views.py
@@ -14,7 +30,7 @@ def __init__(self):
1430 self .headers = {
1531 'Content-Type' : 'application/json' ,
1632 }
17- self .base_url = f"http://{ env .get ('SERVICE ' , 'home-assistant :8124' )} "
33+ self .base_url = f"http://{ env .get ('INTERNAL_URL ' , 'localhost :8124' )} "
1834 self .external_url = env .get ('EXTERNAL_URL' , '' )
1935 self .debug = env .get ('DEBUG' , False )
2036
@@ -33,7 +49,7 @@ def run_integration_config(self) -> dict:
3349 """
3450 runs the integration config step of onboarding via the home assistant api
3551
36- may not be working 🤷
52+ may not be working 🤷, however this doesn't break the onboarding.
3753 """
3854 integration_url = f"{ self .base_url } /api/onboarding/integration"
3955 print (f"We're going to post to { integration_url } for integration config" )
@@ -68,7 +84,7 @@ def create_user(self) -> dict:
6884 "client_id" : client_id ,
6985 "name" : env .get ('ADMIN_NAME' , 'admin' ),
7086 "username" : env .get ('ADMIN_USERNAME' , 'admin' ),
71- "password" : env .get ('ADMIN_PASSWORD' , 'test' ),
87+ "password" : env .get ('ADMIN_PASSWORD' , "b33pB00p.d4Doop" ),
7288 "language" : env .get ('ADMIN_LANGUAGE' , 'en' )
7389 })
7490
0 commit comments