Skip to content

Commit e604544

Browse files
committed
replaced HEX string definition
1 parent 0418267 commit e604544

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

custom_components/bms_ble/plugins/ective_bms.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import asyncio
44
from collections.abc import Callable
55
import logging
6+
from string import hexdigits
67
from typing import Any, Final
78

89
from bleak.backends.device import BLEDevice
@@ -36,7 +37,6 @@ class BMS(BaseBMS):
3637
_MAX_CELLS: Final[int] = 16
3738
_INFO_LEN: Final[int] = 113
3839
_CRC_LEN: Final[int] = 4
39-
_HEX_CHARS: Final[set] = set("0123456789ABCDEF")
4040
_FIELDS: Final[list[tuple[str, int, int, bool, Callable[[int], int | float]]]] = [
4141
(ATTR_VOLTAGE, 1, 8, False, lambda x: float(x / 1000)),
4242
(ATTR_CURRENT, 9, 8, True, lambda x: float(x / 1000)),
@@ -115,7 +115,7 @@ def _notification_handler(self, _sender, data: bytearray) -> None:
115115

116116
if not (
117117
self._data.startswith(BMS._HEAD_RSP)
118-
and set(self._data.decode()[3:]).issubset(BMS._HEX_CHARS)
118+
and set(self._data.decode()[3:]).issubset(hexdigits)
119119
):
120120
LOGGER.debug("%s: incorrect frame coding: %s", self.name, self._data)
121121
self._data.clear()

0 commit comments

Comments
 (0)