My Digital Garden

JPNAS.NET / Digital Garden

🌳 EvergreenLast updated:

Constructing a Smart Home

A smart home that keeps working when the Internet – or the manufacturer – goes away: a short history from X10 to Matter and the clouds that were switched off, how the pieces fit together, what to check before buying a device, and step-by-step examples with Home Assistant, Zigbee2MQTT, automations, an ESPHome fan controller and a Shelly plug.

Open in the interactive Digital Garden

What You Need
A small always-on computer for Home Assistant: a used mini PC, a Raspberry Pi 4 or 5 with an SSD, or the ready-made Home Assistant Green (Example 1)
For Zigbee devices: a coordinator – a USB stick such as the Home Assistant Connect ZBT-2, or a network coordinator (Example 2)
For your own devices: an ESP32 board, a sensor and a relay, and ESPHome (Example 4)
Ideally a separate network (VLAN) for smart devices and a VPN for access from outside – see Computer Networks
Background: what the devices know about you is in Privacy of Smart Devices, MQTT and the first ESPHome steps in Network Door Opener and Microcontroller Communication

Jump to Examples

After the Network Door Opener and the note about the Privacy of Smart Devices, the next step was obvious: a smart home that keeps working when the Internet – or the manufacturer – goes away. A light switch should not need a server in another country. This note is about how to build that: what the pieces are, what to look for when buying, and how to put it together with open-source software. My own setup is being built right now: Example 1 is done (3 November 2026), Examples 2–5 are the plan I'm following and not yet tested on my own hardware.

A Bit of Smart Home History

The smart home is older than the Internet in most homes. X10 was developed in 1975 by Pico Electronics in Glenrothes, Scotland, and the first products were sold in 1978. It sent commands over the normal power wiring – short bursts at 120 kHz, timed to the moment the mains voltage crosses zero – at about 20 bits per second. Slow, sometimes unreliable, but enough for "lamp 3, on", and X10 modules were still sold decades later.

Around 2000 radio took over. Z-Wave started at the Danish company Zensys in 1999 and works below 1 GHz (around 868 MHz in Europe); in 2018 the technology went to Silicon Labs, and since 2020 the standard itself is run by the independent Z-Wave Alliance. The Zigbee Alliance was founded in 2002 and ratified the first Zigbee specification in December 2004: a low-power mesh network on 2.4 GHz, where every mains-powered device also passes messages on for the others. In October 2012 Philips launched Hue, Zigbee light bulbs controlled from a phone, and the idea reached ordinary homes.

In September 2013 Paulus Schoutsen started Home Assistant, a Python program that connected devices of different makers in one place, on your own computer. It grew into a huge community project, and since April 2024 it belongs to the non-profit Open Home Foundation, together with ESPHome and other projects. The commercial side went the other way: Nest, Echo and Alexa, everything through the manufacturer's cloud (that story is in Privacy of Smart Devices).

And then the clouds started to switch off. A few examples:

  • Revolv (2016): a 299-dollar smart-home hub. Nest bought the company in 2014 and switched the service off on 15 May 2016. The hubs became useless.
  • Insteon (2022): in April 2022 the company shut down its servers without warning – the app and all automations stopped. The switches on the wall still worked, and owners were pointed to Home Assistant and openHAB to control them locally. New owners revived the service in June 2022 – with a subscription.
  • Belkin Wemo (2026): the cloud and the app for most Wemo devices ended on 31 January 2026. Devices that had been added to Apple HomeKit before that keep working locally, as do a few Thread models; for the rest the official app and voice control are gone.

The industry's answer is Matter. Amazon, Apple, Google and the Zigbee Alliance (renamed the Connectivity Standards Alliance in May 2021) started the work in 2019, and Matter 1.0 was released on 4 October 2022. A Matter device is controlled over the local network, over Wi-Fi, Ethernet or the Thread mesh, and several systems (Apple Home, Google, Alexa, Home Assistant) can control it at the same time. It is a real improvement – but many devices and features still arrive slowly, and plenty of things in shops are still cloud-only.

The lesson of fifty years: the devices last longer than the companies' interest in running servers for them. A smart home you will still like in ten years is one where the important things happen in your house.

How a Smart Home Is Put Together

Under all the brand names it's always the same four layers:

  1. Devices – sensors that measure (temperature, a door contact, motion, water on the floor) and actuators that do something (a relay, a bulb, a plug, a valve).
  2. The radio or cable they use to talk – Wi-Fi, Zigbee, Z-Wave, Thread, Bluetooth or Ethernet.
  3. The centre that collects everything, remembers the history and runs the rules – in my case Home Assistant, often with an MQTT broker (Mosquitto) next to it.
  4. People – a dashboard on the phone or a wall tablet, notifications, voice, and still the switch on the wall.
Zigbee sensors Wi-Fi plug (Shelly) ESP32 (ESPHome) coordinator + Zigbee2MQTT Home Assistant rules, history phone / tablet at home or via VPN manufacturer's cloud
Everything talks to the centre at home. The phone reaches it on the home network or through a VPN, and the manufacturer's cloud isn't needed for anything that matters.

Which radio for what. The protocols themselves are described in Privacy of Smart Devices; here is how I'm choosing between them:

RadioGood forWatch out for
Zigbeebattery sensors that last a year or more, bulbs, switches; huge choice, cheap, works without any cloud through a coordinator2.4 GHz like Wi-Fi – choose the channel; battery devices need mains-powered "routers" nearby
Wi-Fiplugs with power metering, relays, things that need more power; no extra hubeach device is a computer on your network – put them in a separate VLAN, prefer ones with a local API
Z-Wavelong range through walls, sub-GHz, no interference with Wi-Fifewer devices, usually pricier than Zigbee; needs its own stick
Thread / Matternew devices that work with several systems at once, local by designsupport still uneven; a radio like the ZBT-2 does either Zigbee or Thread, not both at once
ESPHome (own devices)anything you want to build: weather station, door opener, fan controller – fully yours, no appyou are the manufacturer: updates, safety of mains wiring

Where the logic lives. The most important design decision is not the brand, it's where a rule runs. A rule in the manufacturer's cloud stops when the Internet is down. A rule in Home Assistant keeps working without the Internet, but not when Home Assistant restarts. A rule on the device itself (a thermostat in ESPHome, a Shelly that turns off after an hour) keeps working even then. So the things that must never fail – cooling, a water valve, the door – I want on the device, and Home Assistant only watches and adjusts.

Before You Buy: Local First

My short checklist for every device:

  • Does it work without the Internet? Unplug the router's Internet cable once and try. Matter, Zigbee and Z-Wave devices do; for Wi-Fi devices look for a local API (Shelly, ESPHome, Tasmota, WLED).
  • Is it supported? For Zigbee, look the exact model up in the Zigbee2MQTT device list before buying; for everything else in the Home Assistant integrations.
  • Does the switch on the wall still win? Smart relays behind existing switches (rather than smart bulbs that die when someone uses the switch) keep the house normal for everybody.
  • What happens after a power cut? Plugs and relays usually have a setting for this ("on", "off", "as before"). For a fridge or a server it must be "on".
  • Batteries: which type, and does the device report the level? A sensor that silently dies is worse than none.
  • Updates and the end: how long will the maker publish firmware, and can you flash open firmware when they stop?

My Own Setup

What I'm building, in the order I'm building it:

  • The centre: Home Assistant OS on a used office mini PC (a Lenovo ThinkCentre Tiny with a 4-core i3, 16 GB RAM and a 256 GB NVMe SSD), separate from my home server. I expect it to idle at around 10 watts (I'll measure it with the plug from Example 5), and nothing else runs on it, so an update of the server never switches off the lights.
  • The network (planned): Home Assistant and all smart devices in their own VLAN; from the main network you can reach them, they can't reach the main network – with one exception, Home Assistant may reach the NAS share for its backups. From outside only through WireGuard – Home Assistant is never published on the Internet.
  • Measuring power of both servers with Wi-Fi plugs (Example 5).
  • Zigbee sensors for temperature and humidity in the rooms, water leak sensors under the dishwasher and the boiler, door and window contacts (Example 2).
  • A fan controller for the network cabinet with ESPHome (Example 4), then the weather station and finally the door opener.

Examples

Example 1: Home Assistant OS on a Mini PC

Home Assistant comes in several forms. Home Assistant OS is the complete appliance – a small Linux with Home Assistant, extra programs (Mosquitto, Zigbee2MQTT, ESPHome) and backups managed for you. These extra programs were called add-ons for years; since version 2026.2 they are called apps. It wants the whole machine. If you already have a server with Docker, Home Assistant also runs as a container (as in Constructing a Cloud), but then without apps. For a dedicated mini PC, the OS is the easy way.

  1. BIOS: UEFI boot on, Secure Boot off, and "After Power Loss: Power On", so it starts again by itself after a power cut. The boot disk must have 512-byte sectors (most SSDs do; some native-4K NVMe drives won't boot).
  2. Download haos_generic-x86-64-<version>.img.xz from the operating-system releases.
  3. Write it to the internal disk. The official guide recommends booting the mini PC from an Ubuntu live USB stick and using Disks → Restore Disk Image onto the internal SSD. The second method, meant for when the first one fails, is to take the SSD out, put it into a USB adapter or enclosure, and write the image from another computer (balenaEtcher; I used Rufus on Windows – it hides disks in USB enclosures until you tick List USB Hard Drives in its advanced drive options). That's what I had to do: this particular mini PC refused to boot from any USB stick, so I took the 2242 NVMe out, wrote the image through a 10 Gbit/s USB-C enclosure and put it back. It booted on the first try.
  4. Connect the network cable and switch it on. The first start downloads the rest of Home Assistant, so give it a few minutes, then open http://homeassistant.local:8123 (or the IP address with :8123).
  5. First setup: create the owner account with a strong password, then in your profile turn on multi-factor authentication (an authenticator app). Give the machine a fixed address with a DHCP reservation in the router.
  6. Backups straight away: since version 2025.1 Home Assistant makes automatic, encrypted backups and can send them to a network share. Run the backup wizard, save the encryption key (emergency kit) in your password manager, and point it to your NAS. More about why in Constructing a Backup.

One setting worth knowing: by default the database keeps detailed history for 10 days (purge_keep_days). For longer periods Home Assistant keeps hourly long-term statistics by itself, which is enough for most graphs; only if you want years of data at full resolution is it worth sending it to InfluxDB instead of making the SQLite file huge.

Example 2: Zigbee with Zigbee2MQTT

There are two ways to use Zigbee in Home Assistant: the built-in ZHA integration, or Zigbee2MQTT, a separate program that translates Zigbee to MQTT messages. ZHA is simpler to start. I'm going with Zigbee2MQTT because it supports a very long list of devices, has its own web page with a map of the mesh, and the data is plain MQTT that other programs can read too.

  1. The coordinator. A USB stick like the Home Assistant Connect ZBT-2 (November 2025, about 45 euros, Zigbee or Thread), or a coordinator on the network with Ethernet that you can put in the middle of the house. The ZBT-2 comes with its own 1.5 m cable; a classic USB stick goes on a short (about 50 cm) extension cable. Either way, keep it away from the computer's USB 3 ports, SSDs and the Wi-Fi router – USB 3 creates noise right in the 2.4 GHz band (more tips in the Zigbee2MQTT guide).
  2. Install the apps. Mosquitto broker is in the official store (Settings → Apps → Install app). Zigbee2MQTT isn't: in the store open the menu → Repositories, add https://github.com/zigbee2mqtt/hassio-zigbee2mqtt, then install it from the list. Start Mosquitto first and add the MQTT integration.
  3. The configuration. Home Assistant's own Zigbee integration (ZHA) usually discovers the stick first: delete and ignore that discovered entry, otherwise both fight for it. On the first start Zigbee2MQTT shows an onboarding page where you choose the adapter; the result is saved in its configuration.yaml, which for a ZBT-2 should look roughly like this (serial settings from Nabu Casa):
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://core-mosquitto:1883     # the Mosquitto app
  user: zigbee2mqtt                      # a Home Assistant user made for this
  password: "..."
serial:
  port: /dev/serial/by-id/usb-Nabu_Casa_ZBT-2_<serial>-if00-port0
  adapter: ember                         # ember for Silicon Labs chips, zstack for TI
  baudrate: 460800                       # these two are needed for the ZBT-2
  rtscts: true
advanced:
  channel: 25
  network_key: GENERATE                  # a random key on first start - keep a backup
  pan_id: GENERATE
  ext_pan_id: GENERATE
frontend:
  enabled: true
homeassistant:
  enabled: true                          # devices appear in Home Assistant by themselves
  1. The channel. Zigbee and Wi-Fi share the 2.4 GHz band. Zigbee2MQTT recommends channel 11, 15, 20 or 25; pick the one furthest from your Wi-Fi. With Wi-Fi on channels 1 and 6, Zigbee 25 sits above both. Decide before pairing devices – changing it later is possible, but some devices then have to be paired again.
  2. Pair mains-powered devices first (plugs, bulbs, relays). They become routers and make the mesh strong; battery sensors come after. Click Permit join, hold the button on the device until it blinks, and it appears with its name and all its sensors.

Example 3: Two Automations I Want First

Most automations can be clicked together in the editor, but the YAML shows clearly what happens. The first one is the "away mode" from the documentation: when the number of people at home (the zone.home entity, fed by the Companion app on the phones) drops to zero, all lights go off. Before trusting it, check that zone.home really shows the right number.

- alias: "Away mode"
  description: "Turn off the lights when everybody leaves"
  triggers:
    - trigger: state
      entity_id: zone.home
      to: "0"
  actions:
    - action: light.turn_off
      target:
        entity_id: all

The second one is the reason I want water sensors at all: a message to the phone the moment one of them gets wet. The entity names are examples – yours are shown in the device page.

- alias: "Water leak"
  triggers:
    - trigger: state
      entity_id:
        - binary_sensor.dishwasher_leak
        - binary_sensor.boiler_leak
      to: "on"
  actions:
    - action: notify.mobile_app_my_phone
      data:
        title: "Water!"
        message: "{{ trigger.to_state.name }} is wet."

Test both by hand: set the state in Settings → Tools → States (called Developer tools before 2026.2), or put a wet cloth on the sensor. An alarm you never tested is a hope, not an alarm.

Example 4: A Fan Controller That Decides on Its Own

My network cabinet gets warm in summer. The fan should switch on above 27 °C and off below 25 °C – and that must work even when Home Assistant is restarting or broken. So the rule goes into the device: an ESP32 with a DS18B20 temperature sensor and a relay (or a MOSFET for a 12 V fan), with ESPHome's thermostat component. Home Assistant only shows the temperature and lets me change the target.

# rack-fan.yaml - fan in the network cabinet, decides on its own
esphome:
  name: rack-fan

esp32:
  board: esp32dev

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

logger:

api:                      # Home Assistant connects here (encrypted)
  encryption:
    key: !secret api_key

ota:
  - platform: esphome
    password: !secret ota_password

one_wire:
  - platform: gpio
    pin: GPIO4            # DS18B20 data pin (with a 4.7 kOhm pull-up to 3.3 V)

sensor:
  - platform: dallas_temp
    id: rack_temp
    name: "Rack temperature"
    update_interval: 30s

switch:
  - platform: gpio
    id: fan_relay
    name: "Rack fan"
    pin: GPIO26           # relay or MOSFET module

climate:
  - platform: thermostat
    name: "Rack cooling"
    sensor: rack_temp
    min_cooling_off_time: 60s
    min_cooling_run_time: 120s
    min_idle_time: 30s
    cool_deadband: 1 °C     # on above 26 + 1 = 27 °C
    cool_overrun: 1 °C      # off below 26 - 1 = 25 °C
    cool_action:
      - switch.turn_on: fan_relay
    idle_action:
      - switch.turn_off: fan_relay
    default_preset: Normal
    on_boot_restore_from: default_preset   # after a restart always back to Normal
    preset:
      - name: Normal
        default_target_temperature_high: 26 °C
        mode: COOL

The two numbers cool_deadband and cool_overrun make the gap between "on" and "off" (hysteresis), so the fan doesn't click on and off every few seconds around one temperature; the minimum run and off times protect the relay too. The passwords and keys live in secrets.yaml, which never goes into Git. The file passes esphome config rack-fan.yaml (ESPHome 2026.10.2), but I haven't built the controller yet; pin numbers depend on your board. With on_boot_restore_from: default_preset the thermostat returns to cooling mode after every restart, even if somebody switched it off in Home Assistant. What it does if the sensor itself fails I still have to test – until then, an alert in Home Assistant when the temperature becomes unavailable is a good idea. And the plan is a 12 V fan through a MOSFET, so nothing in the box is at mains voltage. Flash it once over USB from the ESPHome app, and after that updates go over Wi-Fi.

Example 5: Measuring a Server's Power with a Shelly Plug

Shelly devices have a local API; from the second generation on it is the RPC API shown here, so they work without the Shelly cloud and Home Assistant finds them by itself. Before adding one, you can talk to it directly from any computer on the same network (replace the address with your plug's):

# state, power in watts (apower) and total energy in Wh (aenergy.total)
curl "http://192.168.1.50/rpc/Switch.GetStatus?id=0"

# after a power cut: always switch on (the plug powers a server!)
curl -g "http://192.168.1.50/rpc/Switch.SetConfig?id=0&config={\"initial_state\":\"on\"}"

These work in a Linux or macOS terminal and in Windows cmd; in PowerShell use curl.exe and check the quotes.

Then add the Shelly integration in Home Assistant and put the energy sensor into the Energy dashboard. Two things I'd do with a plug that powers a server: set the power-on state to "on" (above), and hide or disable its on/off switch in Home Assistant, so nobody switches off the server – or Home Assistant itself – with one wrong tap. And in the Shelly's own settings turn off the cloud connection if you don't use it.

Keeping It Safe

  • Never publish Home Assistant on the Internet with a port forward. Use a VPN (WireGuard, as in Constructing a Cloud) or the paid Home Assistant Cloud.
  • A separate network for smart devices. They may reach Home Assistant, not your computers and NAS. Block Internet access for devices that don't need it.
  • Multi-factor authentication for every Home Assistant user, and separate non-admin accounts for the family.
  • Backups, and the Zigbee network key. Without the coordinator's backup you pair every device again. Home Assistant's encrypted backups plus a copy elsewhere (3-2-1).
  • Updates, but not on a Friday evening. Read the release notes ("breaking changes") before updating, and take a backup first.
  • Mains voltage is not a hobby for guessing. Relays behind wall switches and in the fuse box belong to someone who knows the rules – in many countries legally an electrician.

A Few More Thoughts

What I like about this way of building a smart home is that it's boring in the right places. The light switch works like a light switch. The fan in the cabinet runs when it's hot, whether or not anything else is working. Home Assistant adds the comfortable part – graphs, notifications, one app for everything – but nothing important depends on a company's server staying online.

It is more work than buying a box with an app, and I won't pretend otherwise. But the work is done once, and the knowledge stays. Revolv, Insteon and Wemo owners learned what happens the other way. With open software and local devices, the house belongs to you – and so does the decision when a device is too old.

← All notes