Hi there,
I have for a while been trying to make Home Assistant installed as Generic x86-64 communicate with my adjustable bed controller from Linak using a bluetooth adapter internally mounted in the computer.
To summarize this is where I am at now:
I have sniffed out the communications from the original android app “Bed Control” by Linak to the bed, and have figured it sends write requests to a attribute with UUID 99FA0002-338A-1024-8A49-009C0215F78A.
The values it sends are for example “9400” to toggle a light, “0a00” to lower the back, “0b00” to raise it and so on.
For anyone wondering: This was a great tutorial to sniff out the bluetooth traffic, combined with using the app “BLE scanner” to get the correct attribute.
I have managed to find the device and select the correct attribute in the Terminal app with the “bluetoothctl” command, but sending for example “write 9400” does not work.
Other BLE devices in my home show up in the integrations tab but a common denominator is that all of them have existing integrations already made for them
At this point I see two options:
Write my own integration, however I am struggling to find the correct documentation needed to do this
Figure out the correct format for the “write” command under the GATT menu in Terminal. I have unfortunately not been able to find any applicable or sufficiently detailed documentations to do this either.
In short I know what data to send and where to send it, but not how to send it.
Are there any of you out there that could help me or point me in the right direction?
I consider the best option here to be writing a integration that could be used as a template for “any” BLE device, although that does seem a bit unlikely to be doable.
I will of course update the thread if I happen to figure it out.
Thank you!
Nice tutorial and write up! I also am struggling to make a BLE integration (for a scale). I have asked on discord for some help as there is not a simple tutorial anywhere. Just gold-plated integrations which are hard to understand.
Sounds like you figured out enough to do a ESPHome integration. From the docs, it seems you can write a value to a specific characteristic. https://esphome.io/components/ble_client.html
I forgot to mention I am doing this with a internal bluetooth card on a minicomputer from I believe Dell or HP and do not own a ESP32, although it does seem more and more likely that I will have to buy myself one.
As far as I have understood ESPHome is only for use with ESP32, or is it possible to use with a internally mounted bluetooth card on a x86-64 system?
I am unfortunately unable to use gatttool, as my installation is the generic x86-x64 one.
Or am I mistaken? Is it possible to install? Sudo commands do not work in the terminal at least.
Do you have a normal computer with bluetooth, not home assistant? Windows or linux? That is the easiest way to figure out to send BLE commands. You want to use the bleak library, as that is what HA uses for bluetooth control. You can look at my RD200 integration for some clues: https://github.com/jdeath/rd200v2 . I also have a simple python script there which shows how to interact with the device with the library. Making a python script is relatively easy, the hard part is getting into a HA integration.
Hi @Duus This is great - I want to do exactly the same. It would be cool to have an esp32 controlling the bed I have also sniffed “some” of the values that you point out. I can get them to work sending the commands with this IOS app nRF Connect for Mobile i App Store
Since I started working on this, I were so lucky to get my hands on the official Wifi2lin module for connecting the bed to the Linak cloud service. I have it working now with Google assistant through the new Google SDK in Home Assistant (Formerly known as the Google Relay). It works most of the time, but us who mess around with HA wants to go local - so it would be cool to have an ESP32 as hub. I have been trying to make a BLE node as @jaaem points out, but I cannot get the EPS32 to connect to the bed It would be awesome if someone could crack the nut - what about you @J-Lindvig
Anyone got further with building a ble app for the HA?
I have my Linak bed 100% controled now, with height of head/legs and control… Even use a HACS thermostat to control legs/head from 0-100%. And i can use it with google… BUT it runs on my esp32, which is not good in switching between wifi and ble because it uses the same frequency…
Is there a HACS integration that makes me able to control my Linak moters? I’m getting my new bed in 2 weeks, and would like if i cound use it in my HA setup.
I managed to do the following with a Linak engined elevation bed. It works, but it is quite annoying, that I have to press press press the buttons to get the desired positions:) Anyone have a better approach?