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

BTHome advertised name not honored #79468

Closed
agners opened this issue Oct 2, 2022 · 11 comments
Closed

BTHome advertised name not honored #79468

agners opened this issue Oct 2, 2022 · 11 comments

Comments

@agners
Copy link
Member

agners commented Oct 2, 2022

The problem

After Core 2022.10 update newly added b-parasite sensors don't get the advertised name anymore. Interestingly, two devices behave different. The first device appears with b-parasite as name

image

The advertisment of that sensor is prst, and that shows up in the logs as well

2022-10-02 13:03:52.535 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] living-room-sensor: F6:73:32:3E:2D:48 AdvertisementData(local_name='prst', service_data={'0000181c-0000-1000-8000-00805f9b34fb': b'\x03\x14\x87\x0f#\x02\xea\t\x03\x03(\x14\x03\x0c\x9e\x0c'}) connectable: False match: {'bthome'} rs
si: -69

The second appears with its MAC address

image

2022-10-02 13:07:41.605 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] living-room-sensor: E2:2C:54:BE:F9:3B AdvertisementData(service_data={'0000181c-0000-1000-8000-00805f9b34fb': b'\x03\x14\xa1\x02#\x02D\t\x03\x03H\x15\x03\x0c\x9b\x0c'}) connectable: False match: {'bthome'} rssi: -80

What version of Home Assistant Core has the issue?

core-2022.10.0b3

What was the last working version of Home Assistant Core?

core-2022.9.3

What type of installation are you running?

Home Assistant Core

Integration causing the issue

bthome

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@agners
Copy link
Member Author

agners commented Oct 2, 2022

I've tested the devices close-by to the ESPHome based Bluetooth proxy. I am using a Wi-Fi based proxy, but I can reproduce the same problem with the Olimex PoE based proxy.

After some digging, it seems that the first issue is due custom handling of the prst advertisement name in the BTHome library (Bluetooth-Devices/bthome-ble@bcd07da).

For the second one I customized the advertisement name to be b-prst. I can see the advertisment in the nRF Connect app, but for some reason it seems not to be picked up (missing local_name)?

@homeassistant
Copy link
Contributor

Hey there @Ernst79, mind taking a look at this issue as it has been labeled with an integration (bthome) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)


bthome documentation
bthome source
(message by IssueLinks)

@homeassistant
Copy link
Contributor

Hey there @bdraco, mind taking a look at this issue as it has been labeled with an integration (bluetooth) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)


bluetooth documentation
bluetooth source
(message by IssueLinks)

@Ernst79
Copy link
Contributor

Ernst79 commented Oct 2, 2022

prst in the name is indeed used for bparisite in the pypi package. So the first sensor is OK. The second is strange, it should use the local name as device name. Possibly it isnt forwarded by the ESP device?

@bdraco
Copy link
Member

bdraco commented Oct 2, 2022

The esphome devices don't forward the short local name yet. That's coming in this months update

@agners
Copy link
Member Author

agners commented Oct 2, 2022

It does work for the first device though...

AdvertisementData(local_name='prst', service_data=

vs.

AdvertisementData(service_data...

@agners
Copy link
Member Author

agners commented Oct 2, 2022

Oh I see, according to the nRF Connect App the first device is announcing the "Complete Local Name", whereas the second is only annoucing "Shortened Local Name". What is weird is that the second device is actually a longer name... I wonder why b-parasite decides to announce different local names here.

@agners
Copy link
Member Author

agners commented Oct 2, 2022

prst in the name is indeed used for bparisite in the pypi package. So the first sensor is OK.

Is there a particular reason that is being done? It feels more confusing to me 😅

@Ernst79
Copy link
Contributor

Ernst79 commented Oct 2, 2022

Saving bytes is the reason he is doing this. He wants to have all info in one message, which is limited in length to 31 bytes. So he keeps the name as short as possible, while we can still say it is a b-parasite.

I’m thinking about adding a 2 byte identifier in BTHome, such that we can even skip the name for predefined sensors.

@agners
Copy link
Member Author

agners commented Oct 2, 2022

Sorry, I did not meant why he is using prst only (altough good to know the background of that, thanks!).

I was more wondering why we can't take the name of the advertisement directly. I was planning on flashing them with different names, but the current code makes prst1, prst2 appear with the same b-parasite device name... I do have different MACs, but its not as user friendly 😄

@agners
Copy link
Member Author

agners commented Oct 2, 2022

Ok, this is wired, I reflashed my second b-parasite again, and it appears to advertise a Complete Local Name now 🧐 . And with that, the device also properly appears with local name (although, I had to restart my Core instance, it seems the name does not get updated, but a limitation I can live with.

2022-10-02 23:37:55.682 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] olimex-bluetooth-proxy-d23f9c: E2:2C:54:BE:F9:3B AdvertisementData(local_name='b-prst', service_data={'0000181c-0000-1000-8000-00805f9b34fb': b'\x03\x14;\x02#\x02l\n\x03\x03\xa8\x0f\x03\x0c\xe8\x0c'}) connectable: False match: set() rssi: -48

In any case, there is no problem on HA Core side here, so I am closing this issue.

@agners agners closed this as completed Oct 2, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Nov 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants