Refactor BLE layer for 24/7 reliability
- Replace raw BleakClient with establish_connection from bleak-retry-connector (retries, GATT service cache, proxy-aware) - Replace fragile asyncio.Event with asyncio.Queue for response frames, drain stale data on each connection to prevent cross-cycle leakage - Register BLE advertisement callback to keep BLEDevice reference fresh across ESPHome proxy path changes - Remove asyncio.sleep(2) device lookup hack - Increase poll timeout floor from 10s to 20s - Increase failure tolerance from 3 to 5 consecutive misses - Bump default poll interval to 30s, min to 15s (halves connection churn) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,8 +5,8 @@ DOMAIN = "xiaoxiang_bms"
|
||||
CONF_ADDRESS = "address"
|
||||
CONF_POLL_INTERVAL = "poll_interval"
|
||||
|
||||
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
|
||||
DEFAULT_POLL_INTERVAL = 30 # seconds — each poll does a full BLE connect/disconnect
|
||||
MIN_POLL_INTERVAL = 15 # below this the BMS has no breathing room between polls
|
||||
MAX_POLL_INTERVAL = 300
|
||||
|
||||
# GATT UUIDs (Xiaoxiang BMS UART-over-GATT)
|
||||
|
||||
Reference in New Issue
Block a user