How kairui1108/cuktech-ble-ha works
The repository provides three ways to connect a CUKTECH charger to Home Assistant: a Python BLE gateway, an ESP32 bridge, and the Home Assistant integration that consumes gateway MQTT data. The main Python flow is charger telemetry and commands through BLE management into shared state, then HTTP/MQTT and the web interface; the ESP32 offers a standalone alternative. The README documents these product capabilities, while edges between unsampled subsystems are omitted or marked unverified rather than inferred.
Main entry points: ha_server.py HTTP and MQTT server · ble_manager.py BLE manager · main.c Firmware runtime · __init__.py Integration coordinator
Components 23
Python BLE gateway
- BLE manager
ble_server/ble_manager.py - BLE controller
ble_server/src/cuktech_ble/controller.py - BLE protocol
ble_server/src/cuktech_ble/protocol.py - Charger state
ble_server/state.py - Energy tracking
ble_server/energy.py - SQLite history
ble_server/history.py - HTTP and MQTT server
ble_server/ha_server.py - Xiaomi Cloud setup
ble_server/xiaomi_cloud.py - Bemfa cloud client
ble_server/bemfa_client.py
ESP32 bridge
- Firmware runtime
esp32_ble/main/main.c - BLE manager
esp32_ble/main/ble_manager.c - HTTP server
esp32_ble/main/http_server.c - Bemfa client
esp32_ble/main/bemfa.c
Home Assistant integration
- Integration coordinator
ha_integration/custom_components/cuktech_charger/__init__.py - Charge limit engine
ha_integration/custom_components/cuktech_charger/energy_engine.py - Sensors
ha_integration/custom_components/cuktech_charger/sensor.py - Switch controls
ha_integration/custom_components/cuktech_charger/switch.py
Web management
- Web UI
ble_server/web/static/app.js - Charge history UI
ble_server/web/static/charge_history.js - Charge limit UI
ble_server/web/static/charge_limit.js
Other components
- CUKTECH charger
- MQTT broker
- Home Assistant
Connections 27
- CUKTECH charger → BLE manager: BLE connects
README.md - BLE manager → BLE controller: uses
ble_server/ble_manager.py - BLE manager → Charger state: updates
ble_server/ble_manager.py - BLE manager → Energy tracking: uses
ble_server/ble_manager.py - BLE manager → SQLite history: records
ble_server/ble_manager.py - BLE controller → BLE protocol: uses
ble_server/src/cuktech_ble/controller.py - HTTP and MQTT server → BLE manager: commands
ble_server/ha_server.py - HTTP and MQTT server → Charger state: reads
ble_server/ha_server.py - HTTP and MQTT server → SQLite history: queries
ble_server/ha_server.py - HTTP and MQTT server → Xiaomi Cloud setup: uses
ble_server/ha_server.py - HTTP and MQTT server → Bemfa cloud client: uses
ble_server/ha_server.py - HTTP and MQTT server → Web UI: serves
README.md - Web UI → HTTP and MQTT server: calls API
- Charge history UI → HTTP and MQTT server: requests history
- Charge limit UI → HTTP and MQTT server: sets limits
- Firmware runtime → BLE manager: dispatches
esp32_ble/main/main.c - Firmware runtime → HTTP server: uses
esp32_ble/main/main.c - Firmware runtime → Bemfa client: uses
esp32_ble/main/main.c - BLE manager → CUKTECH charger: BLE connects
README.md - Firmware runtime → MQTT broker: publishes
README.md - MQTT broker → Integration coordinator: delivers data
README.md - Integration coordinator → Charge limit engine: feeds samples
ha_integration/custom_components/cuktech_charger/__init__.py - Integration coordinator → Sensors: updates entities
ha_integration/custom_components/cuktech_charger/sensor.py - Integration coordinator → Switch controls: updates entities
ha_integration/custom_components/cuktech_charger/switch.py - Home Assistant → Switch controls: controls
- Home Assistant → Sensors: views
- HTTP and MQTT server → MQTT broker: publishes
README.md