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

[Enhancement] Support multiple measurements of the same type in BTHome DIY format #854

Open
scrambledleek opened this issue May 2, 2022 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@scrambledleek
Copy link

Hi Ernst,

Good work on adding the HA BLE DIY format! It's been a while since I last updated my Home Assistant as it was working fine for me, so I'd been using my own DIY format, but have now moved over to the official format.

A feature I was using that you don't currently have is support for more than one reading of the same type, e.g. my device is an ESP32 advertising 3x 32-bit 'count' values for my gas and electricity meters (but not my water meter as it doesn't have an LED/magnet :-( ).

I have had a go at adding this feature in my branch of the ble_monitor repository here:
https://github.com/scrambledleek/ha_hacs_ble_monitor
The homebrew-devel branch is my latest, and I have branches for various ble_monitor versions.

I just append '_' to the HA BLE result data (except for the 'packet' type). Then there are some changes in sensor.py to recognise sensor data measurements with an appended index (using a regular expression) and adjust the key/name/unique_id of the description so that a separate Home Assistant entity is created.

I've only tested it for my case, so there may be some issues, but feel free to incorporate it if it seems good to you.

Thanks for all your efforts!

@Ernst79
Copy link
Collaborator

Ernst79 commented May 2, 2022

Hi

Thanks for your suggestion. I will look into it later, as I just moved to a new house and am a little behind with the other issues.

@Ernst79 Ernst79 self-assigned this May 2, 2022
@Ernst79 Ernst79 added the enhancement New feature or request label May 2, 2022
@scrambledleek
Copy link
Author

No problem - if you leave it long enough I may come up with something better than using strings and a regexp - I'm thinking that storing the measurements of the same type as a list initially would be more efficient when it comes to converting them to entities in sensor.py (regular expressions are nice and powerful, but not very CPU efficient).

@slacky1965
Copy link

Hello. When will the ability to use multiple measurements of the same type be added to the official BLE Monitor repository?

@Ernst79
Copy link
Collaborator

Ernst79 commented Aug 25, 2022

I hope soon, I'm currently working on moving HA BLE to a home assistant integration, where it will be called BThome, as the HA devs have plans to use and expand it. This first version will be a limited version, e.g. a counter isn't working yet. I hope to have the first version released in september release. Next step will be to add the missing sensor types, binary sensors and support for multiple sensors of the same type. It is on my todo list, hopefully I will manage to get it in October release of HA. At the same time, I will change it in BLE monitor as well, but development will move to the official integrations over time.

@slacky1965
Copy link

Big thanks!!!

@slacky1965
Copy link

Hello. How are things going with the addition of sensors of the same type?

@Ernst79
Copy link
Collaborator

Ernst79 commented Nov 20, 2022

It has been added to BTHome V2, and will be supported in HA 2022.12 via the official BTHome integration. BTHome V2 was released two weeks ago,

I’m working on the BLE monitor update to support BTHome V2 at the moment (see #1055), I have it working for the new V2 format, but as you can see in the PR the multiple measurement of the same type is on the ToDo list. I’m afraid it isn’t easy to implement, in BLE monitor, due to the design of BLE monitor. It will need a major rewrite of how entities are being defined, Im afraid.

if I fail, my advise would be to use the official BTHome integration in 2022.12. This one is also developed by me, and is able to receive multiple measurements of the same type. You can try with the current dev version of HA already.

@Ernst79 Ernst79 changed the title [Enhancement] Support multiple measurements of the same type in HA BLE DIY format [Enhancement] Support multiple measurements of the same type in BTHome DIY format Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants