Python · IoT · CrateDB · Docker · Apache Superset
Overview
The data source is a TP-Link Tapo H200 hub with T315 temperature and humidity sensors. A Python collector starts up, auto-discovers all T315 sensors registered under the H200, and polls them roughly every 60 seconds, writing readings to a CrateDB time-series database. Apache Superset provides dashboards. The whole stack is packaged as Docker Compose and runs on a Synology NAS or any Docker host. The H200 hub API gives no online/offline status for child sensors: after a sensor drops, the hub keeps returning the last cached reading. The system cross-checks four signals to detect stale data and writes NULL for temperature and humidity when at least N checks fail, logging the event tostale.log.
Core features
- Auto-discovers all T315 sensors under the H200 on startup, no manual device list required
- Collects temperature, humidity, battery level, and RSSI every ~60 seconds
- Four-signal cross-validation (RSSI threshold, RSSI freeze, simultaneous temperature and humidity freeze, device_time freeze): stale only when at least N checks fail (default N=2), avoiding single-signal false positives
- Stale readings write NULL to temperature and humidity columns, preserving
is_validandstale_reasons; events are also written tostale.log - Apache Superset dashboards with pre-built per-minute, hourly, daily, weekly, and monthly aggregate views
- Optional Cloudflare Tunnel for remote access without opening inbound ports
- Automatic reconnect and retry on failure,
restart: unless-stopped
Architecture
climate-monitor
src/climate_monitor
core
collector.py · main polling loop
tapo_client.py · H200 communication
validator.py · four-signal validator
infra/database.py · CrateDB client
config.py · environment variable loading
main.py
docker
docker-compose.pc.yml · local development
docker-compose.prod.yml · NAS / production
scripts/init_db.sql · CrateDB schema initializer
Quick start
1
Set environment variables
2
Start all services (NAS / production)
3
Initialize Superset (first run only)
4
Initialize the CrateDB schema
Open
http://NAS-IP:4200 in a browser and run scripts/init_db.sql in the SQL console. The service does not create tables automatically.5
Verify the collector is running
Stale-data validation
The H200 API does not expose child device connection state, and the hub continues to return cached values after a sensor disconnects. The system cross-checks four signals: A reading is marked stale only when at leastVALIDATOR_MIN_FAILED_CHECKS (default 2) checks fail simultaneously. The freeze window is computed from frozen_window / collection_interval.
Notes
In practice
Suitable for any long-term, low-cost multi-point temperature and humidity monitoring: lab environment logging, server room baseline monitoring, home climate management. The stale validation gives NULL values a precise meaning (sensor offline) rather than silently persisting incorrect data, making it straightforward to exclude invalid intervals in downstream analysis.Links
- GitHub: felimet/climate-monitor
- CrateDB docs: cratedb.com/docs
- Apache Superset docs: superset.apache.org/docs