ha-triones icon indicating copy to clipboard operation
ha-triones copied to clipboard

Write characteristic UUID not found

Open Colorado4Wheeler opened this issue 4 years ago • 26 comments

I also detailed this on your announcement post on HASS forums.

The light gets detected but then when you select the light it refuses to connect to it and add it to HA.

2021-11-21 16:17:52 ERROR (MainThread) [custom_components.triones] Error getting status: Characteristic with UUID 0000ffd4-0000-1000-8000-00805f9b34fb could not be found!
2021-11-21 16:17:52 DEBUG (MainThread) [custom_components.triones] Traceback (most recent call last):
  File "/config/custom_components/triones/triones.py", line 73, in update
    await self._device.start_notify(R_CHARACTERISTIC_UUID, create_status_callback(future))
  File "/usr/local/lib/python3.9/site-packages/bleak/backends/bluezdbus/client.py", line 915, in start_notify
    raise BleakError(
bleak.exc.BleakError: Characteristic with UUID 0000ffd4-0000-1000-8000-00805f9b34fb could not be found!

2021-11-21 16:17:52 DEBUG (MainThread) [custom_components.triones]  cc 23 33

Colorado4Wheeler avatar Nov 21 '21 23:11 Colorado4Wheeler

Thanks for reporting and the helpful error log. I have an idea on fixing this, but it might take some time. I assumed that the characteristic UUID is the same for all Triones. Apparently not, so the implementation needs to query for the characteristics UUIDs first.

sysofwan avatar Nov 22 '21 07:11 sysofwan

I did more digging into this. I think the implementation correctly follows this protocol.

It is possible that your device is using different UUIDs. Can you connect to your device using a BLE debug app (such as this) and share the service and characteristic UUID it exposes?

sysofwan avatar Nov 27 '21 03:11 sysofwan

Found more characteristic UUIDs from another open source Triones implementation.

Do try the latest code if it fixes the issue. Otherwise, I will need you to do BLE scanning of your device the find the necessary UUIDs.

sysofwan avatar Nov 27 '21 06:11 sysofwan

This error originated from a custom integration.

Logger: custom_components.triones
Source: custom_components/triones/triones.py:101
Integration: Triones (documentation, issues)
First occurred: 15:06:06 (3 occurrences)
Last logged: 15:06:13

Error getting status: [org.bluez.Error.Failed] Software caused connection abort

Have the same problem, too. To give some context, it was this one: https://pt.aliexpress.com/item/33002886875.html

claudiocn avatar Dec 08 '21 15:12 claudiocn

@claudiocn this looks like a different error. Please enable debugging for full error trace.

sysofwan avatar Dec 08 '21 15:12 sysofwan

here it is:

2021-12-08 16:27:49 ERROR (MainThread) [custom_components.triones] Error getting status: [org.bluez.Error.Failed] Software caused connection abort
2021-12-08 16:27:49 DEBUG (MainThread) [custom_components.triones] Traceback (most recent call last):
File "/home/homeassistant/.homeassistant/custom_components/triones/triones.py", line 69, in update
await self._device.connect(timeout=20)
File "/srv/homeassistant/lib/python3.9/site-packages/bleak/backends/bluezdbus/client.py", line 278, in connect
assert_reply(reply)
File "/srv/homeassistant/lib/python3.9/site-packages/bleak/backends/bluezdbus/utils.py", line 23, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Software caused connection abort
2021-12-08 16:27:49 DEBUG (MainThread) [custom_components.triones] cc 23 33

claudiocn avatar Dec 08 '21 16:12 claudiocn

Seems to be a timeout, don't know why :\

claudiocn avatar Dec 08 '21 16:12 claudiocn

@claudiocn this is common. See this issue. It is a BLE connection issue that will self recover. The debug log “cc 23 e3” shows that it successfully recovered and sent a BLE message.

I will make an update to the logs to make it clearer.

sysofwan avatar Dec 08 '21 16:12 sysofwan

But the problem is: it doesn't connect at all when setupping.

Just to give a try, tested with the following tool and it worked perfectly: https://github.com/vinceroti/bt-triones

claudiocn avatar Dec 08 '21 16:12 claudiocn

Oh, so it never finish setup. The library you tested is using your browser’s (local) Bluetooth hardware, not Home Assistant’s.

For troubleshooting:

  1. Make sure no other device is connected to the light. It will refuse connection otherwise.
  2. Retry a few times. I do see this error intermittently, but it usually goes away after a few times.

sysofwan avatar Dec 08 '21 16:12 sysofwan

Disconnected from the other library. Didn't work. Turned it off and on again. Didn't work. Retried a couple of times and nothing.

2021-12-08 17:05:57 ERROR (MainThread) [custom_components.triones] No supported read/write UUIDs found
2021-12-08 17:05:57 DEBUG (MainThread) [custom_components.triones] cc 23 33
2021-12-08 17:06:06 ERROR (MainThread) [custom_components.triones] No supported read/write UUIDs found
2021-12-08 17:06:06 DEBUG (MainThread) [custom_components.triones] cc 23 33
2021-12-08 17:06:13 ERROR (MainThread) [custom_components.triones] No supported read/write UUIDs found
2021-12-08 17:06:13 DEBUG (MainThread) [custom_components.triones] cc 23 33
2021-12-08 17:07:12 ERROR (MainThread) [custom_components.triones] Error getting status: Device with address FF:FF:CD:02:EE:19 could not be found. Try increasing `timeout` value or moving the device closer.
2021-12-08 17:07:12 DEBUG (MainThread) [custom_components.triones] Traceback (most recent call last):
File "/home/homeassistant/.homeassistant/custom_components/triones/triones.py", line 69, in update
await self._device.connect(timeout=20)
File "/srv/homeassistant/lib/python3.9/site-packages/bleak/backends/bluezdbus/client.py", line 216, in connect
raise BleakError(
bleak.exc.BleakError: Device with address FF:FF:CD:02:EE:19 could not be found. Try increasing `timeout` value or moving the device closer.
2021-12-08 17:07:12 DEBUG (MainThread) [custom_components.triones] cc 23 33

claudiocn avatar Dec 08 '21 17:12 claudiocn

Thanks, this is have better logs and is the same issue here. No supported read/write UUIDs found means that the read UUID for your device is not known. Unfortunately, Triones uses many different UUIDs.

The test tool you used will only do writes to your device, but not reads (it does not know the current device state). The missing UUID here is for reads.

Can you help do this:

It is possible that your device is using different UUIDs. Can you connect to your device using a BLE debug app (such as this) and share the service and characteristic UUID it exposes?

sysofwan avatar Dec 08 '21 17:12 sysofwan

image

claudiocn avatar Dec 08 '21 17:12 claudiocn

From what I see, it's doing a match, it's a known UUID :\

image

claudiocn avatar Dec 08 '21 18:12 claudiocn

Yeah, it’s weird. I’ll add some more debug logs later to figure this out.

sysofwan avatar Dec 08 '21 18:12 sysofwan

Well, using it directly through the gatttool tool, did the following commands and using the source code in the bt-triones to get the values to be sent, did the following and it's working perfectly from the RPi from where I'm using Home Assistant:

  • gatttool -I to start
  • connect FF:FF:CD:02:EE:19 to connect to the trione with that Mac Address
  • primary to see the actions (handle), the first one did nothing, but the second one (0x007) did! so with the bt-triones values...
  • char-write-cmd 0x007 cc2433 to turn off
  • char-write-cmd 0x007 cc2333 to turn on
  • char-write-cmd 0x007 5600ff0000f0aa to change to colour: R=00, G=ff, B=00 image

values come from here (from bt-triones source code): image image image

claudiocn avatar Dec 08 '21 19:12 claudiocn

Can you add logs to the triones.py:72 uuid detection code to see why it’s not finding the uuid?

You can modify the code inside config/custom_components/triones folder, and restart HA afterwards.

sysofwan avatar Dec 08 '21 19:12 sysofwan

It seems to be empty.

2021-12-08 20:00:01 INFO (MainThread) [custom_components.triones] {}
2021-12-08 20:00:01 ERROR (MainThread) [custom_components.triones] No supported read/write UUIDs found
2021-12-08 20:00:01 DEBUG (MainThread) [custom_components.triones] cc 23 33

image

claudiocn avatar Dec 08 '21 20:12 claudiocn

Try logging self._device.services.characteristics.values() instead

sysofwan avatar Dec 08 '21 20:12 sysofwan

                LOGGER.info(self._device)
                LOGGER.info(self._device.services)
                LOGGER.info(self._device.services.characteristics.values())
2021-12-08 20:06:01 INFO (MainThread) [custom_components.triones] BleakClientBlueZDBus, FF:FF:CD:02:EE:19
2021-12-08 20:06:01 INFO (MainThread) [custom_components.triones] <bleak.backends.service.BleakGATTServiceCollection object at 0x7f4a0c90d0>
2021-12-08 20:06:01 INFO (MainThread) [custom_components.triones] dict_values([])

claudiocn avatar Dec 08 '21 20:12 claudiocn

Not sure why the library is not detecting any characteristics. You can check if it detects it if we go through each service. Sample code here.

Meanwhile, you can hardcode the uuid in code too as a workaround. Just set self._write_uuid and self._read_uuid in the __init__ method in triones.py.

sysofwan avatar Dec 08 '21 20:12 sysofwan

Did some digging with that sample code. the list of services is empty. Can't do a ".values()" but printing for each loop returns zero iterations. Really strange.

Probably because of that, even if I put the UUID, it doesn't work:

2021-12-08 20:59:23 DEBUG (MainThread) [custom_components.triones] Traceback (most recent call last):
File "/home/homeassistant/.homeassistant/custom_components/triones/triones.py", line 90, in update
await self._device.start_notify(self._read_uuid, create_status_callback(future))
File "/srv/homeassistant/lib/python3.9/site-packages/bleak/backends/bluezdbus/client.py", line 915, in start_notify
raise BleakError(
bleak.exc.BleakError: Characteristic with UUID 0000ffd9-0000-1000-8000-00805f9b34fb could not be found!
2021-12-08 20:59:23 DEBUG (MainThread) [custom_components.triones] cc 23 33

claudiocn avatar Dec 08 '21 21:12 claudiocn

Not sure if this is useful, but here's some additional information:

pi@raspberrypi:~ $ gatttool -i hci0 -b FF:FF:CD:02:EE:19 --characteristics
Discover all characteristics failed: Request attribute has encountered an unlikely error
pi@raspberrypi:~ $ gatttool -i hci0 -b FF:FF:CD:02:EE:19 --primary
attr handle = 0x0001, end grp handle = 0x0004 uuid: 0000ffd0-0000-1000-8000-00805f9b34fb
attr handle = 0x0005, end grp handle = 0x0007 uuid: 0000ffd5-0000-1000-8000-00805f9b34fb
pi@raspberrypi:~ $ gatttool -i hci0 -b FF:FF:CD:02:EE:19 --char-read
A valid handle is required
pi@raspberrypi:~ $ gatttool -i hci0 -b FF:FF:CD:02:EE:19 --interactive
[FF:FF:CD:02:EE:19][LE]> exit
pi@raspberrypi:~ $ gatttool -i hci0 -b FF:FF:CD:02:EE:19 --char-desc
handle = 0x0001, uuid = 00002800-0000-1000-8000-00805f9b34fb
handle = 0x0002, uuid = 00002803-0000-1000-8000-00805f9b34fb
handle = 0x0003, uuid = 0000ffd4-0000-1000-8000-00805f9b34fb
handle = 0x0004, uuid = 00002902-0000-1000-8000-00805f9b34fb
handle = 0x0005, uuid = 00002800-0000-1000-8000-00805f9b34fb
handle = 0x0006, uuid = 00002803-0000-1000-8000-00805f9b34fb
handle = 0x0007, uuid = 0000ffd9-0000-1000-8000-00805f9b34fb

claudiocn avatar Dec 08 '21 21:12 claudiocn

Another guess is we need to call await self._device.get_services() explicitly before querying the services in some implementation. Example here.

Can you try it?

sysofwan avatar Dec 08 '21 21:12 sysofwan

the same problem, No supported read/write UUIDs found I have changed UUIDs for that which I got in Bluetootk scanner app, the same, any idea? I see that there is no new information since 12.2021,

wroblear avatar Apr 15 '22 16:04 wroblear

I create supported code repository for uuid 0000fff3-0000-1000-8000-00805f9b34fb is elk-bledom strip.

https://github.com/dave-code-ruiz/elkbledom-ha

dave-code-ruiz avatar Jun 01 '22 08:06 dave-code-ruiz