Skip to content

UNICODE ERROR #349

@neluvarvas

Description

@neluvarvas

Describe the issue here.
If you experience bluetooth connection problems, follow these steps before opening an issue:
https://github.com/fl4p/batmon-ha#troubleshooting

JK-BMS 24s
Home Assistant OS. Core 2026.1.3
Supervisor 2026.01.1
Operating System 17.0
Frontend 20260107.2

Hardware: Raspberry Pi 5 8G RAM

Unicode ERROR

BEGIN
13:01:34 WARNING [bt] BMS JKBt_24s(C8:47:8C:E4:9F:75,battery2) disconnected after 248.9s!
13:01:34 INFO [main] Disconnecting JKBt_24s(C8:47:8C:E1:FC:23,battery1)
13:01:34 INFO [main] Disconnecting JKBt_24s(C8:47:8C:E4:9F:75,battery2)

12:59:15 WARNING [bt] battery1: device C8:47:8C:E1:FC:23 not discovered, trying to connect anyway
12:59:17 INFO [sampling] connected bms JKBt_24s(C8:47:8C:E1:FC:23,battery1)!
12:59:17 INFO [jikong] PSK = '0000' (Note that anyone within BLE range can read this!)
12:59:17 WARNING [sampling] battery1 error fetching device info: 'utf-8' codec can't decode byte 0xbf in position 10: invalid start byte
12:59:17 INFO [jikong] PSK = '0000' (Note that anyone within BLE range can read this!)
12:59:17 ERROR [sampling] battery1 error (#21): 'utf-8' codec can't decode byte 0xbf in position 10: invalid start byte
Traceback (most recent call last):
File "/app/bmslib/sampling.py", line 155, in call
s = await self._sample_inner()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/bmslib/sampling.py", line 241, in _sample_inner
sample = await bms.fetch()
^^^^^^^^^^^^^^^^^
File "/app/bmslib/models/jikong.py", line 283, in fetch
has_float_charger = await self.has_float_charger()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/bmslib/models/jikong.py", line 204, in has_float_charger
await self.fetch_device_info()
File "/app/bmslib/models/jikong.py", line 195, in fetch_device_info
sw_version=read_str(buf, 6 + 16 + 8),
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/bmslib/models/jikong.py", line 34, in read_str
return buf[offset:buf.index(0x00, offset)].decode(encoding=encoding)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbf in position 10: invalid start byte
12:59:17 INFO [sampling] battery1 bms debug data: {'resp': {3: (bytearray(b'U\xaa\xeb\x90\x03\x1aJK-B2A24S20P\x00\x00\x00\x0010.XG\x00\x00\x0010.07D30\x046\xbf\x06\x02\x00\x00\x00JK-B2A24S20P\x00\x00\x00\x001234\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00220610\x00\x002012603089\x000000\x00Input Userdata\x00\x00123456\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00y'), 1770116356.3203976), 1: (bytearray(b'U\xaa\xeb\x90\x01\x1aX\x02\x00\x00\x04\x0b\x00\x00"\x0b\x00\x00^\x10\x00\x00T\x10\x00\x00\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf0\n\x00\x00@\r\x03\x00\x1e\x00\x00\x00<\x00\x00\x00\x90\xd0\x03\x00,\x01\x00\x00<\x00\x00\x00<\x00\x00\x00\xd0\x07\x00\x00\xbc\x02\x00\x00X\x02\x00\x00\xbc\x02\x00\x00X\x02\x00\x008\xff\xff\xff\x9c\xff\xff\xff\x84\x03\x00\x00\xbc\x02\x00\x00\x0e\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00 \xbf\x02\x00\xdc\x05\x00\x00\xe4\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x90'), 1770116356.5829043), 2: (bytearray(b'U\xaa\xeb\x90\x02\x1b\xc2\r\xbe\r\xbd\r\xbd\r\xbd\r\xbd\r\xbd\r\xbd\r\xbc\r\xbd\r\xbc\r\xbc\r\xbc\r\xbc\r\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff?\x00\x00\xbd\r\x05\x00\x00\x022\x002\x002\x002\x002\x002\x002\x001\x002\x002\x001\x001\x001\x002\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00S\xc0\x00\x00\x93\x85\x05\x00\xe4\x1b\x00\x00\xf2\x00\xf7\x00\x05\x01\x00\x00\x00\x00\x00\x1a)\xba\x00\x00 \xbf\x02\x00M\x02\x00\x00RPT\x06d\x00\xae\x0466\xbf\x06\x01\x01\xa3\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\x00\x01\x00\x00\x00\x1a\x04"\x00\x00\x00]\xd1=@\x00\x00\x00\x00\xe2\x04\x00\x00\x00\x00\x00\x01\x00\x03\x00\x00 $\x1dC\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00%'), 1770116357.6466546)}, 'char_w': <bleak.backends.characteristic.BleakGATTCharacteristic object at 0x7f8aa93d40>, 'char_r': <bleak.backends.characteristic.BleakGATTCharacteristic object at 0x7f8ace3f80>}
12:59:17 WARNING [sampling] disconnecting JKBt_24s(C8:47:8C:E1:FC:23,battery1) due to too many errors 21
12:59:20 WARNING [bt] BMS JKBt_24s(C8:47:8C:E1:FC:23,battery1) disconnected after 4.3s!
12:59:20 ERROR [main] Error (num 20, max 200) reading BMS: 'utf-8' codec can't decode byte 0xbf in position 10: invalid start byte
12:59:20 ERROR [main] Stack: Traceback (most recent call last):
File "/app/main.py", line 37, in fetch_loop
if await fn():
^^^^^^^^^^
File "/app/bmslib/sampling.py", line 155, in call
s = await self._sample_inner()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/bmslib/sampling.py", line 241, in _sample_inner
sample = await bms.fetch()
^^^^^^^^^^^^^^^^^
File "/app/bmslib/models/jikong.py", line 283, in fetch
has_float_charger = await self.has_float_charger()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/bmslib/models/jikong.py", line 204, in has_float_charger
await self.fetch_device_info()
File "/app/bmslib/models/jikong.py", line 195, in fetch_device_info
sw_version=read_str(buf, 6 + 16 + 8),
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/bmslib/models/jikong.py", line 34, in read_str
return buf[offset:buf.index(0x00, offset)].decode(encoding=encoding)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbf in position 10: invalid start byte

END

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions