electronic brain surgery since 2001

Home Assistant again

Ever since we moved into the house, my old Home Assistant setup lay dormant. My old port forwardings in the router were missing, so it was unreachable, many of the set up devices did not exist anymore and it was in a really bad state overall.

So in the last weeks I did a fresh start. I shut down my old instance for good, bought a new Raspberry Pi 4 and started with a new install.

Home Assistant is a free and open-source software for home automation that is designed to be the central control system for smart home devices with focus on local control and privacy.Wikipedia

A lot has changed in Home Assistant since I last tried it. It got a lot more user friendly and editing YAML no longer needed for many of the core tasks. I really like it.

Here are a couple of things I found noteworthy.


I used the Home Assistant Operating System setup type. It installs a supervisor that runs all the actual HA in Docker (or that's how I understand it). The supervisor allows for adding “addons” that integrate automatically with the HA setup. Those addons are also Docker containers. Keeps everything super clean.

One of the first addons, I installed is the “Terminal & SSH” addon. By default it gives you a web based shell on the Raspberry. Actually enabling SSH requires some configuration. This blog post by André Jacobs was helpful for that.

My setup of Let's Encrypt and DuckDNS has also been turned into an addon which can be installed with a click. Nice.

Currently I have the following addons installed:

  • DuckDNS - for Let's Encrypt and external HTTPS access
  • ESPHome - for managing ESP devices (see below)
  • File Editor - for easily editing config files
  • Google Drive Backup - automated snapshot backups to Google Drive
  • Node-Red - visual automations (see below)
  • Terminal & SSH - for direct access to the Raspberry


Many integrations can be installed and configured via the web UI, but not all. For those that still require YAML configurations I recommend to use “package” files. For that simply add the following line to your configuration.yaml:

  packages: !include_dir_named packages/

This will load all the yaml files it finds in the packages directory and merge it with the standard config file. This allows you to configure integrations, sensors, switches, etc. that belong to each other in a single file. Much cleaner than in the old days where these kind of configs had to be strewn over multiple files.

For example, the following file configures the TTS integration and creates notification services based on it.

  - platform: picotts
    service_name: tts
    language: "en-US"

  - platform: tts
    name: tts_kitchen
    tts_service: tts.tts
    media_player: media_player.kitchen_speaker
  - platform: tts
    name: tts_bedroom
    tts_service: tts.tts
    media_player: media_player.bedroom_speaker


At some point you will come across a non-standard integration you want to install. You can relatively easy install those, but the Home Assistant Community Store makes it much easier.

Basically it wraps around git to add new integrations to your HA setup and to keep them up-to-date.

The very first setup is a bit finicky because it will fetch a lot of data from github and at one point will run into an API limit. Just wait a few hours after your first installation and it will work fine.

I currently have custom integrations for my car and for fetching the waste collection days installed.


ESPHome is another addon that ties in very well with HomeAssistant. It is a custom firmware builder for ESP powered devices. You can use it to flash consumer devices (to replace their original Chinese firmware) or to power your ESP based DIY projects.

I flashed some WiFi power sockets with it to monitor our dryer and washing machine. It's really versatile, auto exposes all sensors to HomeAssistant and can even do lightweight automation right on the device.

Here's the setup for the Nous SP111 sockets I use.

# Dryer Socket

  devicename: socket-01
  # Higher value gives lower watt readout
  current_res: "0.00238"
  # Lower value gives lower voltage readout
  voltage_div: "755"

  name: $devicename
  platform: ESP8266
  board: esp01_1m
# Enable logging

# Enable Home Assistant API

  port: 80

  password: "5da04df1c90b5bf6c2b29589fa2e8222"

  ssid: "W00t"
  password: !secret wifi_password
  # Enable fallback hotspot (captive portal) in case wifi connection fails
    ssid: "Socket-01 Fallback Hotspot"
    password: "nxMagQ4qAles"


### Initial config based on https://www.esphome-devices.com/devices/Gosund-SP111
# see: https://esphome.io/components/time.html
  - platform: homeassistant
    id: homeassistant_time

  - platform: version
    name: "${devicename} - Version"
    icon: mdi:cube-outline

  - platform: status
    name: "${devicename} - Status"
    device_class: connectivity
  # toggle relay on/off
  - platform: gpio
      number: GPIO13
      mode: INPUT_PULLUP
      inverted: True
    id: "button_state"
      - switch.toggle: button_switch
  # State Sensor
  - platform: template
    name: "${devicename} - Running"
      - delayed_off: 15s # drop below for at least 15s to trigger off
      - delayed_on: 60s  # rise above for at least 60s to trigger on
    lambda: |-
      if (isnan(id(power_wattage).state)) {
        return {};
      } else if (id(power_wattage).state > 5) {
        // Running
        return true;
      } else {
        // Not running
        return false;

  - platform: wifi_signal
    name: "${devicename} - Wifi Signal"
    update_interval: 60s
    icon: mdi:wifi

  - platform: uptime
    name: "${devicename} - Uptime"
    update_interval: 60s
    icon: mdi:clock-outline

  - platform: total_daily_energy
    name: "${devicename} - Todays Usage"
    power_id: "power_wattage"
      # Multiplication factor from W to kW is 0.001
      - multiply: 0.001
    unit_of_measurement: kWh
    icon: mdi:calendar-clock

  - platform: adc
    pin: VCC
    name: "${devicename} - VCC Volt"
    icon: mdi:flash-outline

  - platform: hlw8012
      number: GPIO12
      inverted: True
    cf_pin: GPIO05
    cf1_pin: GPIO04
    change_mode_every: 4
    current_resistor: ${current_res}
    voltage_divider: ${voltage_div}
    update_interval: 3s

      name: "${devicename} - Ampere"
      unit_of_measurement: A
      accuracy_decimals: 3
      icon: mdi:current-ac

      name: "${devicename} - Volt"
      unit_of_measurement: V
      accuracy_decimals: 1
      icon: mdi:flash-outline

      name: "${devicename} - Watt"
      unit_of_measurement: W
      accuracy_decimals: 0
      id: "power_wattage"
      icon: mdi:gauge

    number: GPIO02
    inverted: True
  id: led_blue

  - platform: gpio
    pin: GPIO00
    inverted: true
    id: led_red

  - platform: template
    name: "${devicename} - Switch"
    icon: mdi:power
    optimistic: true
    id: button_switch
      - switch.turn_on: relay
      - switch.turn_off: relay
  - platform: gpio
    pin: GPIO15
    id: relay

To flash them with ESPHome I used Tuya Convert on a separate Raspberry to convert them to Tasmota first, then installed the ESPHome firmware. Migrating from Tasmota describes the process.


Node-RED is another addon that makes Home Assistant easier to use. It is a visual programming environment in the style of Yahoo! Pipes.

The addon is already preconfigured to talk with HomeAssistant. So you can easily create automations based on HA events that call services within HA.

So far I used it to automate the brightness in the office and send a notification whenever the washing machine or dryer in the basement are done.

However Node-RED is not limited to communicating with Home Assistant. It can also be used to integrate web services. So it might end up doing some non-home-automation related things for me.


Lovelace is the new mechanism how dashboards in Home Assistant work. By default HA has a dashboard that will auto-add each and every entity from every device you have. That becomes unusable very very quick.

Instead you need to take control and build your dashboards manually using the GUI Editor. It's tedious but gives you a lot of control over how to visualize state of your home devices. It also makes it easy to build different dashboards for different devices or situations. A wall panel based on a cheap tablet might display something other than you default mobile dashboard.

My only gripe is that you can't drag'n'drop cards from one container to another. So for rearranging items on a dashboard you often need to remove and re-add the same card in different contexts (or switch to the YAML editor for some error prone cut'n'paste action).

I really hope the process of rearranging dashboard cards and entities will be improved in the future.

home-assistant, esphome, node-red
Similar posts: