Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write characteristic UUID not found #3

Open
Colorado4Wheeler opened this issue Nov 21, 2021 · 26 comments
Open

Write characteristic UUID not found #3

Colorado4Wheeler opened this issue Nov 21, 2021 · 26 comments

Comments

@Colorado4Wheeler
Copy link

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
@sysofwan
Copy link
Owner

sysofwan commented Nov 22, 2021

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
Copy link
Owner

sysofwan commented Nov 27, 2021

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 sysofwan changed the title Cannot Connect to Light Write characteristic UUID not found Nov 27, 2021
@sysofwan
Copy link
Owner

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.

@claudiocn
Copy link

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

@sysofwan
Copy link
Owner

sysofwan commented Dec 8, 2021

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

@claudiocn
Copy link

claudiocn commented Dec 8, 2021

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
Copy link

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

@sysofwan
Copy link
Owner

sysofwan commented Dec 8, 2021

@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.

@claudiocn
Copy link

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

@sysofwan
Copy link
Owner

sysofwan commented Dec 8, 2021

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.

@claudiocn
Copy link

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

@sysofwan
Copy link
Owner

sysofwan commented Dec 8, 2021

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?

@claudiocn
Copy link

image

@claudiocn
Copy link

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

image

@sysofwan
Copy link
Owner

sysofwan commented Dec 8, 2021

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

@claudiocn
Copy link

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

@sysofwan
Copy link
Owner

sysofwan commented Dec 8, 2021

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.

@claudiocn
Copy link

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

@sysofwan
Copy link
Owner

sysofwan commented Dec 8, 2021

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

@claudiocn
Copy link

                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([])

@sysofwan
Copy link
Owner

sysofwan commented Dec 8, 2021

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.

@claudiocn
Copy link

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
Copy link

claudiocn commented Dec 8, 2021

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

@sysofwan
Copy link
Owner

sysofwan commented Dec 8, 2021

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?

@wroblear
Copy link

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,

@dave-code-ruiz
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants