#devs_bluetooth-archived

1 messages · Page 5 of 1

wicked prawn
#

The HomeKit protocol is pretty robust encryption wise. You’d have to make a test accessory (eg with the library that HomeKit bridge uses) that exposed all these characteristics and hope the app believed it was a lock or decompile the app.

#

Sometimes you get lucky and the custom chars are more self documenting (on the ip transport we get a name field)

green mural
#

🥲 sounds a lil painful, any examples? Could I pass the real lock through a homekit bridge-like system and intercept it?

#

Could the app limit itself to only talk the right stuff to a SENSE lock when connected over bluetooth? (It doesn't come in with any other connectivity systems afaik)

wicked prawn
#

And as for decompiling, usually that was done on android apps (not HomeKit stuff) and I bet iOS apps are harder to decompile:)

green mural
#

Yep it's not too fun

wicked prawn
green mural
#

I believe the lock does have Android support but I feel like reversing everything would be a lot more work than just one homekit service

wicked prawn
#

The project was called fakegato

green mural
#

ooh elgato

#

..is this from the company that does capture cards? strange side buisness

#

gonna look into this project

wicked prawn
#

They were definitely mocking out characteristics because they unlocked app features that don’t map to the current eve lineup

green mural
#

LMAO

#

that's neat

wicked prawn
#

The capture cards were the side business I think

#

The elgato brand and cards were sold to Corsair and eve systems was what remained

#

This was back in 2018 or so

green mural
#

yeah i just did a lil reading

#

elgato brand & capture cards came first in 2012, then eve in 2014, then elgato brand (and cards) was sold to corsair in 2018

#

fakegato looks neat. I wonder if there's a more recent similar thing

wicked prawn
#

Do you have a Mac?

green mural
#

I do

wicked prawn
#

I don’t know if it has enough logging but maybe the accessory simulator might work? I’ve not really done anything with it myself so not even sure if the lock app would see it.

green mural
#

gonna see if i can get that

#

yup i can

wicked prawn
green mural
#

I'm gonna give this a try

wicked prawn
#

I just hope it supports custom chars

green mural
#

this is very clearly old sw based on the icon and the old font

#

but like, updated with the new design language in parts

#

kinda funny

#

lol i turned on the BLE switch (which i guess starts broadcasting and it instantly showed up

#

1s, tryna share screenshot

#

oh i can't send images here that's why

#

nvm then, it shows up that's a good sign

green mural
wicked prawn
#

So if you look at the file you linked to

#

A bunch of UUID’s end 0000-1000-8000-0026BB765291

#

And they have name fields

#

Those are the apple ones and part of the HomeKit spec

#

The others are custom or vendor characteristics

#

I’m just hoping the simulator doesn’t limit itself to apple defined features

green mural
#

I don't know if it does

#

let me screenshot this so i know if it's what you're looking for

#

This app is actually really neat lol, I can expose a BLE accessory or a IP accessory

wicked prawn
#

That looks perfect

green mural
#

okay so i need to just replicate that json from earlier?

wicked prawn
#

Yep hopefully

green mural
#

this is hopefully a good sign

#

AHAH you can export simulated accessories - and they're just (binary) plists

#

really freaking big ones but plists

#

It doesn't like this UUID: 00000054-0000-1000-8000-0026BB765291

#

oh that's software revision

green mural
#

... format: null

#

@wicked prawn it worked

wicked prawn
#

Hurrah

#

Did you get enough information?

green mural
#

I haven't gotten any logs yet

#

but it shows up in the schlage app

#

i wasn't able to replicate all of the services and characteristics but it seems like enough

#
09/22/23 04:03:36: SENSE   (INFO) Remote write performed on: service: Unnamed (7F0DEE73-…), characteristic: AFAE7AD2-8DD3-4B20-BAE0-C0B18B79EDB5, new value -> {length = 49, bytes = 0x002f0010 00000000 00000000 dd8a065a ... 0000173b 00050100 }
#

@wicked prawn i've got it

#

the lock writes to the AFAE7AD2-8DD3-4B20-BAE0-C0B18B79EDB5 characteristic. not sure how this looks with multiple codes though

#

OH you made aiohomekit

#

i had no idea

#

Where would the vendor service get added? I don't see any other vendor services, only characteristics

wicked prawn
green mural
#

i see

#

very neat regardless

wicked prawn
#

We’ve never had a vendor service before

green mural
#

oh huh

#

idk if it is a vendor service but it isn't known

wicked prawn
#

Usually you can just key off the characteristic

green mural
#

and wasn't reserved (so it let me add it)

wicked prawn
#

In which case you don’t neeeed the service

green mural
#

Wym key off

#

I'm still looking at how all the python homekit stuff works

wicked prawn
#

So there are 3 entity types in HomeKit

#

Ones that are tied to a single characteristic

#

Ones that are tied to a service

#

And ones that are tied to an accessory

#

Generally we use single characteristic entities for vendor stuff

green mural
#

interesting

#

Don't I need the service though to actually update the value?

#

or does that not matter

#

can you just tell homekit "update this characteristic" without the service

#

I think I'm gonna get some sleep but really happy to have even gotten this far. The lock writes 002f00100000000000000000849f640915f8b13d01044841535302043905000003050000173b7f04050000173b000501 (hexed.it link) to AFAE7AD2-8DD3-4B20-BAE0-C0B18B79EDB5 and the access code length to EEC26990-F628-11E3-A3AC-0800200C9A66 (Maybe only for the first code?)

The code name (HASS) and code (1337) are pretty obviously seen in there, but it also contains data like schedule, that I haven't even begun to look into

The lock tries to read access codes from 87D91EC6-C508-4CAD-89F1-A21B0BF179A0 but I don't know what this is meant to contain.

Other thing I noticed is they aren't using the standard battery level characteristic? Battery level is stored in 63D23C2F-2FBB-45E8-8540-47CC26C517D0

#

Is this still the right channel to do this in or is there a homekit channel? I don't see one

wicked prawn
#

You could start a thread

green mural
#

Yeah sure, why not

wicked prawn
#

(Bit frantic on my end but this looks like a good start)

green mural
#

Schlage SENSE HomeKit reversing

snow gull
#

hi how to integrate location finder itag in HA?

#

thank you for your help

native hamlet
glad mantle
#

Hi. I have question about BT classic connection speed and GATT Service caching. Should I do this? Or this is build-in? Or some other things for increase connection speed?

swift gale
#

Hi friends, I am wondering if there is a basic skeleton for a fairly simple BLE integration (discover by service UUID, read/write some GATTs). The docs have a lot of info but I'm having trouble tying together how the overall flow runs.

#

In the past somebody's mentioned LD2410 as a good example, but it's still a fairly big integration by the looks

#

I'm having trouble understanding the basic flow... I am putting my service UUID(s) in the manifest.json, but I'm not sure how that 'discovered' device comes to be - does it need to go through the config flow?

wicked prawn
#

Yep

#

When the core Bluetooth integration sees the uuids you told us in manifest.json it calls async_step_bluetooth

#

If the user is doing the manual “add integration” ui flow, then it’s async_step_user

#

All config flows in core have 100% test coverage and they have to drive a flow to completion

#

So they are a good way to see all the outcomes

swift gale
#

I wonder whether there's a good debugging tool to dig through what the Bluetooth proxy sees. I have LightBlue BLE on my iPhone which works okish but (a) I'm not always in the short range of the device (tap timer outside) and (b) this particular device likes to disconnect immediately if I connect to it

swift gale
half stag
#

I'm getting a bleak.exc.BleakDBusError: [org.bluez.Error.AuthenticationFailed] Authentication Failed error when using a integrated bluetooth adapter, when calling bleak pair(), but not when connecting using ESPHome proxies.
If I first pair manually using bluetoothctl, then everythin works.
Is this some known issue? Anything I can/need to add to the integration to make it pair?

half stag
#

I just found that that if I have bluetoothctl running, it prompts me with [agent] Accept pairing (yes/no): and if I enter yes everything works.
That also explains why there is no issues with ESPHome BT Proxy I guess

half stag
#

bah, it is a bleak limitation since it does not have an agent 😦

glad mantle
frosty plinth
#

If you are talking about using bleak retry connectors connection option to enable caching that I would say yes as long as the device doesn’t have a problem with it and properly implements the service hashing. pySwitchbot and aiohomekit both have methods to clear the service’s cache in the event bluez caches it incorrectly which was a problem on older versions

elfin prawn
#

Sooo.... I've been messing around with making a custom integration to track bluetooth devices by area. I think it's ready to have some other people poke holes in it, so thought I'd post it here first in case it has some significant issues that I'd want to address before unleashing it on unsuspecting users. Also huge thanks to those in here who have helped me out with my muddling around the codebase! 😄
https://github.com/agittins/bermuda/

wicked prawn
elfin prawn
lost goblet
#

I'm getting user reports on dropped active connections with HAOS 11. Appearantly it's an "Unlikely error"...

[org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Unlikely Error)

lost goblet
#

The first one is for the same devices.

frosty plinth
#

someone mentioned the yale lock issue in #bluetooth-archived .. I'm travelling so I won't be able to update/test it until after the 23rd though

lost goblet
#

Except that addon uses the Bluetooth adapter directly, while my integration uses HA bluetooth.

frosty plinth
#

So probably the BlueZ update

#

seems haos has 5.69

#

which doesn't have that fix

lost goblet
#

I'll just tell people to have patience or revert to 10.5. Enjoy your travels.

frosty plinth
#

pretty sure its the same issue and 5.70 will fix it

lost goblet
#

I love it when people know their stuff well enough to see "Unlikely error" and immedietely go "Oh. I know what that is!"

wicked prawn
#

More like “unlikely upstream didn’t break something error”

#

There was a big kernel regression last time

half stag
#

where is the "glue" between esphome bluetooth proxy and bleak client?
I'm trying to debug why the disconnect_callback passed to bleak.client is not being called when using ESPHome...

half stag
#

I checked it, but it looked something else

#

oh, it is it indeed 🤦‍♂️

#

since it did not have the disconnect_callback arg, I dismissed it

#

thanks!

#

_on_bluetooth_connection_state is not called when I call disconnect() on the client. do you know if that is intended?

#

should it be called only when the disconnection is not "intended"?

frosty plinth
#

I think the disconnected callback is only called when the device/esp disconnects not when its requested

half stag
#

yeah, that is the issue

#

that fixes it, but I am in no way familiar with the bluetooth proxy code to be sure that it is fine to do it that way

frosty plinth
#

still checking though

half stag
frosty plinth
#

hmm

#

that will call the disconnected callback even if the device was never connected

half stag
#

true. I can do was_connected = self.is_connected before disconnecting

#

and check was_connected to call the callback method

frosty plinth
#

suggested change in the PR

#
diff --git a/homeassistant/components/esphome/bluetooth/client.py b/homeassistant/components/esphome/bluetooth/client.py
index d44d331248b..970e866b27b 100644
--- a/homeassistant/components/esphome/bluetooth/client.py
+++ b/homeassistant/components/esphome/bluetooth/client.py
@@ -392,8 +392,8 @@ class ESPHomeClient(BaseBleakClient):
         return await self._disconnect()
 
     async def _disconnect(self) -> bool:
-        self._async_disconnected_cleanup()
         await self._client.bluetooth_device_disconnect(self._address_as_int)
+        self._async_ble_device_disconnected()
         await self._wait_for_free_connection_slot(DISCONNECT_TIMEOUT)
         return True
half stag
#

when it calls _async_ble_device_disconnected(), won't is_connected be False already?

#

ah no, that is done on the cleanup

#

let me test it locally

frosty plinth
#

I just did with 10 yale locks

#

working though some homekit devices now

half stag
#

yep, works!

frosty plinth
#

thanks

#

testing is good here as well

half stag
frosty plinth
#

nope, the previous owner really liked to put in doors for some reason

zinc trout
#

I'm trying to figure out the appropriate coordinator to use for a custom integration (https://developers.home-assistant.io/docs/core/bluetooth/bluetooth_fetching_data/). The underlying device library uses Bleak, sending commands with write_gatt_char and then listening for responses with start_notify. I don't really know much about bluetooth (e.g. "advertisements" and what qualifies as active vs. passive). Anyone more knowledgeable able to point me towards the appropriate coordinator setup? (each update I get from the device I need to use to update multiple different entities)

wicked prawn
#

Some devices (sensors) you don’t need to use bleak and you don’t need to connect to them. They just blast their current state into that air (sometimes once a second). And we can decode those broadcasts and turn them into entities. That’s what passive is all about.

#

You probably want to look at ld2410_ble as a starting point

zinc trout
#

thanks so much!

zinc trout
#

Interesting. with this approach, does _async_update_data still get called by the system and just act as a no-op? Or does omitting update_interval mean the system never tries to poll?

grizzled violet
#

I've an integration that connects to a bt device. If the device is not online, the integration fails and I need to reload it when the device is online. Is there some kind of bt event that the integration could listen to to self heal?

wicked prawn
indigo dew
#

Does anyone have any advice or somewhere to look for why BleakClient() would not setup?

                if not client.is_connected:
                    await client.connect()
                print(f"Connected: {client.is_connected}")```

Sample code in a config_flow never gets past line 1, the only relevent log data i can see is:

```2023-11-12 14:44:36.000 INFO (SyncWorker_0) [homeassistant.loader] Loaded nespresso from homeassistant.components.nespresso
2023-11-12 14:44:39.514 INFO (MainThread) [asyncio] execute program 'bluetoothctl': <_UnixSubprocessTransport pid=660937 running stdout=<_UnixReadPipeTransport fd=27 polling>>
2023-11-12 14:44:39.522 INFO (MainThread) [asyncio] <_UnixSubprocessTransport pid=660937 running stdout=<_UnixReadPipeTransport fd=27 polling>> exited with return code 0
2023-11-12 14:44:39.523 INFO (MainThread) [asyncio] <_UnixReadPipeTransport fd=27 polling> was closed by peer
2023-11-12 14:45:09.534 ERROR (MainThread) [aiohttp.server] Error handling request```

Appreciate any help.
#

(discovered.device is a BLEDevice)

indigo dew
#

Turns out HABleakClientWrapper overrides BleakClient and doesnt return a cooroutine so client = BleakClient(BLEDevice) is sufficient.

carmine bone
#

Hi, how can I modify the example sensor example in order to add notifications support? In my case I'm using a BLE device, and I'd like to wait for notifications and when they're received the integration should process the data and update it. I couldn't find many infos online (at least that I could understand). Thanks!

wicked prawn
#

The proxies and dongles both have limited numbers of parallel connections, and using GATT notifications would quickly chew through that.

#

Many devices use the blue advertisements as a way to work around this, by either putting the sensor data in the advertisement and or including some sort of counter to help the controller know when to connect.

#

If you are making your own firmware that’s definitely the best route.

#

There’s a presence sensor in core that does it anyway. In that situation, presence detection you don’t want lag. Its name starts ld2 something or other.

broken root
#

trying to make a standalone ble scanner with esp32 to detect my phone.
can someone guide me to how I can check advertised MAC against IRK:key ?
reason: this esp is far from any wifi, I cannot use esphome there

indigo dew
# wicked prawn In general it’s discouraged

On the same vein. I'm working on an integration for a coffee machine. It uses a notify method to provide a response to the given command. Should i expose this as a sensor to feedback into HA? Wondering how to let the frontend know if the brew command was successful or failed for some reason...

wicked prawn
#

byte ordering easy to screw up, and i think one of the esp32 libs put the MAC in a different order to what we are used to

broken root
#

I'll see if I can plug something together with this and the espresense code

wicked prawn
#

the HA code does a lot of stuff to minimize AES costs

#

like negative caching false matches, so you don't have to check them every time there is a broadcast

#

if your esp code has access to it (we don't in HA yet) there is a flag that says whether its a classic static MAC address or whether its a random one

#

you can ignore a lot of broadcasts by filtering out the static addresses

broken root
#

yeah nimble allows that

wicked prawn
#

It would let people create their own automations (like a notification to their device of choice), integrate with the log book, let you see in the UI when a brew last finished

#

Given its a point in time event, rather than a state of being on or off, event is just a much better fit than sensor

#

I think in your case notify is definitely reasonable, as long as you are only doing it when a brew is in progress

indigo dew
wicked prawn
broken root
#

it'll live in my garage, acting as garage door opener

carmine bone
wicked prawn
#

Xiaomi_ble, govee_ble, inkbird_ble

#

I think oral b?

#

Pretty sure there are others

elfin prawn
carmine bone
elfin prawn
#

Oh cool. I have some nrf51 modules I've been playing with (haven't touched them in a few months, but they're still on my desk!) that I plan to build bthome remote control buttons with. Actually... I am 99% sure I got to the point where I could flash one and have it publish bogus data via bthome. I'll dig it out and throw it up on github if that might be useful for you. I'm pretty sure it's un-encrypted payload though (because lazy/daft) and not sure if it's using bthome v1 or v2. But between that and then looking at the code for pvvx's thermometers (which does v1 encryption) it might give you a decent head-start.

elfin prawn
#

@carmine bone I found it - have thrown it up at https://github.com/agittins/nRF51-BTHome - please excuse my inability to write sensible c code! 😅 But at least it shows the bare minimum required to send BLE packets from an nRF51822.

#

Oh god... I last touched that back in January - more than "a few months"!

elfin prawn
# wicked prawn if your esp code has access to it (we don't in HA yet) there is a flag that says...

I'm looking at adding IRK support at some point to my Bermuda integration (https://github.com/agittins/bermuda/issues/44). I haven't done my own proper searching yet (and frankly I can't remember if I asked you already, sorry), but just off the top of your head, is there an API to your integration that I could leverage to get easier support? I feel like it might be smarter to use your integration to identify any known IRK devices rather than duplicating those things in mine (and not benefiting from future work you put in it).

#

(doh, sorry for the @)

carmine bone
elfin prawn
#

So what's there did build and load on a real nRF51822 (well, I assume it's real!) and it broadcasts valid BTHome packets, which homeassistant picked up with discovery and added to my devices. The sensor values themselves are bogus, but it does "work" in the most basic sense. Code is as pretty as a bucket of smashed crabs, but it worked at least once.

wicked prawn
carmine bone
elfin prawn
# wicked prawn Depends what you need from the API. It’s been a while since I had time to play b...

Ok, sounds promising then. I'm basically "tracking" everything, but by (naughtily) copying data out of the bluetooth advertisement storage, so I'd probably want to throw every "new" MAC address at some IRK resolver (like your integration) and see if it belongs to a "known" key, in which case I'd add it to my list of devices I create sensors for. If I use your integration I wouldn't have to provide a means for the user to enter keys etc, since they would set up their devices once in your private_ble_device and I would include those in the devices I track area and distance for, and keyed against the private address.

elfin prawn
carmine bone
elfin prawn
wicked prawn
#

You’ll need to fish the irks out of my config entries to be able to use my API iirc

#

You register an irk to track rather than ask it about a mac

#

It tries to be clever about not doing AES ops on every packet - so caching negative resolves, tracking current irk->mac relationships, and busting those caches at the right times.

#

You might be able to read out of those internal caches

#

I’d be interested in seeing if we could work something out so that you could just get what you need from the device tracker entities that were Bluetooth based.

#

Like Ibeacon resolves random addresses to a known beacon too in some cases I think?

#

So users could set up the boring ble trackers, beacon trackers, and private ble trackers, and you just attach to device trackers of type Bluetooth, and they expose their current Bluetooth address. And hopefully very little extra configuration?

elfin prawn
#

Awesome, thanks. Yeah iBeacons is another thing I need to add support for, but I think for those one just matches on the UUID in the advert, so no crypto stuff required.

wicked prawn
#

You should get an event from the state machine then when the ble address changes, regardless of the underlying implementation.

elfin prawn
wicked prawn
#

That might work today for private ble device because the current address is an extra attribute on the device tracker entity

#

And i cribbed from ibeacon so might get that for free as might has same extra attribute

elfin prawn
#

The way I'm currently doing things is I internally track every observed advertiser, and in my config flow the user can select which devices (by MAC address) that they'd like to have Area, Distance and device_tracker entities created. But since I only track by observed MAC, ibeacons and private addresses are... suboptimal user experiences 🙂

#

The reason I track all devices is because my pipedream is to approximate a solution for every advertiser and proxy in 2d space - so more data = more garbage = more output, as is my understanding.

#

Hmm. I haven't felt a lot of love for how ibeacon does its matching/ident of devices, but that's probably (as usual) due to my lack of understanding of the nuances rather than some fault of the integration 🙂

wicked prawn
#

From a ux perspective my proposal would mean the user could pick by device tracker entities. And it would be reasonable to enable those macs by default.

#

Under the hood you could still track everything of course

#

And if there were other Bluetooth trackers, as long as they expose the current MAC address you don’t have to do any extra work

#

Eg I’d dearly like to figure out how to track my AirPods - I don’t think they use irks

elfin prawn
#

Yeah that sounds like a pretty good strategy. So I'd listen to events announcing the change of address for any known beacons/pBLE's and just track those associations.

wicked prawn
#

I’m hoping to find bandwidth to tidy up the main ble tracker, as it has lots of low hanging fruit. Like ignoring random addresses.

#

So could all use that scheme eventually maybe.

elfin prawn
wicked prawn
#

Probably

#

Real life beckons… ttfn

elfin prawn
#

No worries - thanks for your help - I'm not sure when I'll get to this feature but I'll save the notes! 🙂

grizzled violet
#

Has someone worked with bluetooth mesh and has a good example that shows how to connect to a network and so on?

wicked prawn
#

There’s nothing in core or esphome for Bluetooth mesh, and there’s no integration in HA with bluezs flavour of Bt mesh. And afaik no one is working on getting anything like that into core.

tranquil marlin
brave gale
#

hello everyone, is there anyway to load custom firmware in HAOS? I have a fairly new NUC bluetooth that's not supported out of the box, I have the firmware - I just need to figure out how to load it in HAOS.
Update- I got it figured, just needed to restart it once custom firmware was loaded.

grizzled violet
#

What kind of mesh are you talking about

mystic mural
#

I'm interested in adding additional support for Thermopro devices. It seems like the real magic happens in the thermopro_ble library. What is the recommended way to setup my dev environment so that the devcontainer will use my own version of thermopro_ble instead of the public one?

wild igloo
#

Hi, I am developing a new integration for my new christmas light chain I bought. I have reverse engineered it so now all that is left is the development of integration. However, I am seeing a weird behaviour where command from HA is not reflected on state of chain - chain does not turn off. What am I doing wrong?

jaunty rainBOT
#

@wild igloo I converted your message into a file since it's above 15 lines :+1:

wild igloo
#

The HA logs also contain the last "None" log I forgot to include it. It looks like both the service and characteristic is the same, but for some reason the command is not respected when issued by HA. Both script and HA run on Mac M2.

#

It does detect characteristics etc flawlessly, so it must be connecting properly...

#

At this point I am trying to just run one command on __init__.py to test it

#

I needed to change this:

await client.write_gatt_char(writeCharacteristic, command, True)
Now it works!

frosty plinth
young forge
#

@frosty plinth That's great! So with these changes, what would the process look like to set up a local dev environment for using a BT proxy with Bleak outside of HA?

frosty plinth
#

Nothing yet. That’s a few more steps down the line. Maybe by the end of the year if I don’t hit any more roadblocks

young forge
#

Great, I will be eagerly awaiting the results 🙂

mystic mural
#

If anyone is able, I could use some help reverse engineering the advertisements for this thermopro tempspike:
AdvertisementData(local_name='TP970R', manufacturer_data={13824: b'\x00\x05\x0b6\x00'}, service_uuids=['72fbb631-6f6b-d1ba-db55-2ee6fdd942bd'], rssi=-29)
It should be giving me two temperatures (the probe, and ambient), but I can't make sense of it so far.

young forge
#

@mystic mural I find it helpful to capture a series of advertisement packets over a period of time as the temperature reading changes. That way you can rule out the bytes that don't change, and the ones that do change are probably what you're looking for.

mystic mural
#

it appears first and last bytes are always 0

#
AdvertisementData(local_name='TP970R', manufacturer_data={14336: b'\x00\xfd\n6\x00'}, service_uuids=['72fbb631-6f6b-d1ba-db55-2ee6fdd942bd'], rssi=-32)
AdvertisementData(local_name='TP970R', manufacturer_data={14848: b'\x00\xfd\n6\x00'}, service_uuids=['72fbb631-6f6b-d1ba-db55-2ee6fdd942bd'], rssi=-36)
AdvertisementData(local_name='TP970R', manufacturer_data={15104: b'\x00\xfb\n6\x00'}, service_uuids=['72fbb631-6f6b-d1ba-db55-2ee6fdd942bd'], rssi=-39)
AdvertisementData(local_name='TP970R', manufacturer_data={15360: b'\x00\xfa\n6\x00'}, service_uuids=['72fbb631-6f6b-d1ba-db55-2ee6fdd942bd'], rssi=-38)
AdvertisementData(local_name='TP970R', manufacturer_data={15616: b'\x00\xfa\n6\x00'}, service_uuids=['72fbb631-6f6b-d1ba-db55-2ee6fdd942bd'], rssi=-38)
AdvertisementData(local_name='TP970R', manufacturer_data={15360: b'\x00\xfb\n<\x00'}, service_uuids=['72fbb631-6f6b-d1ba-db55-2ee6fdd942bd'], rssi=-37)
AdvertisementData(local_name='TP970R', manufacturer_data={15360: b'\x00\xf8\n<\x00'}, service_uuids=['72fbb631-6f6b-d1ba-db55-2ee6fdd942bd'], rssi=-33)
AdvertisementData(local_name='TP970R', manufacturer_data={15104: b'\x00\xf8\n=\x00'}, service_uuids=['72fbb631-6f6b-d1ba-db55-2ee6fdd942bd'], rssi=-37)
AdvertisementData(local_name='TP970R', manufacturer_data={15104: b'\x00\xf8\n=\x00'}, service_uuids=['72fbb631-6f6b-d1ba-db55-2ee6fdd942bd'], rssi=-38)
AdvertisementData(local_name='TP970R', manufacturer_data={14848: b'\x00\xfb\n>\x00'}, service_uuids=['72fbb631-6f6b-d1ba-db55-2ee6fdd942bd'], rssi=-33)```
#

A bit more of a sample

#

I'm wondering if they are splitting the middle 3 bytes somehow

young forge
#

@mystic mural Is this a ThermoPro TP970?

mystic mural
#

It's called TempSpike Plus, but TP970 is the model listed on the device

#

Yes ThermoPro

young forge
#

What is the name of the mobile app that connects to it?

mystic mural
#

TempSpike

#

on android anyway

young forge
#

@mystic mural It's possible the temperature reading is not in the advertisement data. Maybe the app needs to make an active connection to the device and subscribe to a notification characteristic to get the data. I looked at the android app a bit and it seems that may be what's happening.

#

If you want to try decompiling the android app (version 2.20) yourself to look at the parsing code for the notification data, it seems to be located in class a1.b, and I think j is the method that is used for this device model

mystic mural
#

oh ok, I was afraid it might be something like that

#

Thanks for taking a look

#

I didn't see anything useful when I looked at the services and characteristics

#

But I've never done any bluetooth stuff before

frosty plinth
#
'0b11111011'
>>> bin(b'\x00\xfb\n>\x00'[2])
'0b1010'
#

Usually I put the device in the freezer for a bit and than put it some place warm and compare the bits

frosty plinth
young forge
bronze dagger
#

Hi all, I'm a newbie who is seeking to integrate a custom BLE device. I hope to find code for a similar device to learn on. I studied the code for RuuviTag but it seems that only works for data in advertisement, not for devices that needs a connection to get notifications from characteristic uuids

young forge
#

@bronze dagger What kind of device is it?

frosty plinth
bronze dagger
frosty plinth
bronze dagger
#

@frosty plinth I studied RuuviTag integration which I believe was done by you. But I believe that device has all its data in the advertisement right?

frosty plinth
#

It does, but I did not do that integration

#

You want SwitchBot or ledble for something that uses an active connection

wicked prawn
#

Maybe ld2410 for a sensor that needs an active connection

frosty plinth
#

I'd be careful with that one as I think there is an issue in the lib were it retries forever. otherwise its likely fine

bronze dagger
#

Thanks

bronze dagger
#

@frosty plinth I found a few other integrations that uses active connection, idasen_desk, yalexs, medcom_ble, and airthings_ble. Are you aware of any issues with them? Thanks

frosty plinth
#

I maintain yalexs_ble and I’m not aware of any issues. I can’t say about the others as I don’t have history with them

#

The Yale locks have lots of quirks though

#

SwitchBot is a much more strait-forward integration

lost goblet
#

Aha. home_assistant_bluetooth.models has been removed. That's it!

lost goblet
#

So... I'm connecting to a mesh of bluetooth devices. I.e. they are meshing between themselves, and I only need to connect to one to controll all of them.
For a traditional setup of a single bluetooth host, finding the best connection is easy. Just keep a list of all discovered devices, and when you need to send a command you connect to the one with the best RSSI.

With a bunch of proxies though... things get odd.
Does anyone have any ideas about a good way to guarantee a good connection to a system like this?

wicked prawn
#

Are there any heuristics other than rssi for best mesh nodes to connect to?

#

Do you need a persistent connection to the mesh?

#

My instinct would either be to make user choose which proxy to use, then pick the best signal to any mesh node. Or to have heuristics to pick the best mesh nodes (are there mains powered nodes? Is it like thread where there are routers and sleepy end devices?) and then pick the best proxy for the best entry node. Or id just roll with it and pick the best signal overall, but make it sticky to avoid flappy connections. But not too sticky in case of proxy or mesh node failure.

#

If you can easily filter out which devices are mesh nodes, then you should be able to maintain a list of mesh nodes and the best signal strength that ha sees for them just using the existing APIs (assuming they broadcast normal advertisements)

#

Then start at the top and try and connect to them until you get a connection (in case a single proxy has 2 many active connections etc).

#

So it doesn’t sound too awful to just totally lean into the existing Bt/proxy machinery?

#

It’d be more annoying if you had to subscribe to each mesh nodes MAC address manually

#

Could you also bypass the mesh in some cases and just talk to the device directly if there is a proxy in range? Proxies do render the mesh somewhat moot

lost goblet
#

It requires an active connection which stays open to get status updates.
For now I keep a list of the devices and their RSSI as they are discovered, and then try connecting to one at a time based on that order as you say.
The issue is that, say proxy A reports an high RSSI for a device on discovery, but when it's time to connect proxy A is bussy. Then proxy B will make the connection instead, but that may be far away and would make a better connection with a totally different device.
How could you let the user choose the proxy?

wicked prawn
#

If you used the Bt machinery you’d end up with a list that said device a and proxy 1 have the best connection, and device b and proxy 3 have the second best connection

#

It wouldn’t use device a and proxy 3 when device b and proxy 3 were a better choice

#

Ah, I see what you mean. That might be true at “discovery” time, but at connection time the bt manager might pick a “better” proxy.

#

But is that actually what happens? I thought the proxy to use was encoded in the BLEDevice?

#

Ah no I am wrong (_async_get_best_available_backend_and_device)

wicked prawn
#

So I thought you could directly query a scanner instance, make sure your BLEDevice had the right source and then that would be the proxy that was used. But ^ means you’d need to extend ha’s BleakClientWrapper to do that (call _async_get_backend_for_ble_device on your ble device, then only try to connect to that).

#

Without adding a connect wrapper to BleakClientWrapper that only tries the source on your BLEDevice, none of my ideas work. And I don’t see how you could avoid the edge case you said either.

wicked prawn
wicked prawn
#

So I’d probably try and add this wrapper and then not have the user choose anything ?

lilac topaz
#

I'm trying to incorporate a cheap, chinese BLE body scale. The scale works with the OKOK Android app. The scale does not work with the OpenScale app. The scale only sends Advertisement packets. These packets only contain a manufacturer_data section and do not include things like manufacturer_id, local_name, service_data, service_uuids, etc. Below is a DEBUG of a received advertisement packet:

2023-12-30 16:23:51.897 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (00:E0:43:80:E4:03) [connectable]: 50:FB:19:EE:E7:15 AdvertisementData(manufacturer_data={1472: b'\x00\x00\x00\x00\n\x01$P\xfb\x19\xee\xe7\x15', 19904: b'\x1f\x95\x17p\n\x01%P\xfb\x19\xee\xe7\x15'}, rssi=-80) match: set()

The weight is encoded in the first two bytes of the second "element". So \x1f\x95\ = 1F95 = 8085 decimal = 80.85 kilograms, and then they append the MAC address at the end of that same second element. I've tried using jdeath's renpho integration at https://github.com/jdeath/renpho but the manifest.json needs to see manufacturer_id, local_name, or some other common/standard field which is omitted in the packets broadcast by this scale. I'm no coder so I apologize for any incorrect terminology, but the two "section headers" shown of 1472 and 19904 are not constant and change with each weighing. SO, I'm in search of any help on how I can parse the weight from these Advertisement packets and put them into HA. Let me know if you need more DEBUGs or additional info. Many thanks in advance.

wicked prawn
#

Check if the scale has a pairing mode and try entering that if it does.

#

Likewise try resetting it if it’s paired to your phone.

frosty plinth
lilac topaz
#

Thanks @wicked prawn and @frosty plinth . Passive scanning is off. The scale does not have a pairing mode. I believe it truly only spits out Advertisement packets, nothing more. I looked into the BLE chip and it's a Chipsea CST92P23B. From their website: "CST92P23B is a low-power, low-cost, high-integration RF wireless transmitter chip with integrated transmitter, GFSK modem, RF baseband, etc. The chip adopts the SOP8 package, which can realize unidirectional broadcast signal transmission." So from that description it fits that it's a transmit-only device and can't be paired/connected. The OKOK app lists the MAC address of the scale so I'm thinking the first time you use the scale that the app sees the advertisement packet with a Chipsea MAC address, puts that MAC address in a whitelist and marks which "secret sauce" to use to parse the weight from the manufacturer_data.

So, is there a way for me to do the same thing - filter by MAC and parse the first two bytes of the second "section" of the manufacturer_data? TIA!

wicked prawn
#

But you could implement async_step_user and list all addresses and do that filtering yourself

lilac topaz
#

Thanks, @wicked prawn . After reading your reply I realized I was in over my head as I'm not much of a coder. Purely for posterity info should someone run into this same scale or a similar circumstance, allow me to share what I tried as a last-chance "for giggles" effort which happened to work!

I found https://github.com/custom-components/ble_monitor, installed it, added the device via MAC address, stepped on the scale and by some glorious magic the device appeared as Manufacturer = MaxxMee, Model = QJ-J, and Firmware = Xiaogui. And it populated three sensor entities (impedance, non-stablized weight, and weight) of which the weight entity was correct. So I'm set!

Thanks again for your time, suggestions, and the support you provide to the HA community.

slate sphinx
#

are there directions anywhere on how to test a ble integration within the devcontainer?

slate sphinx
slate sphinx
#

for reference, I'm working on a PR to add some features to the switchbot integration to detect opening vs. closing (right now the integration just hard codes any movement = opening which is confusing). @frosty plinth suggested the change should really be in pySwitchbot, not HA. So I started making the changes in the library which I think works (works when I do it in comand line and added a bunch of unit tests). However of course I want to test in HA. I could override the pip install on my actual HA device, but would be much easier to test and debug on the devcontainer

wicked prawn
slate sphinx
#

no, Windows

wicked prawn
#

If it’s something like Debian then in theory you just need to bind mount the dbus socket

slate sphinx
#

but it means it should be using WSL

wicked prawn
#

But it needs a dbus socket

#

Unless you can get it a dbus socket and that dbus bus has bluez running on it and that bluez can see your Bluetooth dongle, no, you can’t

slate sphinx
#

hmm ok

frosty plinth
slate sphinx
frosty plinth
#

Use an esphome Bluetooth proxy

slate sphinx
frosty plinth
#

You’ll have to temporarily repurpose one, as there’s just not enough processing power to reliably update two instances at once

timber garden
#

Let's say I am interested in buying a bluetooth enabled home appliance, how likely is it going to be programmed to be able to work with Home Assistant easily? It isn't listed in any integration at the moment. Not even the brand.

wicked prawn
#

Bluetooth LE doesn’t provide much in the way of standards for building IoT appliances, so every vendor makes their own protocol. They are all varying shades of naff.

#

It has something called GATT as a building block. To put it in terms of web development, it’s like it had a web (http) server but no APIs implemented

#

So we have to make an integration for every vendor

#

Homekit is an exception because Apple defined a bunch of standard IoT types on top of GATT. So we can support many devices with one integration.

#

There are other exceptions where one vendors stuff is reused by other vendors (so there’s actually a few non Xiaomi things that use the Xiaomi protocol) and similar for really cheap imported led lights

#

So the end result is you are going to have to reverse engineer whatever they built on top of GATT

#

Either by Bluetooth sniffing or decompiling the Android app

timber garden
#

Looks like their app interacts with a Bluetooth "gateway" that is a plug and it connects to the appliance

#

Over wifi

#

I would like to cut out that middle man if possible

#

Not sure if their app also do direct connection to the appliance

wicked prawn
#

Hard to know. If you can’t decompile the app for clues you’ll need to sniff the GATT traffic and hope it’s not encrypted

timber garden
#

How secure is unencrypted GATT? Can someone spoof the traffic and make my appliance to do some stuff?

#

Replay attack etc

#

Also, what is the feasibility of re-flashing the firmware to something open source instead?

wicked prawn
#

Like, not even pairing

#

Xiaomi has an encryption key for their sensors broadcast, but you can just issue another one over GATT

wicked prawn
#

Some Xiaomi sensors got a replacement firmware that is way better than the original

#

They even figured out how to turn it from a Bluetooth sensor to a zigbee sensor

#

Would say it’s the exception rather than the rule

#

If it’s powered by as esp32 your chances go up

shell stream
#

I'm looking to add several additional sensor types to bluemaestro. I'm starting by updating and issuing a PR against the python library. Once I have that, is the PR for HA just an update of the dependency version?

frosty plinth
#

Yes unless you need to add new mappings for additional sensor types. Than you’ll have to do one to bump the lib in Ha and one to add the new mapping

shell stream
#

Thanks for confirming

frosty plinth
frosty plinth
brittle fractal
#

I'm looking into improving my Pinecil BLE integration, is there an example integration which features HA autodiscovery via service UUIDs so the user doesn't need to manually find the MAC of the BLE device? I'm finding the BLE HA docs a little all over the place 😦

frosty plinth
#

There’s a lot of examples you can git grep the manifest files for service_uuid in the core repo to find them

#

govee_ble and yalexs-ble likely have some good examples

shell stream
#

What's the right way to point a checkout of ha-core to use a local in-devleopment copy of a BLE library?

#

can I just update the dependency somewhere?

frosty plinth
#

You can run pip install --upgrade . from the checked out library when the venv is activated and than restart

#

Make sure the version matches so ha doesn’t downgrade the library

#

Or temporarily remove it from the manifest.json

bronze dagger
#

Anyone here familiar with the Idasen desk integration? I wrote a custom integration based on it, but I have some questions. Thanks

crystal raptor
#

@half stag

bronze dagger
#

@half stag I need to connect to multiple BLE scales (different MAC address, same product) that sends weight data via a characteristic uuid, much like the height for the Idasen desk. I implemented my custom HA integration for the HA yellow by mimicking the Idasen desk. I got it to kinda work but it's having issues connecting and reconnecting to the scales. The scales shut off after a period of inactivity and turn back on when there is activity. Previously I implemented this on my PC using the bleak package in Python and it was able to handle multiple devices and arbitrary connects and disconnects almost instantaneously. But the HA version cannot reliably reconnect. I sometimes get a lot of timeout errors when doing multiple connection attempts. But I'm not able to pinpoint the issue as it's not repeatable, ie, sometimes it can reconnect quickly after the 1st try. Another type of error I saw in the logs is "no backend with an available slot..."

#

@half stag I hope you or someone more well versed in HA and Bleak can advise. Granted there is a hardware difference (Windows PC vs HA Yellow). I wonder if that can explain some of the issues

#

Another thing I can think of is that in my PC implementation I use a set to keep track of connected MAC addresses and when a device disconnect it is removed from the set and the next time it turns on, a new Bleak client object is created. I'm not sure if this is the case for the HA implementation

#

Thanks

wicked prawn
#

The error you saw about connection slots typically indicates either a range issue or a Bluetooth hardware issue

#

The 3rd cause is that some dongles can only handle 2 connections at once , so if you have lots of devices with semi permanent connections you’ll have trouble

#

If neither of those are working (eg if you get None instead of a BLEDevice but the device is active) it strongly points to a hardware or range issue

half stag
charred lantern
#

Removed

keen fiber
charred lantern
bronze dagger
bronze dagger
wicked prawn
#

10m might be a long distance for some devices, and eg for built in pi Bluetooth we’ve seen the effective range be 2m. Heck we’ve seen it be 30cm for some combinations.

#

And for Realtek usb based Bluetooth, even if you have an antenna and it’s near, the chip crashes that often that it spends more time offline than online. (HA has a watchdog to try and reset such chips, but they can crash again after a few minutes).

bronze dagger
bronze dagger
# half stag Have you tried using esphome Bluetooth proxies? I found that it works much, much...

I haven't yet. One thing I noticed is that if I start HA and both scales are off, in the init.py it'll still create a Bleakclient object and attempt to connect. Is there a way to make it so that it only attempts to connect to discoverable (on) devices? I tried to do await bleakscanner.find_device_by_address() to get a list of discoverable devices and it won't run, and didn't throw any exceptions. When I tried bleakscanner.discover(), it was "discovering" devices that are off for some reason. The reason I tried this is because I want to see if having a new Bleakclient each time would help with the connection reliability. Thanks

half stag
#

well, from experience I would say the esphome bt proxy has more chances of helping 😄

#

I had really weird issues when using the internal BT

wicked prawn
#

Depends on the chipset a lot, which is why I asked

#

Realtek chipset crashes every couple of minutes

#

Intel pretty spotty

#

Internal Pi also seems to be pretty bad for some

wicked prawn
#

See the stuff I linked to up there

#

And then grep for integrations using them

#

There’s a couple that use those callbacks to only connect when a device is seen

bronze dagger
# wicked prawn See the stuff I linked to up there

Thanks. I'll give it a try tomorrow. Seems like I just need to add the async_register_callback() to the asyn_setup_entry() in init.py and match by address. And then wrap the rest of the setup (creating the coordinator, etc) in a callback function. The asyn_connect() of the coordinator already uses async_ble_device_from_address.

teal prairie
#

I am using a Raspberry Pi 4 with Home Assistant 12.0.
I want to use the onboard bluetooth to controll some BT devices. I see that a Bluetooth integration came with the installation of HAOS. But when I try to add a entry I just get a message as of "No unconfigured Bluetooth adapters found. There are 0 ignored adapters.".

What could be wrong?

wicked prawn
teal prairie
bronze dagger
#

Can this error message be related to my Bluetooth integration?
ERROR (MainThread) [bellows.uart] Lost serial connection: ConnectionResetError('Remote server closed connection')

#

It seems bellows is for Zigwee but I get that message in my logs, and always after a 2nd device attempt to connect

bronze dagger
half stag
bronze dagger
wicked prawn
#

Pretty sure that doesn’t work

#

Full virtualisation might, but it’s a common reason I end up doing support in #bluetooth-archived - usb passthrough is a joke

bronze dagger
bronze dagger
# wicked prawn Pretty sure that doesn’t work

I think the issue is due to the raspberry pi built in Bluetooth. In the HA terminal I used bluetoothctl and it showed a MAC address corresponding to Pi. I tried connects and disconnects and found out when one is connected, the other will take a long time to connect. But if I connect to one individually it's fast. So it looks to be a hardware issue huh?

bronze dagger
half stag
bronze dagger
half stag
#

but you can try another adapter. maybe you get lucky

wicked prawn
#

Raspberry pi internal Bluetooth is bad for what you are doing

#

It is highly susceptible to interference

#

We see lots of cases where the chip itself hangs and can only be recovered by removing the power from the pi completely

#

Lots of cheap Bluetooth dongles use Realtek chips that are also rubbish.

#

In the worst case they crash every few minutes. At least some of them (but not all!) can be recovered by HA by simulating USB replugs.

#

As for simultaneous connections - it does vary by adaptor (2 or 3). It’s mostly quite a low number. But there are some that can manage 5 iirc.

#

If you read the documentation for the Bluetooth integration it will tell you which ones are best in this regard.

#

Of course the ones that support more devices are slower to connect.

#

ESPHome proxies work well, but there are still things you need to keep in mind.

#

Eg wired is better than wireless - esp chips have one raid that switches between Bluetooth and WiFi as quickly as possible. But that means it’s not doing Bluetooth whenever it’s doing WiFi. You will miss packets because of this.

#

And you need to be mindful of the antennae.

#

Olimex wired poe boards with external antenna are popular. The GL-s10 is popular.

#

Hope that helps @bronze dagger

winged sorrel
#

Why is OTA not working when ESPHome updates Proxy server I get this error "ERROR Connecting to 192.168.1.104:3232 failed: [Errno 113] No route to host"

bronze dagger
# wicked prawn And you need to be mindful of the antennae.

We decided to try an USB Bluetooth adapter first as it's an easier option now than ESPHome BT proxy. We ordered a "high performance" one and I can already see it's better than the built-in one thru using bluetoothctl. How do I choose which adapter my integration should use? Is it as simple as disabling the built-in one in Bluetooth integration? Or do I need to modify the configuration.yaml by specifying the MAC address of the adapter under "Bluetooth"? Thx

wicked prawn
#

You should have a Bluetooth integration for each dongle

#

Delete the one you aren’t using

#

When it is “discovered” again you can ignore it in the ui

bronze dagger
crystal raptor
#

FAFO

#

Fuck around and find out 🙂

bronze dagger
#

Already doing it.

wicked prawn
bronze dagger
# wicked prawn All mine are set to active fwiw

So far the issues I have are all connection related. What about devices that don't require an action? Such as the RuuviTag that has data in its advertisement. Would the built-in Bluetooth fare better?

ancient pendant
#

hi everyone, I've been trying to understand the switchbot integration as an example, but i am having trouble figuring out where its doing things like choosing the service or characteristic uuids, might just be an issue with me not being familliar with home assistant integrations or python.
my goal is to create an integration for the power watchdog that doesn't require an esp32 as a bluetooth relay, i have a c# test script that gets the data just fine, but i can't seem to understand how to use what i learned from it to make a python based integration. if anybody knows of an integration simpler than switchbot please let me know.
here is a pastebin of my c# program (its a single-source-file .net8 program, probably would work in .net7 as well) https://pastebin.com/pdkjwpi4

wicked prawn
#

Reading and writing to characteristics in HA is done with bleak. Our version is a little more complicated because we support multiple adapters at once and roaming between them. But looking at bleak and porting your c# to work with bleak outside of HA would probably be useful.

elfin prawn
bronze dagger
elfin prawn
#

The bthome integration does exactly that, I'd also search for passivebluetoothdata in the components to find more that are likely (going by memory, I'm out currently)

