HA Custom Integration to control BLE ADV Ceiling Fans / Lamps

New version 0.9.3!
Support for supplementary controller to be synced with HA, such as a physical remote. This can be done using the ‘reconfigure’ path on an existing integration (see FAQ)
Review of configure / re-configure flows.

Do not hesitate to open issues in case of problem :slight_smile:

Attempted to update to this version but it causes my HA installation to lock up entirely upon loading it. Ended up needing to boot into safe mode via CLI during startup before it tries to load this integration. I was planning to create an issue on Github but I can’t seem to get the debug logs to capture anything. The only log that gets captured when enabling the integration is this:

2025-03-27 19:03:36.389 INFO (MainThread) [homeassistant.setup] Setting up ble_adv

HA core stops responding after that and takes a hard reboot to recover

@zedfs, thanks a lot for the notification!
I deleted the release so that no new user would face the same issue, I am trying to reproduce and investigating what is happening.

@zedfs: bug reproduced, found and corrected!

New release 0.9.4, same as 0.9.3 but with the bug fix

@zedfs: also includes a new zhimei_fan_vr1 codec that should handle your remote

New version 0.9.5 thanks to @siva1danil: Support for Extended Advertising.

@narolinus, this was maybe the same problem than with your first Bluetooth Adapter not supporting Standard Advertising and needing Extended Advertising.

New version 0.9.7, the last beta release as there are no more issue opened!

Main feature: Support of ble_adv_proxy as an addition to existing ESPHome Bluetooth Proxy (that cannot be used as such as not handling BLE ADV message publishing).

Concerning Shelly I never used one, but as per their doc they have the same limitations than the ESPHome Bluetooth Proxy, and their scripting for bluetooth does not allow to publish ADV so a priori it is not possible to build something with it.

Hi @NicoIIT I want to give you a shout out and huge thank you for this effort. I recently got two fans from Amazon by Kviflon, a 46" fan and a 38" fan for my kids room. Both of them come with a rgb color secondary light around the main light. What I did not realize at the time was this was Bluetooth enabled remote and not a Tuya device (I run localtuya). Your integration came to rescue for integrating them with my home assistant.

For other readers, I bought a Bluetooth dongle by ZEXMTE, amazon product id: B0D4PMLL9Y to replace my Rasberry Pi4 internal dongle to increase range and better BLE integration. After disabling my pi4 internal bluetooth, this was a plug n play with no additional drivers.

@NicoIIT - For both the fans, the integration worked 90% out of the box using a light button from the remote as a trigger to identify the device. Both the devices recommend the FanLamp Pro android app which I am not inclined to install.

What can be improved? The rgb lighting on both the fans cannot be controlled by the app, its only on/off. For one of the fans, the main light seems to control the secondary (rgb) light, need to debug this further since the remotes for the fans are not identical. I can try any other feature to help with your development. Thanks again!

Hello @abctechie , well the thing is that I fully reverted the protocols of those apps, meaning I know exactly which command is sent when a button is pressed on the app. Still there is something I cannot know without a device and it is the effect this is going to have on the device!

For Fanlamp Pro I supposed the RGB Control was for the main light and implemented it as such but it seems from what you are saying that it is controlling the second light. And as you are the first user of RGB for Fanlmap protocol, you are debugging this part :slight_smile:.

In order to confirm this and produce a bug fix, I would need you to open an issue and provide debug logs from HA performing the non working actions with the remote. Please note it is important to specify what I cannot see: what action you have done with the remote and what was the result on the light (“I pressed button to go full RED at 12:30:25 and it switched the second light RGB color to RED”) as I need to correlate this action with the captured logs!

Thanks!

@NicoIIT
This mostly works well but encountered a few issues

  1. It doesn’t seem to cycle through all the decodes before erroring out. It just tries the first decode and stops. It worked for all of my lights except one which was using fanlamp_v3 instead of v1. I had to flash the esphome ble_adv_handler to decode the button press and manually put in the second decode and forcedid.
  2. There should be a toggle to switch between multiple ble proxies after the device is set-up or even have the ability to broadcast on all of them instead of having to choose one(not sure if it’s a design limitation)
    Overall, this worked great, thanks a lot for working on this.

Hello @ChayR,
Thanks for the testing!

First of all, I will add a recommendation in the doc and in the config flow: when performing the configuration you must be in the same room than your device. This simply ensures the Ble Proxy you select is immediately tested while configuring and then you should not need to change it afterwards.

It doesn’t seem to cycle through all the decodes before erroring out. It just tries the first decode and stops

I do not reproduce this bug, please open a bug report where you describe precisely your actions and provide the debug logs.

There should be a toggle to switch between multiple ble proxies after the device is set-up

Please open a feature request!

