Skip to content

shawngerrard/home-assistant

Repository files navigation

Home Assistant Setup Instructions

This will take us through the steps of setting up Home Assistant on Ubuntu Server.

Prerequisites

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.

Specification

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

Future updates:

Administer infra stack with Pulumi configuration
Change from single node infra to multi-node for high-availability.
Replace Raspberry Pi with more powerful server hardware.
Replace Ubuntu Server with RedHat Enterprise Linux (RHEL).

Pulumi authentication

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.

Update credentials.json with access token

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” } } }

Update an environment variable

We could also use the PULUMI_ACCESS_TOKEN environment variable to store our access token.

Google Cloud authentication

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.

Pulumi backend configuration

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.

Infrastructure deployment (k3s/helm)

Refer to the README for scaffolding and deployment of infra-k3s.

Ingress controller deployment (nginx-ingress-controller)

Refer to the README for scaffolding and deployment of app-nginx.

Certificate manager deployment (cert-manager)

Refer to the README for scaffolding and deployment of app-certmanager.

Application deployment (home-assistant)

Refer to the README for scaffolding and deployment of app-homeassistant.

Integrating Google Cloud with Home Assistant

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.

Future updates

Investigate use of gcp identity platform (idp) to automate creation of OAuth 2.0 Clients in GCP.

Investigate use of service accounts within Home Assistant and GCP to automate deployment.

Enable GCP services

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

Create an Oauth consent for GCP

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>

Create credentials for a new Oauth Client ID

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.

Create a device access project

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.

Create a Home Assistant administrator

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.

Add a Google Nest device to Home Assistant

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).

Install Home Assistant with Docker

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.

Future updates:

Replace Docker with a single-node Kubernetes cluster.
Install RedHat OpenShift (RHOS) over the top of Kubernetes to better orchestrate the platform.

Create a Home Assistant Docker 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

Access the Home Assistant dashboard

Once the Docker container is up and running, the Home Assistant dashboard will be accessible using https://<host name/host ip network address>:8123/.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published