elfin prawn
#

Not sure if this belongs in devs_core but being bluetooth related... I am trying to get my tests working in a custom component. I've made some progress and I think I am starting to grasp a few pylint basics. I'm running into a problem where now it errors trying to load the bluetooth dependency (my component depends on bluetooth_adaptors, which in turn depends on bluetooth). In my pytest run I get:

INFO     homeassistant.setup:setup.py:366 Setting up usb
INFO     homeassistant.setup:setup.py:366 Setting up bluetooth
ERROR    bluetooth_adapters.systems.linux_hci:linux_hci.py:102 Unexpected error while getting HCI devices: A test tried to use socket.socket.
Traceback (most recent call last):
  File "/home/vscode/.local/lib/python3.12/site-packages/bluetooth_adapters/systems/linux_hci.py", line 83, in get_adapters_from_hci
    sock = socket.socket(AF_BLUETOOTH, socket.SOCK_RAW, BTPROTO_HCI)

Is there something simple/obvious I'm missing that I need to set up in my testing or will I need to put my full logs and config up somewhere so someone can dig at it properly? I'm using the pytest_homeassistant_custom_component plugin.

frosty plinth
#

Most Bluetooth integrations have a fixture enabled in there conftest.py that should prevent that. Mobile right now so I can’t check what it is but should be easy enough to find as all of them should have it