have the ability to broadcast on all of them instead of having to choose one(not sure if it’s a design limitation)

This is a design choice, not a limitation:

  1. At a given time, your device has one best Ble Proxy to communicate with, and this does not change often.
  2. Each Ble Proxy usually has very limited scan capabilities already heavily polluted by the existing Ble devices of your home regularly publishing their services.
  3. Each of your Ble Proxy could emit messages that could be listen by the others if they are in range.
  4. The co-existence in between Ble emit / Ble scan / Wifi on ESP is really not good: the more one is used the more the others are impacted

As a consequence if we broadcast to all your Ble proxies (knowing it is useless because of (1)), each of them will emit messages that will pollute (2) even more all your other Ble proxies in its range (3), themselves re emitting all those listen messages to the HA host via Wifi (4). => Sh** Storm and risk to have your Ble proxies overloaded.

So yes if you are a very lazy user that do not want to select the Ble Proxy nearest to the device and do not care about the stability of his system, you can open a feature request :smile:. Note that I may implement it, with a big Warning specifying no support will be provided :smiling_imp:

1 Like

New release 0.9.8:

  • Improved documentation, added debug log of config listened in config flow
  • (blind) fix for issue #22 opened by @MinnesotaMean

Also reviewed the templates for issues:

Please use them to report complete bugs or feature requests, they guide you to provide all the info needed for me to investigate / implement them, thanks!

First non Beta Release 1.0.1 is available, correcting all known (and reproduced) bugs, also adding last missing features. Enjoy!

1 Like

Thank you so much !!!

I just got a new patio fan by Ahawill (this thing) and I was trying to figure out how to integrate into HA (it uses appliancesmart which is atrocious :face_vomiting:) and I found this post!

Just wanted to express my gratitude - everything worked immediately, I chose to replicate the app settings, the device immediately started blinking and all controls are working :heart_eyes:

Just in case someone is looking for the same thing - the model is Ahawill 2051-Outdoor CF

1 Like

If I have a FanLamp Pro fan/light that the integration recognizes as such, but none of the identified indexes successfully flashes the light, is that appropriately submitted as an issue/New Remote?

Hello @freesew4502,

If I have a FanLamp Pro fan/light that the integration recognizes as such, but none of the identified indexes successfully flashes the light

I do not reproduce this issue, I have a FanLamp Pro myself and everything is working OK. You may have a particular install / Bluetooth adapter or a very particular device.

is that appropriately submitted as an issue/New Remote?

There is no such issue opened as no one experienced this before with Fan Lamp Pro. The opened issues are available here (and there are none):

Please open a new Bug Report providing all the info you can so that I can investigate your particular situation.

Thanks, I wanted to follow the most effective submission path. I didn’t want to dump a lot of detail in this discussion thread.

My problem appears to have been the Tx strength of my M5 Stack Atom Lite ESP32 proxy. It was only 20’ away from the porch fan/light, but diagonally through a couple of exterior walls. Moving it to another interior outlet with fewer obstructions appears to allow the control commands to consistently operate the fan and light as expected. Thanks for all the work on this project. This will be a nice addition.

Ah so you are using a ble_adv_proxy! It would have simplified the answer if you gave this info sooner :smile:. FYI there is an option to increase the TX strength to the max, it does not work on all boards but you can give it a try:

ble_adv_proxy:
  use_max_tx_power: true

Thank you so much, the truth is you’ve solved a lot of problems for me with this integration. I bought 2 Cool White/Warm White lamps that work with the Zhi Guang application and I didn’t know how to integrate them into Home Assistant. Thanks to you, I’ve been able to. The ‘automatic’ function has worked perfectly for me. Just one small problem, which isn’t really a problem for me because the most important thing is adjusting brightness and color temperature. These two functions work perfectly, but the ON/OFF doesn’t. I don’t know why, it seems to only work one cycle, the next one doesn’t, and the one after that does. For example, if I turn the light on, it turns off perfectly, but the next ON/OFF doesn’t work, the one after that does, and so on. If, for example, the ON hasn’t worked and I turn on the lamp with the remote control, the OFF also doesn’t work until the next cycle. However, even though the ON/OFF doesn’t work, the brightness and temperature adjustments do. The cycles can change, and maybe one time it’s the ON/OFF that doesn’t work, and other times it’s the OFF/ON. Otherwise, the integration is great.
Thank you very much!!!

Hello @Tarod1977,

Happy to see this integration is helping!

I just pushed a (blind) fix attempt for your issue in release v1.0.5, but this is really a guess of what could be wrong based on one difference between the Phone App behavior and this integration so I have hope but cannot guarantee it will work…

If it does not fix the problem please fill in a Bug Report so that I could have all the info needed to investigate.