Switch to connect→poll→disconnect per cycle (single-connection BMS fix)

The BMS only allows one simultaneous BLE connection. Keeping a persistent
connection blocked the mobile app from connecting at all.

Changes:
- BmsBluetoothHandler: replace connect()/disconnect()/request() public API
  with a single poll() method that owns the full connect→read→disconnect
  lifecycle. Connection is held only for the duration of one data fetch.
- Coordinator: gutted connection-state management — _async_update_data now
  just calls handler.poll() and processes results. No reconnect loop needed.
- Poll interval defaults: 15s default, 10s min, 300s max. The BLE connect
  overhead (~2s) makes sub-10s intervals impractical.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-11 20:09:43 +02:00
parent af608792da
commit 3fc25c083b
3 changed files with 79 additions and 114 deletions
+3 -3
View File
@@ -5,9 +5,9 @@ DOMAIN = "xiaoxiang_bms"
CONF_ADDRESS = "address"
CONF_POLL_INTERVAL = "poll_interval"
DEFAULT_POLL_INTERVAL = 5 # seconds — fast for solar/energy monitoring
MIN_POLL_INTERVAL = 2
MAX_POLL_INTERVAL = 60
DEFAULT_POLL_INTERVAL = 15 # seconds — each poll does a full BLE connect/disconnect
MIN_POLL_INTERVAL = 10 # below this the BMS has no breathing room between polls
MAX_POLL_INTERVAL = 300
# GATT UUIDs (Xiaoxiang BMS UART-over-GATT)
UART_SERVICE_UUID = "0000ff00-0000-1000-8000-00805f9b34fb"