Controlling BLE ceiling light with HA

Hi!

First off, glad that light control is working for you. As for fan control, it shouldn’t be too difficult - but I currently don’t have free time to do it, and furthermore - I don’t have a fan to test the changes on. If you’re comfortable with coding, I can point you in the direction of what’s needed to control fans.

Cheers!

OK.

So, here is the native code inside the Android app that’s responsible for generating the BLE packets (it’s taken as-is from Ghidra, so mind you - it shouldn’t compile, and might be imperfect otherwise): Java.com.alllink.encodelib.Tool.c · GitHub

And this is the Java code from the app that calls the native code - this can give you some insight into what the different values should be (again - taken straight from jadx-gui decompiler, so not necessarily a valid piece of code): FanLampPro.java · GitHub

You can look at the code in my repo and see how it’s implementing the commands blevbBinding and blevbDimming - you’d need to add similar code to implement fan-related commands (and generate a fan entity in home assistant, in addition to the existing light entity).

Good luck!

Thanks.
I will try understand

Greetings Lev,
and compliments for your nice work.
Unfortunately Lampsmart Pro isn’t the most widespread app for ceiling lamps and fans.
Chinese shops like Temu sell ceiling lamps with fans too that use apps like fanlampro.apk and primarily zhishan.apk. Could you consider reverse-engineering these apps too? Obviously I would be able and willing to provide you with everything you need.

Hi! I have same issues( so I cant pairing my lamp(

[19:32:37][D][lampsmartpro:146]: LampSmartProLight::on_pair called!
[19:32:38][W][component:204]: Component api took a long time for an operation (1.00 s).
[19:32:38][W][component:205]: Components should block for at most 20-30ms.

with esp32 ch9102x

is there any news how to resolve this?

Any luck on this, @jymbob? I’ve tried a few changes similar to your fork but the esp32 still would not pair.

Hello,

I read through this posts. Excellent work on the lampsmartpro!

Unfortunately i dont understand half of it.

Would somebody care to write down a short cookbook on how to get into this for beginners?

I have 12 outdoor lights on my house which are controlled by lampsmartpro but id like to have them in HA.

Thank you!
Regards

You could refer to the guide that @jymbob has written above in post #62.

1 Like

My HA died and I had to reformat and set up everything again which means, I lost all my HA backups too. Interestingly the paired lamps on the ESP32 device is safe and still paired, by I no longer have access to the ESP32 device from HA. Is there any way I can restore the connection, pulling data from the device?

found this ESP8266 solution

Hello,

Raymond thank you for pointing out the guide!

So i finally got started with it and i got to point 9 where i am stuck at the moment.

I see the ESP home in devices and services. Also i see that it has 1 device. When i open the device i see that it has no entities.

In the point 9 i am supposed to click on edit to open config.yaml. The problem is that i see no edit button and i cant find the config.yaml. Where exactly should i look? Do you maybe mean the file configuration.yaml which sits in the config directory?

Thank you!
Best Regards

Hello!

Ah i figured it out. I did not have the ESP Dashboard installed through add-ons. So now back on track!

Thank you
Regards

I get the same log when I try to pair my lights
I’ve tried 2 different ESP32 but I can’t get my lights to pair

Anyone found a solution ?

Ok, sadly I am also unable to pair my lights…

Hi,
would it be possible to have it as an integration in HA to use directly the bluetooth device of the HA hardware (where HA is installed)?

Hi,
I’m also unable to pair my light. Want to make sure we are talking about the same kind of devices here.

The light i have is a Neona ourea. Bought it without knowing it is smart. Actually I looked for specs to replace the LED driver by one with Zigbee. While search for the numbers on the driver I found out the there is an app. The one if the green icon shown the image in post 2. When searching for the name only there are different ones. Is that the app you are using as well?

@aronsky I guess you wrote the C++ code in the repo, right?
I never wrote any low level networking code and definitely no bluetooth, but it guess it’s not that easy to reverse engineer the protocol from wireshark logs because of the withening here. I do see something similar to what @jymbob described. But I don’t have an angle to verify that all these constants are the same for my light. Looking at the package structure it looks a bit suspicious that your command codes are one byte only while here it says 16bit. Is that an issue of the decompilation?

cheers,

It should be possible, but would require developing everything from scratch. If anyone wants to do it, they are welcome to use the info about the protocol in my repo.

@kairohmer - yeah, the app I reversed is the one with the green icon, Lampsmart Pro Light.

If you can get the BLE communications from Wireshark, you can simply unwhiten the packets before inspecting them, I even wrote some Python code to do it: Unable to connect to alternative brand of lights - incorrect base code? · Issue #5 · aronsky/esphome-components · GitHub. And the commands are 16-bit integers, as per the reversing of the protocol from the app. Not an issue at all - 16-bit integers are allowed to have values under 256 :wink:

1 Like

got everything to work perfectly i just added the reversed: true, the only thing that I would’ve wanted is to control it directly from the BLE on my home assistant network, thanks so much for this

1 Like

Hello All,

I was not able to pair my lights, so I thought maybe I can get me a nrf52840 dongle and try to sniff out the connection.
I got it setup with wireshark and I can see packets comming in. However I don’t see my lamp or the phone in the device list.
I tried many times to listen to the channels, sending commands through the phone (iphone) and also through the remote, but no luck catching any packets commanding the lamp.
Could it be that I need to do some decrypting or do I need to listen to the pairing first for some reason?

Thank you!