Home Assistant

February 13, 2025    Home Automation Smart Home IoT

Home Assistant

Home Assistant is an open-source home automation platform that allows users to control their smart devices and create complex automations. It is written in Python and can be installed on various platforms, including Raspberry Pi and Kubernetes clusters using k3s. This document provides an overview of Home Assistant, its features, how to install it on a Raspberry Pi, and how to set it up in a Kubernetes cluster using k3s.

What is Home Assistant?

Home Assistant is a flexible and customizable platform that provides users with a central hub to control and automate their smart devices. It enables integration with a wide range of devices and services, including lights, sensors, thermostats, and cameras, supporting over 1400 different devices and services.

Home Assistant Features

  • Integrations: Compatible with Google Home, Amazon Alexa, Philips Hue, Nest, and more.
  • Automations: Create complex automations using Home Assistant’s visual editor.
  • User Interface: Highly customizable with configurable dashboards.
  • Add-ons: Growing library of pre-configured software packages to extend functionality.

Installing Home Assistant on Raspberry Pi

To install Home Assistant on a Raspberry Pi, follow these steps:

  1. Download the latest version of Raspberry Pi OS and flash it onto an SD card.
  2. Connect the Raspberry Pi to your network and power it on.
  3. Access it via SSH and run the following commands:
sudo apt-get update
sudo apt-get install python3 python3-pip
pip3 install homeassistant
  1. Start Home Assistant with:
sudo systemctl start home-assistant@homeassistant.service
  1. Access the web interface at http://<your-raspberry-pi-ip>:8123 in your browser.

Installing Home Assistant on Kubernetes with k3s

To install Home Assistant on a Kubernetes cluster using k3s:

  1. Install k3s on your Kubernetes cluster.
  2. Create a new namespace:
kubectl create namespace home-assistant
  1. Define the deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
  name: home-assistant
  namespace: home-assistant
spec:
  replicas: 1
  selector:
    matchLabels:
      app: home-assistant
  template:
    metadata:
      labels:
        app: home-assistant
    spec:
      containers:
      - name: home-assistant
        image: homeassistant/home-assistant:latest
        ports:
        - containerPort: 8123
        volumeMounts:
        - name: config
          mountPath: /config
      volumes:
      - name: config
        persistentVolumeClaim:
          claimName: home-assistant-config
  1. Create a persistent volume claim:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: home-assistant-config
  namespace: home-assistant
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  1. Apply the configurations:
kubectl apply -f deployment.yaml
kubectl apply -f pvc.yaml
  1. Access the web interface at http://<your-kubernetes-node-ip>:<node-port>.

Optionally, you can expose Home Assistant to the internet using a Kubernetes ingress controller or a load balancer.