bronze dagger
#

I wrote a custom integration for a BLE scale that contains weight data in the advertisements, by emulating the RuuviTag BLE integration. I basically put the files in the custom integration folder. Good news is that I was able to get it to work. Bad news is that I get strange errors in the log shown below that I have no clue about. I don't even think my code uses those modules, but somehow it's expecting to import those .py files.

jaunty rainBOT
#

@bronze dagger I converted your message into a file since it's above 15 lines :+1:

bronze dagger
#

But the integration seems to run (I get data in the homepage) with no problem

#

Yes the advertisement works a lot smoother than active connection

frosty plinth
#

_async_process_single_integration_platform_component no longer exists in 2024.4.x. Are you running an old version?

bronze dagger
#

Thanks

elfin prawn
wild inlet
#

I've just bought some Graywind BLE roller blinds... I'm trying to reverse engineer the protocol so I can control it from HA. I used HCI snoop log and can see some packets that seem to correspond to up/down/stop but when I try sending them from bluetoothctl it doesn't work. It also isn't showing the service UUID, but just a handle (0x0015) and so I have to guess which service UUID to send the packets to. I also notice that when I run 'connect XXX' in bluetoothctl the pairing LED on the blind keeps blinking whereas when I pair the app on the phone it stops blinking. Any ideas?

near flare
#

The television and light are discovered with this advertisement data:

2023-12-04 20:15:50.851 DEBUG (MainThread) [custom_components.casambi_bt.config_flow] Discovery: [C8:12:0B:09:81:7D] Television from e8:9f:6d:08:ad:74.Advertisement: AdvertisementData(local_name='Television', manufacturer_data={117: b'\x02\x18\x14\xa1AZ\x88b\xe0\xf9F\x19\xeb\xe9\x00ng\x83', 963: b'm*\xb2c\xd8\xb0\n', 224: b'\x00\x93\xcaX\x93\x08'}, service_data={'0000fe9f-0000-1000-8000-00805f9b34fb': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}, service_uuids=['0000fe4d-0000-1000-8000-00805f9b34fb', '0000fe9f-0000-1000-8000-00805f9b34fb', '00000601-0000-1000-8000-00805f9b34fb'], tx_power=-127, rssi=-70).
2023-12-04 20:15:50.852 DEBUG (MainThread) [custom_components.casambi_bt.config_flow] Discovery: [6D:2A:B2:63:D8:B0] CBU-PWM4 RGBW from e8:9f:6d:08:ad:74.Advertisement: AdvertisementData(local_name='CBU-PWM4 RGBW', manufacturer_data={963: b'm*\xb2c\xd8\xb0\n'}, service_uuids=['0000fe4d-0000-1000-8000-00805f9b34fb'], tx_power=-127, rssi=-80).
2024-04-07 13:30:20.026 DEBUG (MainThread) [custom_components.casambi_bt.config_flow] Discovery: [C8:12:0B:09:81:7D] Television from E8:9F:6D:08:AD:74. Advertisement: AdvertisementData(local_name='Television', manufacturer_data={117: b'\x02\x184\xa1^\x91Z(\xfbd\x96\x1d\x94\xc3L\xce\xfa`', 963: b'_\xef5B\xb0I\x0f\xbb\x00)\x00\x00m*\xb2c\xd8\xb0\x02\n\x00\x00\xf2', 224: b'\x00h\xcaX\x93\x08'}, service_data={'0000fe9f-0000-1000-8000-00805f9b34fb': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}, service_uuids=['0000fe4d-0000-1000-8000-00805f9b34fb', '0000fe9f-0000-1000-8000-00805f9b34fb'], tx_power=-127, rssi=-71).
stone acorn
stone acorn
#

Also Hi guys, I made some modification to Ryan integration, but I have issues with the authentication with nespresso machine. If any of you have any ideas on why I cannot get it to connect it would be great :
https://github.com/nxor/ha_nespresso_integration/tree/feature/supportForDV6

2024-04-06 10:47:38.074 ERROR (MainThread) [custom_components.nespresso.nespresso] Onboarding not permitted. Already paired?
2024-04-06 10:47:41.076 ERROR (MainThread) [custom_components.nespresso.nespresso] Couldn't read onboarding status of device. Probably BT Dongle incompatible?

The device is : Vertuo_DV6_80646F4D3454 (not real mac)

stone acorn
#

do you know how to get the auth_key ? I can get it to pair with my phone, but not with HA...

frosty plinth
shell wolf
near flare
hallow marten
#

Hi, I'm working on a bluetooth mower integration (I actually wrote the mower platform) and am running into a small issue where I'm getting object has no attribute 'last_update_success' on async add entities. This is on a coordinator which has an activeBluetoothDataCoordinator which of course inherits from passive which has this attribute which is why I'm so confused.

hallow marten
#

got around it for now by setting last_update_success but I don't see it used anywhere else, though the only other active bluetooth integration is switchbot from what I can see, which isn't helpful. Is there a better way to set the poll interval other than the poll_debouncer?

frosty plinth
#

Only the processor coordinators and DataUpdateCoordinator have that method.

hallow marten
#

No it does not, it requires an active connection

#

I send protobuf messages to the device and it responds

#

Ooooh I should just be using DataUpdateCoordinator

#

@elder idol

#

Advertisements have nothing in the for this device. I need to periodically connect and get data

hallow marten
#

Thanks @frosty plinth totally had misunderstood that documentation when I originally read it

hallow marten
#

With bluetooth proxies they don't connect directly to devices as in GATT notifications can they?

wicked prawn
#

ESPHome proxies support GATT.

#

Generally BLE connections are short lived (homekit devices forcefully close if they are idle for 30s for example) and there are a limited number of active devices that can be sustained at once. Even for the best usb dongle that’s 7. But for esp32s it’s like 2 or 3 from what I remember.

#

So there’s an argument that it’s better to poll some devices that waste one of those precious slots.

#

But i would expect notifications to work on esphome provides if they were needed

hallow marten
#

Right, with the integration I'm writing, I poll a device about once a minute, only needs to be connected for about 30s then can disconnect, just not seeing any activity on the esp32, I probably haven't flashed it correctly. Fwiw it's a lawn mower. Considering I got confused with the active ble description for coordinators (using data update coordinator now) figured it didn't hurt to ask.

hallow marten
#

Yeah at least for the ble tracker needed to flash locally

hallow marten
#

ok so it connects but its not proxying the commands from HA to said device. Is this due to the interface number with bleak?

hallow marten
#

the proxy connects but it drops the connection straight away. Its actually preventing HA from communicating with the device.

hallow marten
#

resolved issue

willow nebula
#

I've been reviewing/testing the Husqvarna automower Bluetooth integration using ESPHome bluetooth proxy. I've noticed that when I have 1 proxy everything "works", but if I add a second proxy to HA, it no longer connects to the mower. Removing the second proxy, everything starts working again.
I suspect the author is missing some method. Any pointers would be very helpful!
https://github.com/home-assistant/core/pull/108326

dire blade
#

I posted this in the non-devs channel: how was a dev supposed to know that PassiveBluetoothDataProcessor changed the number of arguments it needed? PassiveBluetoothDataProcessor[Optional[Union[float, int]]] needs to change to PassiveBluetoothDataProcessor[str | int | None, SensorUpdate] . Only found it by seing this change made in the oral-b integration (which I based my integration on) years ago. Did not see a notice about it in the "Backward-incompatible changes" section of change log. Thanks..

frosty plinth
#

Is there a specific commit you are referencing? That looks like a typing only change and not a run-time change.

dire blade
# frosty plinth Is there a specific commit you are referencing? That looks like a typing only ch...

Moving from 2024.5 to 2024.6 caused my custom integration written with 1 argument to not load/fail. It threw an error at that line about number of arguments. I made the change and it loaded fine. I think commit #117157 shows someone made that number of arguments change to a bunch of core components. Just took an hour or so for me to figure out why something broke after being stable for over a year. Error if run it the old way: Unexpected exception importing platform custom_components.renpho_ble.sensor File "/config/custom_components/renpho_ble/sensor.py", line 129, in <module> PassiveBluetoothDataProcessor[Optional[Union[float, int]]] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/typing.py", line 384, in inner return func(*args, **kwds) ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/typing.py", line 1066, in _generic_class_getitem _check_generic(cls, params, len(cls.__parameters__)) File "/usr/local/lib/python3.12/site-packages/typing_extensions.py", line 2947, in _check_generic raise TypeError(f"Too {'many' if alen > elen else 'few'} arguments" TypeError: Too few arguments for <class 'homeassistant.components.bluetooth.passive_update_processor.PassiveBluetoothDataProcessor'>; actual 1, expected at least 2

frosty plinth
#

Please open an issue. I don’t think the op intended that to be a breaking change

dire blade
#

done. #119150

amber igloo
#

Hi o/ I'm currently working on an integration for a bluetooth device and ran into some weird behaviour. When the device is connected through the bluetooth adapter of my pc or the on-board bluetooth of the raspberry pi all works fine, but when the device is connected through an esp32-based bluetooth proxy for some of the characteristics i get the errorbleak.exc.BleakCharacteristicNotFoundError: Characteristic f6d7ffff-5a10-4eba-aa55-33e27f9bc533 was not found!

#

are there some known limitations with the amount of characteristics? or should i report a bug?

idle basin
solar violet
#

Hi everybody. I developed a custom component that works with fitness equipment that implements Bluetooth Fitness Machine Service. I have an elliptical trainer, which strangely presents itself as an exercise bike. 😄 I would like to announce and invite users who have fitness equipment at home. Where is the best place to write about this? Thank you.

wide hare
#

How can I make ESPHome to announce BTHome event of a "button pressed" ?

wicked prawn
#

ESPhome is normally used with WiFi, but you’d be better asking this in the ESPhome discord

slim rock
#

Hi All, I have a BLE device I'd like to support that requires pairing/bonding before you can write/notify the relevant gatt characteristics. Is it possible to perform this paring in the config flow of a home assistant integration? I cant seem to find any existing components in core that do this. Even the bleak doco is pretty patchy on this as pairing seems to be delegated to an OS function.

frosty plinth
#

Eq3smart

slim rock
#

Thanks for the tip, I'll look at that. I found this statement on the integration page confusing "Pairing is only required with firmware versions above 120 and when not using ESPHome Bluetooth proxies." Surely pairing is required by the device, so is this actually meaning to say that the device is not supported by ESPHome bluetooth proxies? (i.e. requires a local adapter)?

frosty plinth
#

I think the ESP home implementation will automatically pair