Using CUE to unify IoT sensor data
a day ago
- #home-automation
- #IoT
- #CUE
- The author built a home automation system using CUE to unify IoT sensor data from various IKEA Zigbee devices.
- Home Assistant and Node-RED were initially used but proved limiting for complex logic, leading to a custom Go service.
- The system architecture involves Zigbee sensors connected via zigbee2mqtt, which bridges to an MQTT broker, with a Go service processing the data.
- Different sensor types (IKEA TRÅDFRI and VALLHORN) report data in different formats, complicating data processing.
- CUE is used to validate and transform sensor data into consistent structures, eliminating the need for type switches in Go.
- CUE schemas define required and optional fields, handle conditional logic, and normalize data from different sensors.
- The Go code becomes generic, with CUE handling validation and transformation, simplifying the addition of new sensor types.
- CUE provides advantages over alternatives like JSON Schema and Protocol Buffers by combining validation and transformation.
- Future plans include extending the system to handle outbound MQTT commands for different bulb types and more sensor types.