4a769bf50f
- BLE GATT communication via bleak (UART-over-GATT, service 0xff00) - Parses 0x03 (general info) and 0x04 (cell voltages) frames - Protocol verified against official RS485/UART spec V4 - DataUpdateCoordinator with 5s poll interval (configurable 2-60s) - Auto-reconnect on BLE disconnect - Config flow: BT auto-discovery + manual MAC entry + options flow - Sensors: voltage, current, power, SoC, capacity, cycles, temps, cells, cell delta - HACS-ready (hacs.json, manifest.json) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
28 lines
898 B
Python
28 lines
898 B
Python
"""Constants for the Xiaoxiang Smart BMS integration."""
|
|
|
|
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
|
|
|
|
# GATT UUIDs (Xiaoxiang BMS UART-over-GATT)
|
|
UART_SERVICE_UUID = "0000ff00-0000-1000-8000-00805f9b34fb"
|
|
RX_CHAR_UUID = "0000ff01-0000-1000-8000-00805f9b34fb" # BMS → HA (notify)
|
|
TX_CHAR_UUID = "0000ff02-0000-1000-8000-00805f9b34fb" # HA → BMS (write)
|
|
|
|
# Request frames: [0xDD, 0xA5, CMD, 0x00, CHK_HI, CHK_LO, 0x77]
|
|
CMD_GENERAL = bytes([0xDD, 0xA5, 0x03, 0x00, 0xFF, 0xFD, 0x77]) # pack info
|
|
CMD_CELL = bytes([0xDD, 0xA5, 0x04, 0x00, 0xFF, 0xFC, 0x77]) # cell voltages
|
|
|
|
# Frame markers
|
|
FRAME_START = 0xDD
|
|
FRAME_END = 0x77
|
|
|
|
# Response command IDs (byte 1 of frame)
|
|
CMD_ID_GENERAL = 0x03
|
|
CMD_ID_CELL = 0x04
|