
The One
Home Automation Re-architecture
Overview
The Problem
Tecnel MC ran an existing home automation system that controlled lights, cameras, sensors, and access in a facility with many devices. It worked, but it started collapsing with just a few devices: rising latency, frequent crashes, and the server under constant load. The client needed to expand to 1000+ devices, but the existing architecture made that impossible.
Code analysis revealed the root cause: every device was polling the server over HTTP every second, asking whether there were updates, even when nothing had changed. With 200 devices, this meant 200 requests per second at idle. At 1000 devices it would be 1000 requests per second just standing still. The server couldn't cope, and the polling even took down the office's internet connection.
The Solution
I re-architected the system starting from the communication layer. I replaced HTTP polling with persistent WebSockets: devices open one connection and receive notifications only when there's something to communicate. Idle load dropped to near zero. To further reduce traffic I introduced custom binary serialization instead of JSON: device status messages compress by 80%.
Every IoT device manufacturer uses different proprietary protocols. I wrote custom parsers for each protocol present in the facility, with an abstraction layer that exposes them all through the same interface to the frontend. Redux Toolkit manages the global state of every device predictably, using incremental diffs instead of full replacements.
The architecture is hybrid to guarantee continuity: local Redis handles real-time state and immediate commands (if internet goes down, the facility still works), cloud MongoDB syncs logs and configurations and handles remote access. A health monitoring system with auto-recovery detects offline or erroring devices and attempts automatic restoration before alerting the team. I also added multi-hub management and an invitation system with temporary permissions.
The Result
The reconnection-burst crash was eliminated with exponential backoff on the Socket.IO client. Three protocol parsers were written and integrated. I rebuilt the whole existing system with WebSocket, Redis and MongoDB and went beyond what was asked. The project was delivered up to the point agreed with the client.
Key Features
- Reconnect burst crash fixed: exponential backoff on the Socket.IO client
- 3 custom protocol parsers written to integrate devices from different manufacturers
- Re-architected with WebSocket + local Redis + cloud MongoDB, delivered up to the point agreed with the client
- Multi-hub management and invitations with temporary permissions