5d527168e2
Sensors added: - energy_stored (kWh = V × Ah / 1000) for energy dashboard Binary sensors added (all from existing 0x03 frame, no extra BLE requests): - Charge MOSFET / Discharge MOSFET (MOS gate status) - Cell Balancing (any balance bit active) - 13× protection flags: cell/pack over/under-voltage, charge/discharge over/under-temperature, charge/discharge over-current, short circuit, frontend IC error, software lock Other: - Hardware version string fetched once via CMD 0x05, shown in device card - DeviceInfo centralised on coordinator (sensor + binary_sensor share it) - CONF_ADDRESS removed from sensor.py (coordinator holds address) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
30 lines
1011 B
Python
30 lines
1011 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
|
|
CMD_VERSION = bytes([0xDD, 0xA5, 0x05, 0x00, 0xFF, 0xFB, 0x77]) # hardware version string
|
|
|
|
# Frame markers
|
|
FRAME_START = 0xDD
|
|
FRAME_END = 0x77
|
|
|
|
# Response command IDs (byte 1 of frame)
|
|
CMD_ID_GENERAL = 0x03
|
|
CMD_ID_CELL = 0x04
|
|
CMD_ID_VERSION = 0x05
|