Add MOS gate control via select entity

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>
This commit is contained in:
2026-04-11 20:46:10 +02:00
parent b6c3e597f7
commit b52b25973e
5 changed files with 141 additions and 1 deletions
+6
View File
@@ -23,6 +23,12 @@ CMD_VERSION = bytes([0xDD, 0xA5, 0x05, 0x00, 0xFF, 0xFB, 0x77]) # hardware vers
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