I’ve been building a home automation system that processes motion sensor data from various IKEA Zigbee devices. Each sensor type sends a different data structure, and I needed to extract consistent information from all of them without sacrificing type safety.
I spent a long time trying to make Home Assistant work for my setup. The visual automation builder felt limiting once I needed conditional logic beyond simple triggers, and writing automations in YAML became tedious. Adding complex logic like correlating motion across multiple rooms or applying time-weighted logic was difficult. I ended up fighting the system rather than solving the problem.
My current home automation setup looks like this:
┌─────────────┐ ┌─────────────┐ │ TRÅDFRI │ │ VALLHORN │ │ Sensor │ │ Sensor │ └──────┬──────┘ └──────┬──────┘ │ │ └────────┬───────┘ Zigbee │ ▼ ┌──────────────────┐ │ zigbee2mqtt │ │ (Zigbee bridge) │ └────────┬─────────┘ │ ▼ ┌──────────────────┐ │ MQTT Broker │ │ │ │ Topics: │ │ bedroom/motion │ │ hallway/motion │ │ kitchen/motion │ └────┬─────────┬───┘ │ │ │ │ JSON messages ┌───────┘ └───────┐ ▼ ▼ ┌──────────────┐ ┌──────────────┐ │ Node-RED │ │ Home │ │ │ │ Assistant │ │ - Visual │ │ │ │ flows │◄────►│ - Visual │ │ - Custom │ │ automata │ │ logic │ │ - YAML │ └──────────────┘ └──────┬───────┘ │ │ HTTP API ▼ ┌──────────────────┐ │ Philips Hue Hub │ │ │ │ ┌────┐ ┌────┐ │ │ │Bulb│ │Bulb│ │ │ └────┘ └────┘ │ │ │ │ ┌──────┐ │ │ │Sensor│ │ │ └──────┘ │ └──────────────────┘
With Home Assistant and Node-RED handling some of my automation logic, and controlling devices through various hubs like Philips Hue. This works for many people, but I wanted more control and flexibility that I knew I could get with a custom Go service. I could build exactly what I wanted with the language I already knew.
I’m building a Go service to replace this entire automation layer—Home Assistant, Node-RED, and the device-specific hubs. The service subscribes directly to MQTT topics where zigbee2mqtt publishes sensor data, processes that data, and sends commands back to control lights and other devices.
The system architecture #
The sensors connect via Zigbee, a low-power wireless protocol common in home automation. I’m running zigbee2mqtt which bridges between Zigbee devices and an MQTT broker. My Go service subscribes to MQTT topics and processes the JSON messages that sensors publish whenever their state changes.
Currently, I’m using two different sensor types:
IKEA TRÅDFRI motion sensor – the older model that reports light levels as a boolean
... continue reading