HomeDomoticaCollector
A Raspberry Pi hub that collects data from every device in my home — solar, weather, EV charger, awnings, thermostats, AC — stores it, and lets me monitor and control everything from a Telegram bot, a LAN web dashboard, and by voice through Alexa.
The idea
My home is full of “smart” devices, each with its own app and portal: solar inverter, weather station, EV charger, sun awnings, thermostats, air conditioners. I wanted one place to see everything, keep its history, and automate how it behaves. So I built a small hub running on an always-on Raspberry Pi.
What it does
It polls the various home systems on a schedule and stores their readings in a SQLite database:
- Solar & battery — production, consumption, state of charge, energy flows.
- Weather station — temperature, humidity, wind, rain, pressure, UV.
- EV charger — status and energy delivered (OCPP protocol).
- Sun awnings — state and position (Somfy TaHoma).
- Thermostats — temperature, setpoint and mode per zone.
- Air conditioners — status and control (Sensibo).
And it offers three ways to interact:
- Telegram bot with inline menus — status of everything plus direct control: open/close the awnings, set thermostat modes, turn on/adjust the AC, start/stop charging, enable or disable the automations.
- LAN web dashboard — a read-only view of the latest readings and history charts, with a light/dark theme.
- Alexa voice control — a custom skill to ask for status, command the awnings, and run “scenes”.
The automation engine
The “smart” core is a rule engine: rules are defined in the configuration and evaluated after every weather poll. Examples: close the awnings on wind or rain, put the thermostats into frost protection, switch on the AC when the conditions are right.
Rules support multiple AND conditions across different sources (weather, solar, thermostats), time windows, and two priority levels: critical rules (e.g. strong wind) can fire multiple times and lock out the normal rules on the same devices for the rest of the day.
How it’s built
- A Python (async) app on a Raspberry Pi 4, run as a systemd service with automatic restart and network-wait.
- Modular collectors, one per device family, sharing a common base class; a scheduler polls each at its own interval. Readings go to SQLite with automatic migrations.
- The bot, dashboard and Alexa all read the same tables — no duplicate polling.
Engineering notes
- Cloudflare Tunnel exposes the HTTPS endpoint for Alexa without opening any ports on the router: the Pi’s IP stays private and TLS is handled by Cloudflare. The dashboard, by contrast, is deliberately kept LAN-only.
- Resilience: the optional features (Alexa, dashboard) are guarded so a failure can never take down the collector; a network watchdog reboots the Pi after a prolonged loss of connectivity.
- Pragmatic fixes: where
urllibtimed out on the Pi I shelled out tocurl; OAuth tokens are refreshed and persisted across restarts. - Handles device quirks (e.g. one awning wired in reverse — open and close swapped in software).
Stack
Python (async) · Raspberry Pi 4 · SQLite · Telegram Bot · aiohttp · OCPP · Cloudflare Tunnel · systemd
Next steps
- Switch SQLite to WAL mode if write contention shows up.
- Add more thermostat zones.
- Expand the Alexa intents.