This will take us through the steps of setting up Home Assistant on Ubuntu Server.
To use these instructions, you’ll need Ubuntu Server installed on a machine, as well as SSH access (OpenSSH) to the server.
You’ll need to install the following tools to use this repository:
Note: If using my ubuntu-tool setup, these tools should already be installed/configured.
I’m running Home Assistant on the following specs:
- Raspberry Pi model 4b
- Ubuntu Server 64-bit LTS 22.04
- 3TB SSD mounted storage volume
If you haven’t already, we must authenticate with Pulumi in order to interact with the Pulumi Cloud API. We can do this a number of different ways - either log in via CLI or use an access token.
Note: Please refer to the definitions of both organizational and personal access tokens on the Pulumi website. This link will also provide the information on how to generate an access token. For the purposes of this guide, we will be creating a personal access token.
Note: Neither of the options listed below are secure on their own - please refer to Pulumi regarding how to use it securely.
We can update the ~/.pulumi/credentials.json
with the appropriate access token:
{ “current”: “https://api.pulumi.com”, “accessTokens”: { “https://api.pulumi.com”: “<access token>” }, “accounts”: { “https://api.pulumi.com”: { “accessToken”: “<access token>”, “username”: “<username>”, “organizations”: [ “<org1>”, “<org2>” ], “lastValidatedAt”: “2024-04-16T11:35:59.084951264+12:00” } } }
We could also use the PULUMI_ACCESS_TOKEN
environment variable to store our access token.
If you haven’t already, we must authenticate with Google in order to interact with the Google Cloud API by setting a project and using a link supplied by Google to optain an access code.
# Set project ID in config
gcloud config set project <YOUR_GCP_PROJECT_ID>
# Obtain a url from Google to log in
gcloud auth login --no-launch-browser
Use the code from the URL provided to obtain an access code and enter the code into the CLI.
Make sure to update the Pulumi configuration to use the correct organization by default:
pulumi org set-default <org-name>
I’ve named the default organization for these projects as myhome
.
Refer to the README for scaffolding and deployment of infra-k3s
.
Refer to the README for scaffolding and deployment of app-nginx
.
Refer to the README for scaffolding and deployment of app-certmanager
.
Refer to the README for scaffolding and deployment of app-homeassistant
.
This guide will outline how integrate home-assistant
within a gcp
project by using the Google Cloud console to configure an OAuth 2.0 client, and then use the client to facilitate integration between home-assistant
and a new Google Nest project.
Note: These steps are mostly manual as Google does not offer an API to programatically create or update OAuth 2.0 Clients - refer to StackOverflow and the link in the answer section for more information. These manual steps can also be followed by the guide provided in Home Assistant when adding a new device.
Note: Refer to the section Google Cloud authentication above to set the
gcp
configuration and log in to the correct project.
- IDP appears mostly free - refer to the Google pricing model.
First, we must enable the required integration services within gcp
:
# Enable the smart device management api in the gcp api library
gcloud services enable smartdevicemanagement.googleapis.com
# Enable the cloud pub/sub api in the gcp api library
gcloud services enable pubsub.googleapis.com
# Enable the iam api in the gcp api library
gcloud services enable iam.googleapis.com
Next, we must consent for GCP to be available to external users.
This must be enabled in the gcp
console. Access API’s & Services in the left-menu of the gcp
dashboard, select OAuth consent screen in the left-menu of the next page, and then select “External” and click the Create button.
Fill out the relevant information:
App name: home-assistant User support email: <Your-Email>
Under Credentials, select Create Credentials and the Oauth client ID.
Fill out the relevant information:
Application type: Web application Name: home-assistant-oauth-client
Under Authorized redirect URIs, select Add URI as enter https://my.home-assistant.io/redirect/oauth
. Then, click the Create button.
Note the Client ID and Client Secret - you need to add these into home-assistant
when adding a new Google device.
Next, access the Nest device access console and follow through the payment flow - this will cost a one-off $5 developer registration fee.
Once you have access to the console, create a new project. You’ll need to add in the Client ID you created earlier.
Note the Project ID - you need to add this into home-assistant
when adding a new Google device.
You can access home-assistant
by pointing your browser to http://<your server local ip address>:<nodeport port>
.
Once there, create a new user to enter the home-assistant
dashboard.
In home-assistant
, go to Settings > Devices and services and then click Add device.
Follow the steps and enter in the details provided from the steps above (gcp project id, oauth client id, nest device access project id).
To start with, we’ll be running our Home Assistant application in a Docker container.
To install Docker, consult the official Docker installation instructions for Ubuntu.
For reference: I’ve installed Docker using their apt
repository.
This Docker installation requires root privileges to run Docker containers. To run Docker containers as a non-root user, follow the official Docker Linux post-installation instructions.
Any OCI (Open Container Initiative) compatible runtime can be used to run a Home Assistant container.
With Docker installed, we can start Home Assistant in an OCI (Open Container Initiatie) container.
docker run -d \
--name homeassistant \
--privileged \
--restart=unless-stopped \
-e TZ=MY_TIME_ZONE \
-v /PATH_TO_YOUR_CONFIG:/config \
-v /run/dbus:/run/dbus:ro \
--network=host \
ghcr.io/home-assistant/home-assistant:stable
- /PATH_TO_YOUR_CONFIG points at the folder where you want to store your configuration and run it. Make sure that you keep the :/config part.
- MY_TIME_ZONE is a tz database name, like TZ=America/Los_Angeles.
- D-Bus is optional but required if you plan to use the Bluetooth integration.
docker run -d \
--name homeassistant \
--privileged \
--restart=unless-stopped \
-e TZ=Pacific/Auckland \
-v /mnt/data:/config \
-v /run/dbus:/run/dbus:ro \
--network=host \
ghcr.io/home-assistant/home-assistant:stable
Once the Docker container is up and running, the Home Assistant dashboard will be accessible using https://<host name/host ip network address>:8123/
.