diff --git a/custom_components/bms_ble/plugins/basebms.py b/custom_components/bms_ble/plugins/basebms.py index b553091..212725d 100644 --- a/custom_components/bms_ble/plugins/basebms.py +++ b/custom_components/bms_ble/plugins/basebms.py @@ -62,7 +62,7 @@ def __init__( disconnected_callback=self._on_disconnect, services=[*self.uuid_services()], ) - self.name: str = self._ble_device.name or "undefined" + self.name: Final[str] = self._ble_device.name or "undefined" self._data_event: Final[asyncio.Event] = asyncio.Event() @staticmethod diff --git a/custom_components/bms_ble/plugins/jbd_bms.py b/custom_components/bms_ble/plugins/jbd_bms.py index 80faa1f..db00864 100644 --- a/custom_components/bms_ble/plugins/jbd_bms.py +++ b/custom_components/bms_ble/plugins/jbd_bms.py @@ -50,7 +50,6 @@ class BMS(BaseBMS): def __init__(self, ble_device: BLEDevice, reconnect: bool = False) -> None: """Intialize private BMS members.""" super().__init__(LOGGER, self._notification_handler, ble_device, reconnect) - self.name: str = str(self._ble_device.name) + self._ble_device.address[-4:] self._data: bytearray = bytearray() self._data_final: bytearray = bytearray() diff --git a/tests/test_jbd_bms.py b/tests/test_jbd_bms.py index bf18737..aabc7b8 100644 --- a/tests/test_jbd_bms.py +++ b/tests/test_jbd_bms.py @@ -63,34 +63,6 @@ async def write_gatt_char( self._notify_callback("MockJBDBleakClient", notify_data) -# class MockInvalidBleakClient(MockJBDBleakClient): -# """Emulate a JBD BMS BleakClient returning wrong data.""" - -# def _response( -# self, char_specifier: BleakGATTCharacteristic | int | str | UUID, data: Buffer -# ) -> bytearray: -# if ( -# isinstance(char_specifier, str) -# and normalize_uuid_str(char_specifier) == normalize_uuid_str("ff02") -# and bytearray(data)[0] == self.HEAD_CMD -# ): -# if bytearray(data)[1:3] == self.CMD_INFO: -# return bytearray( # wrong end -# b"\xdd\x03\x00\x1D\x06\x18\xFE\xE1\x01\xF2\x01\xF4\x00\x2A\x2C\x7C\x00\x00\x00" -# b"\x00\x00\x00\x80\x64\x03\x04\x03\x0B\x8B\x0B\x8A\x0B\x84\xf8\x84\xdd" -# ) - -# return ( # wrong CRC -# bytearray(b"\xdd\x04\x00\x1d") + bytearray(31) + bytearray(b"\x77") -# ) - -# return bytearray() - -# async def disconnect(self) -> bool: -# """Mock disconnect to raise BleakError.""" -# raise BleakError - - class MockOversizedBleakClient(MockJBDBleakClient): """Emulate a JBD BMS BleakClient returning wrong data length."""