fl4p / batmon-ha

Add-on for Home Assistant to connect JK, JBD, Daly, ANT, SOK and Supervolt BMS via Bluetooth
MIT License
246 stars 53 forks source link

Supervolt BMS | Error | Characteristic 6e400003-b5a3-f393-e0a9-e50e24dcca9e not found! | unsupported operand type(s) for &: 'NoneType' and 'int' #226

Open nightcat91 opened 2 months ago

nightcat91 commented 2 months ago

2x Supervolt SX150P

Error: ERROR [supervolt] (<class 'bleak.exc.BleakError'>, BleakError('Characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e was not found!') ERROR [main] Error reading BMS: unsupported operand type(s) for &: 'NoneType' and 'int'

I already tried "install_newer_bleak", "bt_power_cycle" and with ot without "keep_alive" Not quite sure how to get a complete log, down below are pieces of logs which I got from the addon logs tab with careful refreshing and copy...

Using a "DIGITUS DN-30210-1" external Bluetooth Adapter with a USB Extension, Bluetooth Integration in HomeAssistant is working, other integrations that use it also work!

If any more info is needed please let me know.

Paste log output between BEGIN and END:
BEGIN 

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
19:01:53 INFO [install_bleak] bleak 0.13.1a1 installed, want 0.20.2, running pip3 install bleak==0.20.2
19:01:53 INFO [install_bleak] influxdb installed=False need=False
Looking in indexes: https://pypi.org/simple, https://wheels.home-assistant.io/musllinux-index/
Collecting bleak==0.20.2
  Downloading https://wheels.home-assistant.io/musllinux-index/bleak-0.20.2-py3-none-any.whl (135 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 135.6/135.6 kB 598.0 kB/s eta 0:00:00
Collecting dbus-fast<2.0.0,>=1.83.0 (from bleak==0.20.2)
  Downloading https://wheels.home-assistant.io/musllinux-index/dbus_fast-1.95.2-cp311-cp311-musllinux_1_2_aarch64.whl (1.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 5.0 MB/s eta 0:00:00
Installing collected packages: dbus-fast, bleak
  Attempting uninstall: bleak
    Found existing installation: bleak 0.13.1a1
    Uninstalling bleak-0.13.1a1:
      Successfully uninstalled bleak-0.13.1a1
Successfully installed bleak-0.20.2 dbus-fast-1.95.2
19:02:03 INFO [main] Power cycle bluetooth hardware
Unable to open mgmt_socket
Unable to open mgmt_socket
19:02:06 INFO [bt] BT Discovery:
19:02:12 INFO [bt] BT E9:66:91:7B:15:C8                  Victron 1
19:02:12 INFO [bt] BT CE:A0:09:E7:49:9D     SmartShunt HQ2220VVMXM
19:02:12 INFO [bt] BT E0:1E:AF:76:E6:EE SmartBatterySense HQ21237KXFV
19:02:12 INFO [bt] BT C7:19:54:F9:0A:3B                  Victron 2
19:02:12 INFO [bt] BT 42:8B:15:75:B7:A7         Truma iNetX-2F3DBD
19:02:12 INFO [bt] BT C4:08:7D:7F:B8:1C             SX150P-B230101
19:02:12 INFO [bt] BT E6:F9:20:27:3C:31             SX150P-B230149
19:02:12 INFO [bt] BT 7B:43:6E:AF:CB:18           Jabra Evolve2 85
19:02:12 INFO [bt] BT 10:D3:42:27:2F:B1          10-D3-42-27-2F-B1
19:02:12 INFO [bt] BT 4D:85:DD:0B:F3:31           Jabra Evolve 65e
19:02:12 INFO [bt] BT 55:5C:7D:C1:91:32               JBL Charge 5
19:02:12 INFO [bt] BT 69:73:8B:1B:DA:D5          69-73-8B-1B-DA-D5
19:02:12 INFO [bt] BT D9:11:A9:01:5D:85          D9-11-A9-01-5D-85
19:02:12 INFO [bt] BT 4E:AF:AF:EC:91:17          4E-AF-AF-EC-91-17
19:02:12 INFO [bt] BT 4C:18:E6:33:D3:0C          4C-18-E6-33-D3-0C
19:02:12 INFO [main] Verbose logging enabled
19:02:12 INFO [main] Bleak version 0.20.2, BtBackend version bluez-v5.70
19:02:12 DEBUG [bt] BMS SuperVoltBt(C4:08:7D:7F:B8:1C,Vorne1) keep alive enabled
19:02:12 DEBUG [bt] BMS SuperVoltBt(E6:F9:20:27:3C:31,Hinten2) keep alive enabled
19:02:12 INFO [main] connecting mqtt addons@core-mosquitto
/app/main.py:196: DeprecationWarning: Callback API version 1 is deprecated, update to latest version
  mqtt_client = paho.Client(paho.CallbackAPIVersion.VERSION1)
19:02:12 DEBUG [client] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b''
19:02:12 INFO [main] Fetching 2 BMS + 0 virtual + 0 others concurrently, period=1.00s, keep_alive=True
19:02:12 INFO [sampling] connecting bms SuperVoltBt(E6:F9:20:27:3C:31,Hinten2)
19:02:12 INFO [bt] connecting Hinten2 (E6:F9:20:27:3C:31) adapter=default timeout=20
19:02:12 DEBUG [client] Connecting to device @ E6:F9:20:27:3C:31
19:02:12 DEBUG [manager] received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0): ['org.bluez.Adapter1', {'Discovering': <dbus_fast.signature.Variant ('b', True)>}, []]
19:02:12 DEBUG [manager] received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_C7_19_54_F9_0A_3B): ['org.bluez.Device1', {'RSSI': <dbus_fast.signature.Variant ('n', -44)>}, []]
19:02:12 DEBUG [manager] received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded (/): ['/org/bluez/hci0/dev_E9_66_91_7B_15_C8', {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Device1': {'Address': <dbus_fast.signature.Variant ('s', E9:66:91:7B:15:C8)>, 'AddressType': <dbus_fast.signature.Variant ('s', random)>, 'Name': <dbus_fast.signature.Variant ('s', Victron 1)>, 'Alias': <dbus_fast.signature.Variant ('s', Victron 1)>, 'Paired': <dbus_fast.signature.Variant ('b', False)>, 'Bonded': <dbus_fast.signature.Variant ('b', False)>, 'Trusted': <dbus_fast.signature.Variant ('b', False)>, 'Blocked': <dbus_fast.signature.Variant ('b', False)>, 'LegacyPairing': <dbus_fast.signature.Variant ('b', False)>, 'RSSI': <dbus_fast.signature.Variant ('n', -52)>, 'Connected': <dbus_fast.signature.Variant ('b', False)>, 'UUIDs': <dbus_fast.signature.Variant ('as', [])>, 'Adapter': <dbus_fast.signature.Variant ('o', /org/bluez/hci0)>, 'ManufacturerData': <dbus_fast.signature.Variant ('a{qv}', {737: <dbus_fast.signature.Variant ('ay', bytearray(b'\x10\x02`\xa0\x01\x08\x17\x0cQ\xf1m.\x0e$V\x1a\x02\x90\xed\xd4'))>})>, 'ServicesResolved': <dbus_fast.signature.Variant ('b', False)>, 'AdvertisingFlags': <dbus_fast.signature.Variant ('ay', bytearray(b'\x06'))>}, 'org.freedesktop.DBus.Properties': {}}]
19:02:12 DEBUG [manager] received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded (/): ['/org/bluez/hci0/dev_62_13_0A_CB_0F_E6', {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Device1': {'Address': <dbus_fast.signature.Variant ('s', 62:13:0A:CB:0F:E6)>, 'AddressType': <dbus_fast.signature.Variant ('s', random)>, 'Alias': <dbus_fast.signature.Variant ('s', 62-13-0A-CB-0F-E6)>, 'Paired': <dbus_fast.signature.Variant ('b', False)>, 'Bonded': <dbus_fast.signature.Variant ('b', False)>, 'Trusted': <dbus_fast.signature.Variant ('b', False)>, 'Blocked': <dbus_fast.signature.Variant ('b', False)>, 'LegacyPairing': <dbus_fast.signature.Variant ('b', False)>, 'RSSI': <dbus_fast.signature.Variant ('n', -78)>, 'Connected': <dbus_fast.signature.Variant ('b', False)>, 'UUIDs': <dbus_fast.signature.Variant ('as', [])>, 'Adapter': <dbus_fast.signature.Variant ('o', /org/bluez/hci0)>, 'ManufacturerData': <dbus_fast.signature.Variant ('a{qv}', {76: <dbus_fast.signature.Variant ('ay', bytearray(b'\x16\x08\x00$\xe0\xdf\x96\xcc\xbb\x03'))>})>, 'ServicesResolved': <dbus_fast.signature.Variant ('b', False)>, 'AdvertisingFlags': <dbus_fast.signature.Variant ('ay', bytearray(b'\x1a'))>}, 'org.freedesktop.DBus.Properties': {}}]
19:02:12 DEBUG [manager] received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded (/): ['/org/bluez/hci0/dev_CE_A0_09_E7_49_9D', {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Device1': {'Address': <dbus_fast.signature.Variant ('s', CE:A0:09:E7:49:9D)>, 'AddressType': <dbus_fast.signature.Variant ('s', random)>, 'Name': <dbus_fast.signature.Variant ('s', SmartShunt HQ2220VVMXM)>, 'Alias': <dbus_fast.signature.Variant ('s', SmartShunt HQ2220VVMXM)>, 'Paired': <dbus_fast.signature.Variant ('b', False)>, 'Bonded': <dbus_fast.signature.Variant ('b', False)>, 'Trusted': <dbus_fast.signature.Variant ('b', False)>, 'Blocked': <dbus_fast.signature.Variant ('b', False)>, 'LegacyPairing': <dbus_fast.signature.Variant ('b', False)>, 'RSSI': <dbus_fast.signature.Variant ('n', -49)>, 'Connected': <dbus_fast.signature.Variant ('b', False)>, 'UUIDs': <dbus_fast.signature.Variant ('as', [])>, 'Adapter': <dbus_fast.signature.Variant ('o', /org/bluez/hci0)>, 'ManufacturerData': <dbus_fast.signature.Variant ('a{qv}', {737: <dbus_fast.signature.Variant ('ay', bytearray(b'\x10\x02\x89\xa3\x02\x80\x16wE\xe1/\x8a\xf3c\xc4\xf9\xba.%\x94\x11\xc4\x8e'))>})>, 'ServicesResolved': <dbus_fast.signature.Variant ('b', False)>, 'AdvertisingFlags': <dbus_fast.signature.Variant ('ay', bytearray(b'\x06'))>}, 'org.freedesktop.DBus.Properties': {}}]
19:02:12 DEBUG [manager] received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_E9_66_91_7B_15_C8): ['org.bluez.Device1', {'RSSI': <dbus_fast.signature.Variant ('n', -46)>, 'ManufacturerData': <dbus_fast.signature.Variant ('a{qv}', {737: <dbus_fast.signature.Variant ('ay', bytearray(b'\x02\xe0\x8b\x7f\x00\x99O\xa9\x89-\x194\xd3\x05\xf8V\x89\x18\xa4\xb8n-'))>})>, 'AdvertisingFlags': <dbus_fast.signature.Variant ('ay', bytearray(b'\x00'))>}, []]
19:02:12 DEBUG [manager] received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded (/): ['/org/bluez/hci0/dev_E0_1E_AF_76_E6_EE', {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Device1': {'Address': <dbus_fast.signature.Variant ('s', E0:1E:AF:76:E6:EE)>, 'AddressType': <dbus_fast.signature.Variant ('s', random)>, 'Name': <dbus_fast.signature.Variant ('s', SmartBatterySense HQ21237KXFV)>, 'Alias': <dbus_fast.signature.Variant ('s', SmartBatterySense HQ21237KXFV)>, 'Paired': <dbus_fast.signature.Variant ('b', False)>, 'Bonded': <dbus_fast.signature.Variant ('b', False)>, 'Trusted': <dbus_fast.signature.Variant ('b', False)>, 'Blocked': <dbus_fast.signature.Variant ('b', False)>, 'LegacyPairing': <dbus_fast.signature.Variant ('b', False)>, 'RSSI': <dbus_fast.signature.Variant ('n', -49)>, 'Connected': <dbus_fast.signature.Variant ('b', False)>, 'UUIDs': <dbus_fast.signature.Variant ('as', [])>, 'Adapter': <dbus_fast.signature.Variant ('o', /org/bluez/hci0)>, 'ManufacturerData': <dbus_fast.signature.Variant ('a{qv}', {737: <dbus_fast.signature.Variant ('ay', bytearray(b"\x02\xe0K5!\x98F\x19S*\'7k1\xbd\x8b\xee\xe4\xdb#\xa40\xad\x8ca\x97\xb7"))>})>, 'ServicesResolved': <dbus_fast.signature.Variant ('b', False)>, 'AdvertisingFlags': <dbus_fast.signature.Variant ('ay', bytearray(b'\x00'))>}, 'org.freedesktop.DBus.Properties': {}}]
19:02:12 DEBUG [manager] received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_42_8B_15_75_B7_A7): ['org.bluez.Device1', {'RSSI': <dbus_fast.signature.Variant ('n', -51)>, 'TxPower': <dbus_fast.signature.Variant ('n', 0)>}, []]
19:02:12 DEBUG [manager] received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesAdded (/): ['/org/bluez/hci0/dev_E7_80_AF_CC_96_92', {'org.freedesktop.DBus.Introspectable': {}, 'org.bluez.Device1': {'Address': <dbus_fast.signature.Variant ('s', E7:80:AF:CC:96:92)>, 'AddressType': <dbus_fast.signature.Variant ('s', random)>, 'Alias': <dbus_fast.signature.Variant ('s', E7-80-AF-CC-96-92)>, 'Paired': <dbus_fast.signature.Variant ('b', False)>, 'Bonded': <dbus_fast.signature.Variant ('b', False)>, 'Trusted': <dbus_fast.signature.Variant ('b', False)>, 'Blocked': <dbus_fast.signature.Variant ('b', False)>, 'LegacyPairing': <dbus_fast.signature.Variant ('b', False)>, 'RSSI': <dbus_fast.signature.Variant ('n', -78)>, 'Connected': <dbus_fast.signature.Variant ('b', False)>, 'UUIDs': <dbus_fast.signature.Variant ('as', [])>, 'Adapter': <dbus_fast.signature.Variant ('o', /org/bluez/hci0)>, 'ManufacturerData': <dbus_fast.signature.Variant ('a{qv}', {76: <dbus_fast.signature.Variant ('ay', bytearray(b'\x12\x02\x00\x03'))>})>, 'ServicesResolved': <dbus_fast.signature.Variant ('b', False)>, 'AdvertisingFlags': <dbus_fast.signature.Variant ('ay', bytearray(b'\x00'))>}, 'org.freedesktop.DBus.Properties': {}}]
19:02:12 DEBUG [manager] received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_C7_19_54_F9_0A_3B): ['org.bluez.Device1', {'RSSI': <dbus_fast.signature.Variant ('n', -62)>, 'ManufacturerData': <dbus_fast.signature.Variant ('a{qv}', {737: <dbus_fast.signature.Variant ('ay', bytearray(b'\x02\xe0\x9c\xeef\x99/|\x89*C\xb5b>\x948\x83\x123fJ\x0f\xf9\xdb <\xb8'))>})>, 'AdvertisingFlags': <dbus_fast.signature.Variant ('ay', bytearray(b'\x00'))>}, []]
19:02:12 DEBUG [manager] received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_CE_A0_09_E7_49_9D): ['org.bluez.Device1', {'RSSI': <dbus_fast.signature.Variant ('n', -59)>, 'ManufacturerData': <dbus_fast.signature.Variant ('a{qv}', {737: <dbus_fast.signature.Variant ('ay', bytearray(b'\x02\xe0\xda\xec\x8f\x9a\x02\xdf\x89+NP\x820\x91\xdc\xbc\xb5\x83\x9c\x9fRk\xa7R\xdc"'))>})>, 'AdvertisingFlags': <dbus_fast.signature.Variant ('ay', bytearray(b'\x00'))>}, []]
19:02:12 DEBUG [manager] received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_E9_66_91_7B_15_C8): ['org.bluez.Device1', {'RSSI': <dbus_fast.signature.Variant ('n', -52)>, 'ManufacturerData': <dbus_fast.signature.Variant ('a{qv}', {737: <dbus_fast.signature.Variant ('ay', bytearray(b'\x01\xe0\x8b\x7f\x00\x99P\xa9\x89-\x00\x00\xca?\xd2\xf2'))>})>}, []]
19:02:12 DEBUG [manager] received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_E6_F9_20_27_3C_31): ['org.bluez.Device1', {'RSSI': <dbus_fast.signature.Variant ('n', -43)>}, []]
19:02:12 DEBUG [manager] received D-Bus signal: org.freedesktop.DBus.Properties.PropertiesChanged (/org/bluez/hci0/dev_C7_19_54_F9_0A_3B): ['org.bluez.Device1', {}, ['RSSI']]
19:02:12 DEBUG [manager] received D-Bus signal: org.freedesktop.DBus.ObjectManager.InterfacesRemoved (/): ['/org/bluez/hci0/dev_C7_19_54_F9_0A_3B', ['org.freedesktop.DBus.Properties', 'org.freedesktop.DBus.Introspectable', 'org.bluez.Device1']]

.....

19:02:24 INFO [sampling] Bleak version 0.20.2
19:02:24 ERROR [main] Error (num 7, max 0) reading BMS: unsupported operand type(s) for &: 'NoneType' and 'int'
19:02:24 ERROR [main] Stack: Traceback (most recent call last):
  File "/app/main.py", line 36, 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 237, in _sample_inner
    sample = await bms.fetch()
             ^^^^^^^^^^^^^^^^^
  File "/app/bmslib/models/supervolt.py", line 397, in fetch
    status_discharging=(self.workingState & 0x0002 > 0),
                        ~~~~~~~~~~~~~~~~~~^~~~~~~~
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'

19:02:25 ERROR [supervolt] (<class 'bleak.exc.BleakError'>, BleakError('Characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e was not found!'), <traceback object at 0xffff7f3bb7c0>)
Traceback (most recent call last):
  File "/app/bmslib/models/supervolt.py", line 113, in requestData
    await self.requestRealtimeData()
  File "/app/bmslib/models/supervolt.py", line 95, in requestRealtimeData
    ret = await self.client.write_gatt_char(char_specifier=handle, data=data)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.11/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/app/venv/lib/python3.11/site-packages/bleak/backends/bluezdbus/client.py", line 848, in write_gatt_char
    raise BleakError("Characteristic {0} was not found!".format(char_specifier))
bleak.exc.BleakError: Characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e was not found!
19:02:25 ERROR [sampling] Vorne1 error (#9): unsupported operand type(s) for &: 'NoneType' and 'int'
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 237, in _sample_inner
    sample = await bms.fetch()
             ^^^^^^^^^^^^^^^^^
  File "/app/bmslib/models/supervolt.py", line 397, in fetch
    status_discharging=(self.workingState & 0x0002 > 0),
                        ~~~~~~~~~~~~~~~~~~^~~~~~~~
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'
19:02:25 INFO [sampling] Bleak version 0.20.2
19:02:25 ERROR [main] Error (num 8, max 0) reading BMS: unsupported operand type(s) for &: 'NoneType' and 'int'
19:02:25 ERROR [main] Stack: Traceback (most recent call last):
  File "/app/main.py", line 36, 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 237, in _sample_inner
    sample = await bms.fetch()
             ^^^^^^^^^^^^^^^^^
  File "/app/bmslib/models/supervolt.py", line 397, in fetch
    status_discharging=(self.workingState & 0x0002 > 0),
                        ~~~~~~~~~~~~~~~~~~^~~~~~~~
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'

19:02:25 ERROR [supervolt] (<class 'bleak.exc.BleakError'>, BleakError('Characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e was not found!'), <traceback object at 0xffff7f3baf40>)
Traceback (most recent call last):
  File "/app/bmslib/models/supervolt.py", line 113, in requestData
    await self.requestRealtimeData()
  File "/app/bmslib/models/supervolt.py", line 95, in requestRealtimeData
    ret = await self.client.write_gatt_char(char_specifier=handle, data=data)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.11/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/app/venv/lib/python3.11/site-packages/bleak/backends/bluezdbus/client.py", line 848, in write_gatt_char
    raise BleakError("Characteristic {0} was not found!".format(char_specifier))
bleak.exc.BleakError: Characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e was not found!
19:02:25 ERROR [sampling] Hinten2 error (#9): unsupported operand type(s) for &: 'NoneType' and 'int'
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 237, in _sample_inner
    sample = await bms.fetch()
             ^^^^^^^^^^^^^^^^^
  File "/app/bmslib/models/supervolt.py", line 397, in fetch
    status_discharging=(self.workingState & 0x0002 > 0),
                        ~~~~~~~~~~~~~~~~~~^~~~~~~~
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'
19:02:25 INFO [sampling] Bleak version 0.20.2

###########################
Additional Log Entry from home-assistant.log:
2024-04-26 19:03:56.869 ERROR (MainThread) [habluetooth.scanner] hci0 (00:1A:7D:DA:71:13): Error stopping scanner: [org.bluez.Error.Failed] No discovery started

END
tinkercasa commented 1 month ago

I get similar errors.

ERROR:

bleak.exc.BleakError: Characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e was not found!
[..]
status_discharging=(self.workingState & 0x0002 > 0),
                        ~~~~~~~~~~~~~~~~~~^~~~~~~~
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'

HA Core: 2024.5.3 HA Supervisor: 2024.05.1 HA OS: 12.3 Bluetooth: Home Assistant Yellow / Raspberry Pi Compute Module 4 Battery: Supervolt SX-100 (2024 version) Batmon Version: 1.78 Batmon Configuration:

- address: XX:XX:XX:XX:XX:XX
  type: supervolt
  alias: battery_sx100
  verbose: true

Without knowing any better I suspect that Batmons supervolt type needs to be updated for the 2024 version of the batteries. The new batteries have a blue top and the old batteries have a black top. The new 2024 version might have changes in the BMS / BLE communication.

Some more information just to show that the battery is visible via BLE and is generally accessible:

The BMS is accessible via the Supervolt companion app. When searching for the battery with the ESPHome Bluetooth Low Energy Tracker the battery shows up:

address: XX:XX:XX:XX:XX:XX name: SX100-B230019 advertised service UUID: 0xFF00 advertised service data: \<empty> advertised manufacturer data: 0x007B

According to Bluetooth-Company-Identifiers.csv 0x007B stands for Hanlynn Technologies. I could confirm this with the android app BLE Radar.

@OP (nightcat91):

How to get the complete batmon add-on log

Error Log

Start of log:

Paste log output between BEGIN and END:
BEGIN 

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
16:41:36 INFO [bt] BT Discovery:
16:41:41 INFO [bt] BT XX:XX:XX:XX:XX:XX              SX100-B230019
16:41:41 INFO [main] Bleak version 0.13.1a1, BtBackend version bluez-v5.70
16:41:41 INFO [main] connecting mqtt batmon2ha@core-mosquitto
/app/main.py:196: DeprecationWarning: Callback API version 1 is deprecated, update to latest version
  mqtt_client = paho.Client(paho.CallbackAPIVersion.VERSION1)                                                                        16:41:41 INFO [main] Fetching 1 BMS + 0 virtual + 0 others serially, period=1.00s, keep_alive=True                                   16:41:41 INFO [sampling] connecting bms SuperVoltBt(XX:XX:XX:XX:XX:XX,battery_sx100)                                                 16:41:41 INFO [main] mqtt watchdog loop started with timeout 300.0s                                                                  16:41:43 ERROR [sampling] SuperVoltBt(XX:XX:XX:XX:XX:XX,battery_sx100) device not found, retry in 1 seconds                          16:41:43 ERROR [supervolt] (<class 'bleak.exc.BleakError'>, BleakError('Characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e was not fTraceback (most recent call last):
  File "/app/bmslib/models/supervolt.py", line 113, in requestData
    await self.requestRealtimeData()
  File "/app/bmslib/models/supervolt.py", line 95, in requestRealtimeData
    ret = await self.client.write_gatt_char(char_specifier=handle, data=data)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.11/site-packages/bleak/backends/bluezdbus/client.py", line 904, in write_gatt_char
    raise BleakError("Characteristic {0} was not found!".format(char_specifier))
bleak.exc.BleakError: Characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e was not found!
16:41:43 ERROR [sampling] battery_sx100 error (#2): unsupported operand type(s) for &: 'NoneType' and 'int'
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 237, in _sample_inner
    sample = await bms.fetch()
             ^^^^^^^^^^^^^^^^^
  File "/app/bmslib/models/supervolt.py", line 397, in fetch
    status_discharging=(self.workingState & 0x0002 > 0),
                        ~~~~~~~~~~~~~~~~~~^~~~~~~~
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'
16:41:43 INFO [sampling] Bleak version 0.13.1a1
16:41:43 ERROR [main] 1 exceptions occurred fetching BMSs
16:41:43 ERROR [main] Error (num 1, max 200) reading BMS: unsupported operand type(s) for &: 'NoneType' and 'int'
16:41:43 ERROR [main] Stack: Traceback (most recent call last):
  File "/app/main.py", line 36, in fetch_loop
    if await fn():
       ^^^^^^^^^^
  File "/app/main.py", line 319, in fn
    raise exceptions[0]
  File "/app/main.py", line 314, in fn
    await t()
  File "/app/bmslib/sampling.py", line 155, in __call__
    s = await self._sample_inner()
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/bmslib/sampling.py", line 237, in _sample_inner
    sample = await bms.fetch()
             ^^^^^^^^^^^^^^^^^
  File "/app/bmslib/models/supervolt.py", line 397, in fetch
    status_discharging=(self.workingState & 0x0002 > 0),
                        ~~~~~~~~~~~~~~~~~~^~~~~~~~
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'

The error repeats itself every second ( probably because of period=1.00s ). That's why I shortened the log in this part considerably.

End of log:

16:45:05 ERROR [supervolt] (<class 'bleak.exc.BleakError'>, BleakError('Characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e was not fTraceback (most recent call last):
  File "/app/bmslib/models/supervolt.py", line 113, in requestData
    await self.requestRealtimeData()
  File "/app/bmslib/models/supervolt.py", line 95, in requestRealtimeData
    ret = await self.client.write_gatt_char(char_specifier=handle, data=data)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.11/site-packages/bleak/backends/bluezdbus/client.py", line 904, in write_gatt_char
    raise BleakError("Characteristic {0} was not found!".format(char_specifier))
bleak.exc.BleakError: Characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e was not found!
16:45:05 ERROR [sampling] battery_sx100 error (#202): unsupported operand type(s) for &: 'NoneType' and 'int'
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 237, in _sample_inner
    sample = await bms.fetch()
             ^^^^^^^^^^^^^^^^^
  File "/app/bmslib/models/supervolt.py", line 397, in fetch
    status_discharging=(self.workingState & 0x0002 > 0),
                        ~~~~~~~~~~~~~~~~~~^~~~~~~~
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'
16:45:05 INFO [sampling] Bleak version 0.13.1a1
16:45:05 WARNING [sampling] battery_sx100 disconnect because no data has been flowing for some time
16:45:05 ERROR [main] 1 exceptions occurred fetching BMSs
16:45:05 ERROR [main] Error (num 201, max 200) reading BMS: Characteristic 6e400003-b5a3-f393-e0a9-e50e24dcca9e not found!
16:45:05 ERROR [main] Stack: 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 237, in _sample_inner
    sample = await bms.fetch()
             ^^^^^^^^^^^^^^^^^
  File "/app/bmslib/models/supervolt.py", line 397, in fetch
    status_discharging=(self.workingState & 0x0002 > 0),
                        ~~~~~~~~~~~~~~~~~~^~~~~~~~
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/main.py", line 36, in fetch_loop
    if await fn():
       ^^^^^^^^^^
  File "/app/main.py", line 319, in fn
    raise exceptions[0]
  File "/app/main.py", line 314, in fn
    await t()
  File "/app/bmslib/sampling.py", line 187, in __call__
    await bms.disconnect()
  File "/app/bmslib/models/supervolt.py", line 84, in disconnect
    await self.client.stop_notify(self.UUID_RX)
  File "/app/venv/lib/python3.11/site-packages/bleak/backends/bluezdbus/client.py", line 1099, in stop_notify
    raise BleakError("Characteristic {} not found!".format(char_specifier))
bleak.exc.BleakError: Characteristic 6e400003-b5a3-f393-e0a9-e50e24dcca9e not found!

16:45:05 WARNING [main] too many errors, abort
16:45:05 INFO [main] fetch_loop <function main.<locals>.fn at 0x7faf4d6020> ends
16:45:05 INFO [main] All fetch loops ended. shutdown is already False
16:45:05 INFO [main] Disconnecting SuperVoltBt(XX:XX:XX:XX:XX:XX,battery_sx100)
16:45:05 INFO [main] exit signal handler... (), {}, shutdown was True
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

END
fl4p commented 1 month ago

Hi, apparently they changed the BLE characteristic UID. Someone needs with this BMS needs to run service_explorer.py

nightcat91 commented 1 month ago

I got these documents from Supervolt in March 2024 via an email contact. Maybe they are useful?

At least in the bt-protocol PDF there are some UUIDs on the last page and a lot more info about the full BT protocol in general.

bt_protocol.pdf https://support.supervolt.de/attachments/token/VsJUkKGbW5zPzOdH5dM5MZbqt/?name=%5BB%5D+bt+protocol.pdf

rs485_protocol.docx https://support.supervolt.de/attachments/token/rCajBS0UYSQo4cwcP0ugLNWxF/?name=%5BB%5D+rs485+protocol.docx

tinkercasa commented 1 month ago

Executing service_explorer.py confirmed that the UUIDs near the end of the PDF [B] bt protocol.pdf are correct.

$ python3 service_explorer.py
INFO:__main__:Connecting XX:XX:XX:XX:XX:XX
INFO:__main__:Connected: True
INFO:__main__:[Service] 00002600-0000-1000-8000-00805f9b34fb (Handle: 23): Vendor specific
INFO:__main__:  [Characteristic] 00007000-0000-1000-8000-00805f9b34fb (Handle: 24): Vendor specific (write,indicate), Value: None
INFO:__main__:          [Descriptor] 00002902-0000-1000-8000-00805f9b34fb (Handle: 26): Client Characteristic Configuration) | Value: b'\x00\x00'
INFO:__main__:  [Characteristic] 00007001-0000-1000-8000-00805f9b34fb (Handle: 27): Vendor specific (read,write-without-response), Value: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
INFO:__main__:[Service] 0000ff00-0000-1000-8000-00805f9b34fb (Handle: 14): Vendor specific
INFO:__main__:  [Characteristic] 0000ff01-0000-1000-8000-00805f9b34fb (Handle: 17): Vendor specific (notify), Value: None
INFO:__main__:          [Descriptor] 00002902-0000-1000-8000-00805f9b34fb (Handle: 19): Client Characteristic Configuration) | Value: b'\x01\x00'
INFO:__main__:  [Characteristic] 0000ff02-0000-1000-8000-00805f9b34fb (Handle: 15): Vendor specific (write-without-response), Value: None
INFO:__main__:[Service] 0000180a-0000-1000-8000-00805f9b34fb (Handle: 20): Device Information
INFO:__main__:  [Characteristic] 00002a23-0000-1000-8000-00805f9b34fb (Handle: 21): System ID (read), Value: b'\xc7AP,\x0e\xe3'
INFO:__main__:[Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 6): Generic Attribute Profile
INFO:__main__:  [Characteristic] 00002b2a-0000-1000-8000-00805f9b34fb (Handle: 12): Database Hash (read), Value: b'\xd2\xa3w\x8d\xd7\n\xf5T\x91\xd9d\xc88i\xd1\x8b'
INFO:__main__:  [Characteristic] 00002a05-0000-1000-8000-00805f9b34fb (Handle: 7): Service Changed (indicate), Value: None
INFO:__main__:          [Descriptor] 00002902-0000-1000-8000-00805f9b34fb (Handle: 9): Client Characteristic Configuration) | Value: b'\x02\x00'
INFO:__main__:  [Characteristic] 00002b29-0000-1000-8000-00805f9b34fb (Handle: 10): Client Supported Features (read,write), Value: b'\x01'
nightcat91 commented 1 month ago

@fl4p Will it be possible to fix the Supervolt integration with the new UUIDs?

I would love to test it once available. Thanks

koebiii commented 3 weeks ago

I guess supervolt.py would have to be modified to hopefully get the newer (v3) BMS versions connected... likely breaking connection to previous (v2?) BMS version(s).

supervolt.py in line 19 and 20 today:

UUID_RX = '6e400003-b5a3-f393-e0a9-e50e24dcca9e' # std uart TX (tx on device side, rx on host)
UUID_TX = '6e400002-b5a3-f393-e0a9-e50e24dcca9e' # std uart RX

bt_protocol.pdf states:

SERVICE UUID: 0000ff00-0000-1000-8000-00805f9b34fb write characteristic UUID: 0000ff02-0000-1000-8000-00805f9b34fb read characteristic UUID: 0000ff01-0000-1000-8000-00805f9b34fb

supervolt.py change request:

UUID_RX = '0000ff02-0000-1000-8000-00805f9b34fb' # std uart TX (tx on device side, rx on host)
UUID_TX = '0000ff01-0000-1000-8000-00805f9b34fb' # std uart RX
nightcat91 commented 2 weeks ago

Is there somehow a way for us to do this change just locally with the already installed version?

I wouldnt mind changing the file and testing it, but I dont have the knowledge to make a pull request on github or clone the repository and be able to install another version in my HomeAssistant...

Otherwise I think only @fl4p can make that change and push a new version.

koebiii commented 2 weeks ago

You can run the stand-alone setup for testing at least, outside of Home Assistant, see https://github.com/fl4p/batmon-ha/blob/master/doc/Standalone.md. I was able to set it up and edit supervolt.py on Ubuntu. I ran out of time when I came to installing a local mqtt instance. This will have to wait for a few more days unfortunately...

nightcat91 commented 2 weeks ago

This is running as a HomeAssistant addon in my camper. I can´t run another standalone linux there sadly. Thats why I asked about beeing able to change that one file locally inside the installed HomeAssistant Addon?

koebiii commented 2 weeks ago

It was meant for testing only. In theory, you should be able to fork this project and get your modified version installed through your own repository... but it will take time, as always in software development. Sorry that I can't help more, lacking experience on that particular problem.

Karatzie commented 2 weeks ago

Hi.

please do not change the old Supervolt code. Please add a new type Supervolt 2024 Edition in a seperate code.

Thanks

BR Andreas