home_assistant_delonghi_primadonna
home_assistant_delonghi_primadonna copied to clipboard
little problem on macOS
Hello! great I sow the bleak integration. Unfortunately there is a problem on macOS: I receive errors: [custom_components.delonghi_primadonna.device] BleakError: Device with address 00:A0:50:1D:99:27 was not found and it's related to https://bleak.readthedocs.io/en/latest/backends/macos.html
#https://github.com/hbldh/bleak/issues/252
Got familuar problem on Linux. Looks like this integration conflicts with the other bluetooth.
Checking.
Could you please check? 1.1.1 I have added BLE discovery as it was recommended by the Home Assistant community.
Sure, but I can't see difference...I use this MAC address: 8BB8F40D-4437-3E11-9FEE-97D8C0584A48 because bleak on my Mac can discover only this tipe of ids:
I can see a connection too:
But home assistant: 2022-07-31 21:56:28 WARNING (MainThread) [custom_components.delonghi_primadonna.device] BleakError: Characteristic 00002a00-0000-1000-8000-00805f9b34fb was not found!
This is what I found on the documentation: mac_addr = ( "24:71:89:cc:09:05" if platform.system() != "Darwin" else "243E23AE-4A99-406C-B317-18F1BD7B4CBE" )
That`s interesting. Could you please check if devices are connected? If it is plugin will not establish connection.
what do you mean? when the plugin establishes the connection i can see that the mac connects to the machine obviously
I tried with a python script:
python3 service_explorer.py INFO:__main__:Connected: True INFO:__main__:[Service] 00035b03-58e6-07dd-021a-08123a000300 (Handle: 14): Unknown INFO:__main__: [Characteristic] 00035b03-58e6-07dd-021a-08123a000301 (Handle: 15): Unknown (read,write,indicate), 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\x00\x00\x00\x00\x00' INFO:__main__: [Descriptor] 00002902-0000-1000-8000-00805f9b34fb (Handle: 17): Client Characteristic Configuration) | Value: b'\x00\x00' INFO:__main__: [Characteristic] 00035b03-58e6-07dd-021a-08123a0003ff (Handle: 18): Unknown (read,write), Value: b'\x00'
this is the script: https://github.com/hbldh/bleak/blob/develop/examples/service_explorer.py
if I perform a scan on a different machine (raspberry 4) the characteristics are more:
INFO:__main__:Connected: True INFO:__main__:[Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 10): Generic Attribute Profile INFO:__main__: [Characteristic] 00002a05-0000-1000-8000-00805f9b34fb (Handle: 11): Service Changed (indicate), Value: None INFO:__main__: [Descriptor] 00002902-0000-1000-8000-00805f9b34fb (Handle: 13): Client Characteristic Configuration) | Value: b'\x02\x00' INFO:__main__:[Service] 00035b03-58e6-07dd-021a-08123a000300 (Handle: 14): Unknown INFO:__main__: [Characteristic] 00035b03-58e6-07dd-021a-08123a000301 (Handle: 15): Unknown (read,write,indicate), 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\x00\x00\x00\x00\x00' INFO:__main__: [Descriptor] 00002902-0000-1000-8000-00805f9b34fb (Handle: 17): Client Characteristic Configuration) | Value: b'\x00\x00' INFO:__main__: [Characteristic] 00035b03-58e6-07dd-021a-08123a0003ff (Handle: 18): Unknown (read,write), Value: b'\x00'
Maybe it's a bleak version problem, it's possible to use the new one?
ok I was wrong, the problem is that on mac it is as if the device were registered twice so after the integration has been added it is no longer possible, even from the same mac, to communicate with the machine. I admit that I really don't know how to solve this problem
The new version of HA can partially solve it. They added kinda Bluetooth device manager. But, if you initiate bt session by the other software it will not help, cause coffee machine supports only one bt connection at once.
yes I'll try with the new version, with the raspberry no problem at all...with the MAC it seems as if it made two connections, one when I add the integration to HA and one when I try to use it and when I try to use it it does not find it because it is already used. (obviously when I try with the mac I turn off the raspberry)
in fact if I try to scan without adding the integration I can see from the Mac the Characteristics :
python3 service_explorer.py INFO:__main__:Connected: True INFO:__main__:[Service] 00035b03-58e6-07dd-021a-08123a000300 (Handle: 14): Unknown INFO:__main__: [Characteristic] 00035b03-58e6-07dd-021a-08123a000301 (Handle: 15): Unknown (read,write,indicate), 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\x00\x00\x00\x00\x00' INFO:__main__: [Descriptor] 00002902-0000-1000-8000-00805f9b34fb (Handle: 17): Client Characteristic Configuration) | Value: b'\x00\x00' INFO:__main__: [Characteristic] 00035b03-58e6-07dd-021a-08123a0003ff (Handle: 18): Unknown (read,write), Value: b'\x00'
then if I add the integration a can't perform the scan anymore....from THE SAME MACHINE...it's very strange....
however I noticed that there is no discovery by HA and I have to add the machine by hand, maybe that's the problem
however I noticed that there is no discovery by HA and I have to add the machine by hand, maybe that's the problem
Yes, that`s a next feature in this project. Autodiscovery and status parsing.
maybe this will solve the problem
nothing...it's like it makes two connections on macOS...can't understand...it's a bleak and coreBluetooth problem...on the raspberry no issues
On my experience bleak is a little bit raw. I got some issues then started bleak in the Docker HA. Try to exec this in your environment:
import asyncio
import binascii
import uuid
from bleak import BleakClient, BleakScanner
from bleak.exc import BleakError
MAC = "00:A0:50:82:75:CA"
NAME_CHARACTERISTIC = '00002A00-0000-1000-8000-00805F9B34FB'
GENERAL_SERVICE = '00001801-0000-1000-8000-00805f9b34fb'
async def main(ble_address: str):
device = await BleakScanner.find_device_by_address(ble_address, timeout=20.0)
async with BleakClient(device) as client:
services = await client.get_services()
print("Services:")
for service in services:
print(service)
value = bytes(await client.read_gatt_char(uuid.UUID(NAME_CHARACTERISTIC))).decode('utf-8')
print(value)
asyncio.run(main(MAC))
if got an issue submit it to the bleak project
ok...no sense:
(homeassistant) michele@perlhof ~ python3 service_explorer.py INFO:__main__:Connected: True INFO:__main__:[Service] 00035b03-58e6-07dd-021a-08123a000300 (Handle: 14): Unknown INFO:__main__: [Characteristic] 00035b03-58e6-07dd-021a-08123a000301 (Handle: 15): Unknown (read,write,indicate), 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\x00\x00\x00\x00\x00' INFO:__main__: [Descriptor] 00002902-0000-1000-8000-00805f9b34fb (Handle: 17): Client Characteristic Configuration) | Value: b'\x00\x00' INFO:__main__: [Characteristic] 00035b03-58e6-07dd-021a-08123a0003ff (Handle: 18): Unknown (read,write), Value: b'\x00'
but
(homeassistant) michele@perlhof ~ python3 provadimamica.py Services: 00035b03-58e6-07dd-021a-08123a000300 (Handle: 14): Unknown Traceback (most recent call last): File "/Users/michele/provadimamica.py", line 21, in <module> asyncio.run(main(MAC)) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete return future.result() File "/Users/michele/provadimamica.py", line 18, in main value = bytes(await client.read_gatt_char(uuid.UUID(NAME_CHARACTERISTIC))).decode('utf-8') File "/opt/homeassistant/lib/python3.10/site-packages/bleak/backends/corebluetooth/client.py", line 262, in read_gatt_char raise BleakError("Characteristic {} was not found!".format(char_specifier)) bleak.exc.BleakError: Characteristic 00002a00-0000-1000-8000-00805f9b34fb was not found!
I think there is a correlation here https://github.com/hbldh/bleak/issues/1189#issuecomment-1370045978
Was this solved, @bubez81? I think BLE support on macOS with HA is not great generally (not specific to this plug-in).
Solved with an esp32 😂
Great - same here. Can you please close the ticket?
Not sure if it's right to close the thicket...I have to try whitout the esp32