DEV Community

Cover image for Stop Building “Remote Controls.” Build an Automation Engine
STONE module
STONE module

Posted on

Stop Building “Remote Controls.” Build an Automation Engine

Most smart home projects stall at the same point. You buy a smart plug. You open the app. You tap a button. The lamp turns on. It feels like progress — until you realize you have built a very expensive remote control.

The STONE article on smart home automation draws a distinction that every developer should internalize before writing a single line of integration code: a smart device responds to a command; an automated home evaluates a condition and acts without anyone asking. The gap between those two things is not hardware. It is architecture.

The Loop You Are Actually Building

A functioning automation system is a closed loop. Sensors produce state. A logic layer evaluates that state against rules. Actuators receive commands. The loop runs continuously, mostly without human input.

In a developer-friendly stack, that loop maps cleanly onto three concerns:

Ingestion: devices publish state to a message bus.

Evaluation: a rule engine subscribes to that bus and decides what should happen.

Dispatch: commands go back out to the devices that can change the physical world.

The mistake is collapsing these into a single process. When your sensor firmware directly calls your light’s HTTP endpoint, you have created a point-to-point dependency that breaks the moment either device changes, goes offline, or gets replaced. The MQTT pub/sub model exists precisely to decouple these concerns: devices publish to a broker; the logic layer subscribes; neither side needs to know the other’s address.

Home Assistant as the Evaluation Layer, Not the Whole System

Home Assistant is often described as a “hub,” which undersells what it actually is. Architecturally, it is a local-first event loop that integrates thousands of device protocols — Matter, Zigbee, Z-Wave, Wi-Fi, Bluetooth — and exposes them as entities that automations can reason about. It is the evaluation layer. It is not the message bus, and it is not the device.

The cleaner design separates them. Run an MQTT broker (Mosquitto is the obvious starting point) as the message backbone. Let devices — ESP32 sensors, Tasmota-flashed plugs, Zigbee bridges — publish state to that broker. Let Home Assistant subscribe, evaluate, and publish commands back. The result is a system where you can swap a Zigbee temperature sensor for a Wi-Fi one without rewriting the automation that depends on it, because the automation is subscribed to a topic, not to a device.

MQTT Discovery Is the Glue Worth Learning
The single highest-leverage implementation detail in this stack is MQTT Discovery. Instead of manually defining every sensor in configuration files, a device publishes a retained JSON payload to a discovery topic. Home Assistant picks it up and creates the entity automatically.

A minimal discovery payload for a temperature sensor looks like this:

Published to homeassistant/sensor/livingroom_temp/config, this payload registers the entity, binds it to a physical device, and makes it available to automations without any manual YAML. The device becomes self-describing. That property matters more than it first appears: it means the automation layer does not need to be redeployed when hardware changes.

The Automation Itself Should Be Boring

Once the plumbing is in place, automations should read like state machines, not scripts. A trigger fires on a state transition. Conditions constrain the context. Actions dispatch commands.

This is deliberately unglamorous. It is also deterministic, idempotent, and debuggable. When it fails — and it will — you can inspect three separate concerns: did the sensor publish? did the condition evaluate correctly? did the action reach the actuator?

The Real Lesson

Smart home automation is not a hardware problem. The devices are cheap and increasingly interoperable. The hard part is resisting the urge to build point-to-point remote controls and instead investing in a decoupled loop where state flows into a bus, logic evaluates it, and commands flow back out. Build that loop once, and every device you add afterward becomes a new input or output — not a new integration project.

Top comments (0)