b52b25973e
Adds a Select entity with four options (Normal / Charge Disabled / Discharge Disabled / Both Disabled) that sends the 0xE1 write command to the BMS and immediately refreshes sensor state. Current option is derived from the mos_charge_enabled / mos_discharge_enabled bits already parsed on every poll. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
"""Constants for the Xiaoxiang Smart BMS integration."""
|
|
|
|
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
|
|
MAX_POLL_INTERVAL = 300
|
|
|
|
# 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
|
|
|
|
# MOS control values (XX byte in write command DD 5A E1 02 00 XX CHK_H CHK_L 77)
|
|
MOS_NORMAL = 0x00 # release software lock — both gates open
|
|
MOS_CHARGE_OFF = 0x01 # disable charge MOS, keep discharge MOS on
|
|
MOS_DISCHARGE_OFF = 0x02 # disable discharge MOS, keep charge MOS on
|
|
MOS_BOTH_OFF = 0x03 # disable both charge and discharge MOS
|
|
|
|
# Response command IDs (byte 1 of frame)
|
|
CMD_ID_GENERAL = 0x03
|
|
CMD_ID_CELL = 0x04
|
|
CMD_ID_VERSION = 0x05
|