diff --git a/custom_components/xiaoxiang_bms/bluetooth_handler.py b/custom_components/xiaoxiang_bms/bluetooth_handler.py index c2aa36b..2c9da02 100644 --- a/custom_components/xiaoxiang_bms/bluetooth_handler.py +++ b/custom_components/xiaoxiang_bms/bluetooth_handler.py @@ -58,6 +58,9 @@ class BmsBluetoothHandler: ) await self._client.connect() await self._client.start_notify(RX_CHAR_UUID, self._on_notify) + # Give the BMS a moment to register the notification subscription + # before we start sending commands — avoids dropped first response + await asyncio.sleep(0.5) _LOGGER.debug("Connected to BMS at %s", self._address) async def disconnect(self) -> None: @@ -126,7 +129,7 @@ class BmsBluetoothHandler: self._response_event.clear() self._response_data = None try: - await self._client.write_gatt_char(TX_CHAR_UUID, command, response=False) + await self._client.write_gatt_char(TX_CHAR_UUID, command, response=True) except BleakError as exc: _LOGGER.error("BLE write failed: %s", exc) return None