Add new ble_adv_controller component integrating the handling of fan, lights, pairing button and new variants

Creation of a new component 'ble_adv_controller' able to handle not only lights but also fans combined in a same lamp. It is based mainly on your component 'ble_adv_light' and the fork from @flicker581, with a lot of refactoring. It does not support only lights and has a centralized controller so I renamed it.
New Features:

Centralized controller for multiple entities to support lamps with multiple lights and/or fan
Handling of 'pair' button, more easy to use than service call from HA.
Handling of Fan for ZhiJia (Not Tested, retro engineering from app)
Handling of Fan for FanLamp pro (Tested OK with my own fan)
Handling of ZhiJia encoding v0 (MSC16) and v1 (MSC26) based on work done by @14roiron here and retro engineering from app for the command codes and arguments. Not Tested.
Handling of FanLamp encoding v1a / v1b / v2 / v3 based on work done by @flicker581. Verified by comparing packets generated from the app on his forked repository and this new component.
Handling of custom commands to be able to test features more easily, and explanations on reverse engineering.

Related Issues:
https://github.com/aronsky/esphome-components/issues/16 : Add of Fan Support, partially tested
https://github.com/aronsky/esphome-components/issues/13 : potentially solved by the support of more encoding on ZhiJia, but needs to be tested
https://github.com/aronsky/esphome-components/issues/12 : No more compilation issues on the new component
https://github.com/aronsky/esphome-components/issues/11: Added encoding proposed (Not Validated, need user help)
https://github.com/aronsky/esphome-components/issues/11: Solved already in @flicker581 repo, encoding added here
https://github.com/aronsky/esphome-components/issues/1: Changing the default value of 'default_transition_length' to 0s

Thank you for the hard work! That's a huge PR, I'll go over it when I find the time, and hopefully will merge it soon.

I have many lamp controlled by FanLamp and ZhiJia App.
Include two identical lamp controller by ZhiJia App.
In app lamp controlled separately.
In HA lamp controlled same time.
My esphome config:
external_components:
source: github://NicoIIT/esphome-components
ble_adv_controller:

id: bedroom_bedsidelamp_my
encoding: zhijia
variant: v2
duration: 500
forced_id: 0xC630B1

id: bedroom_bedsidelamp_notmy
encoding: zhijia
variant: v2
duration: 500
forced_id: 0xC630B2

id: bedroom_chandelier
encoding: fanlamp_pro
variant: v1a
duration: 500
reversed: false
forced_id: 0

light:

platform: ble_adv_controller
ble_adv_controller_id: bedroom_bedsidelamp_my
name: bedroom_bedsidelamp_my
default_transition_length: 0s

platform: ble_adv_controller
ble_adv_controller_id: bedroom_bedsidelamp_notmy
name: bedroom_bedsidelamp_notmy
default_transition_length: 0s

platform: ble_adv_controller
ble_adv_controller_id: bedroom_chandelier
name: bedroom_chandelier
index: 0
min_brightness: 21

button:

platform: ble_adv_controller
ble_adv_controller_id: bedroom_bedsidelamp_my
name: Pair bedroom_bedsidelamp_my
cmd: pair

platform: ble_adv_controller
ble_adv_controller_id: bedroom_bedsidelamp_notmy
name: Pair bedroom_bedsidelamp_notmy
cmd: pair

platform: ble_adv_controller
ble_adv_controller_id: bedroom_chandelier
name: Pair bedroom_chandelier
cmd: pair

ESPHome log:
[20:50:45][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[20:50:45][D][light:051]:   Brightness: 71%
[20:50:45][D][ble_adv_light:053]: BleAdvLight::write_state called! Requested cw: 97, ww: 97
[20:50:45][D][zhijia:636]: UUID: '0x00C630', tx: 11, Command: '0xAE', Args: [127,0,0]
[20:50:45][D][ble_adv_controller:071]: Prepared packet: 22.9D.B4.C4.1B.AF.43.9C.EF.3F.1A.80.2D.E5.D1.02.C<IP_ADDRESS>A.5F.85.F6.9C.A9.19 (26)
[20:50:45][D][zhijia:636]: UUID: '0x00C630', tx: 12, Command: '0xAD', Args: [194,0,0]
[20:50:45][D][ble_adv_controller:071]: Prepared packet: 22.9D.0D.7A.1F.AB.40.98.EB.3B.19.87.29.E1.D5.01.C<IP_ADDRESS>A.5F.85.F6.9C.A9.19 (26)
[20:50:45][D][ble_adv_controller:085]: bedroom_bedsidelamp_my - start advertising at 143917
[20:50:45][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[20:50:45][D][light:047]:   State: OFF
[20:50:45][D][zhijia:636]: UUID: '0x00C630', tx: 13, Command: '0xA6', Args: [0,0,0]
[20:50:45][D][ble_adv_controller:071]: Prepared packet: 22.9D.C5.B3.15.A1.4B.92.E<IP_ADDRESS>.23.EB.DF.0A.C3.22.9C.4A.5F.85.F6.9C.A9.19 (26)
[20:50:46][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising at 144432
[20:50:46][D][ble_adv_controller:085]: bedroom_bedsidelamp_my - start advertising at 144437
[20:50:46][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising at 144940
[20:50:46][D][ble_adv_controller:085]: bedroom_bedsidelamp_my - start advertising at 144950
[20:50:47][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising at 145457
[20:51:08][D][light:036]: 'bedroom_bedsidelamp_notmy' Setting:
[20:51:08][D][light:047]:   State: ON
[20:51:08][D][ble_adv_light:053]: BleAdvLight::write_state called! Requested cw: 255, ww: 255
[20:51:08][D][zhijia:636]: UUID: '0x00C630', tx: 2, Command: '0xA5', Args: [0,0,0]
[20:51:08][D][ble_adv_controller:071]: Prepared packet: 22.9D.C9.B0.19.AD.48.9E.ED.3D.11.89.2F.E7.D3.09.C3.2D.90.4A.5F.85.F6.9C.A9.19 (26)
[20:51:08][D][zhijia:636]: UUID: '0x00C630', tx: 3, Command: '0xAE', Args: [127,0,0]
[20:51:08][D][ble_adv_controller:071]: Prepared packet: 22.9D.BC.C4.13.A7.43.94.E7.37.1A.88.25.ED.D9.02.C3.2C.9A.4A.5F.85.F6.9C.A9.19 (26)
[20:51:08][D][zhijia:636]: UUID: '0x00C630', tx: 4, Command: '0xAD', Args: [255,0,0]
[20:51:08][D][ble_adv_controller:071]: Prepared packet: 22.9D.38.47.17.A3.40.90.E<IP_ADDRESS>F.21.E9.DD.01.C3.2B.9E.4A.5F.85.F6.9C.A9.19 (26)
[20:51:08][W][component:237]: Component light took a long time for an operation (69 ms).
[20:51:08][W][component:238]: Components should block for at most 30 ms.
[20:51:08][D][ble_adv_controller:085]: bedroom_bedsidelamp_notmy - start advertising at 166474
[20:51:08][D][ble_adv_controller:096]: bedroom_bedsidelamp_notmy - stop advertising at 166980
[20:51:08][D][ble_adv_controller:085]: bedroom_bedsidelamp_notmy - start advertising at 166987
[20:51:09][D][ble_adv_controller:096]: bedroom_bedsidelamp_notmy - stop advertising at 167491
[20:51:09][D][ble_adv_controller:085]: bedroom_bedsidelamp_notmy - start advertising at 167499
[20:51:09][D][ble_adv_controller:096]: bedroom_bedsidelamp_notmy - stop advertising at 168003

@cRazyK67, thanks a lot for your testing and input!
The UUID used by ZhiJia on 3 characters is computed from the input forced_id by truncation. I simulated what was done by the ZhiJia App from the AndroidId : 0xAABBCCDD => [AA, BB, CC]. In your case:
0xC630B1 = 0x00C630B1 => [00,C6,30]
0xC630B2 = 0x00C630B2 => [00,C6,30]
So they have the same UUID at the end... This computation is definitively not smart as the way you entered the ID (having the last digit vary) is clearly the way anyone will enter them: the software needs to be changed or at least the doc :)
Still there is some mystery in how the App is controlling multiple lights, I am not sure the UUID is effectively the key used to differentiate the lights, especially because from the app it is using the AndroidId... Could you please try to change them to 0xC630B100 and 0xC630B200 and check it it works? If not, I will add some debug options to be able to have other for now "fixed" parameters to vary, such as GROUP and MAC.
Another question: did you manage to have the lights work separately with previous 'ble_adv_light' component ?

Still there is some mystery in how the App is controlling multiple lights, I am not sure the UUID is effectively the key used to differentiate the lights, especially because from the app it is using the AndroidId... Could you please try to change them to 0xC630B100 and 0xC630B200 and check it it works?

The change you suggested (changing the first 3 significant bytes of the UUID) allowed the lamps to be controlled separately.

Another question: did you manage to have the lights work separately with previous 'ble_adv_light' component ?

With the previous component, all sources worked simultaneously for me.
I also have a problem with lamps flickering when changing brightness or color temperature. It seems that the brightness is first set to 100%, and then to the desired value.
I’ll post a video of the lamp’s behavior on YouTube a little later.
[11:12:52][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[11:12:52][D][light:051]:   Brightness: 19%
[11:12:52][D][ble_adv_light:053]: BleAdvLight::write_state called! Requested cw: 7, ww: 7
[11:12:52][D][zhijia:636]: UUID: '0xC630B1', tx: 5, Command: '0xAE', Args: [127,0,0]
[11:12:52][D][ble_adv_controller:071]: Prepared packet: 22.9D.F4.3B.9D.EF.0D.DC.AF.7F.92.C0.6D.A5.A1.4C.4B.E5.D2.4A.5F.85.F6.9C.A9.19 (26)
[11:12:52][D][zhijia:636]: UUID: '0xC630B1', tx: 6, Command: '0xAD', Args: [14,0,0]
[11:12:52][D][ble_adv_controller:071]: Prepared packet: 22.9D.85.49.9D.EF.0E.DC.AF.7F.91.C3.6D.A5.A1.4F.4B.E6.D2.4A.5F.85.F6.9C.A9.19 (26)
[11:12:52][D][ble_adv_controller:085]: bedroom_bedsidelamp_my - start advertising at 166152
[11:12:53][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising at 166655
[11:12:53][D][ble_adv_controller:085]: bedroom_bedsidelamp_my - start advertising at 166661
[11:12:54][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising at 167166
[11:12:57][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[11:12:57][D][light:051]:   Brightness: 46%
[11:12:57][D][ble_adv_light:053]: BleAdvLight::write_state called! Requested cw: 28, ww: 28
[11:12:57][D][zhijia:636]: UUID: '0xC630B1', tx: 7, Command: '0xAE', Args: [127,0,0]
[11:12:57][D][ble_adv_controller:071]: Prepared packet: 22.9D.F6.3B.9F.ED.0D.DE.AD.7D.92.C2.6F.A7.A3.4C.4B.E7.D0.4A.5F.85.F6.9C.A9.19 (26)
[11:12:57][D][zhijia:636]: UUID: '0xC630B1', tx: 8, Command: '0xAD', Args: [56,0,0]
[11:12:57][D][ble_adv_controller:071]: Prepared packet: 22.9D.BD.7F.93.E1.0E.D2.A1.71.91.CD.63.AB.AF.4F.4B.E8.DC.4A.5F.85.F6.9C.A9.19 (26)
[11:12:57][D][ble_adv_controller:085]: bedroom_bedsidelamp_my - start advertising at 170444
[11:12:57][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising at 170955
[11:12:57][D][ble_adv_controller:085]: bedroom_bedsidelamp_my - start advertising at 170960
[11:12:58][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising at 171468
[11:13:00][D][light:352]: 'bedroom_bedsidelamp_my' - Setting cold/warm white channels using white/color temperature values.
[11:13:00][W][light:227]: 'bedroom_bedsidelamp_my' - Color temperature value 333.00 is out of range [167.0 - 333.0]!
[11:13:00][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[11:13:00][D][light:066]:   Color temperature: 333.0 mireds
[11:13:00][D][light:071]:   Cold white: 0%, warm white: 100%
[11:13:00][D][ble_adv_light:053]: BleAdvLight::write_state called! Requested cw: 0, ww: 28
[11:13:00][D][zhijia:636]: UUID: '0xC630B1', tx: 9, Command: '0xAE', Args: [255,0,0]
[11:13:00][D][ble_adv_controller:071]: Prepared packet: 22.9D.78.BB.91.E3.0D.D0.A3.73.92.CC.61.A9.AD.4C.4B.E9.DE.4A.5F.85.F6.9C.A9.19 (26)
[11:13:00][D][zhijia:636]: UUID: '0xC630B1', tx: 10, Command: '0xAD', Args: [28,0,0]
[11:13:00][D][ble_adv_controller:071]: Prepared packet: 22.9D.9B.5B.91.E3.0E.D0.A3.73.91.CF.61.A9.AD.4F.4B.EA.DE.4A.5F.85.F6.9C.A9.19 (26)
[11:13:00][D][ble_adv_controller:085]: bedroom_bedsidelamp_my - start advertising at 173960
[11:13:01][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising at 174476
[11:13:01][D][ble_adv_controller:085]: bedroom_bedsidelamp_my - start advertising at 174485
[11:13:01][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising at 174994
[11:13:04][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[11:13:04][D][light:051]:   Brightness: 27%
[11:13:04][D][ble_adv_light:053]: BleAdvLight::write_state called! Requested cw: 0, ww: 7
[11:13:04][D][zhijia:636]: UUID: '0xC630B1', tx: 11, Command: '0xAE', Args: [255,0,0]
[11:13:04][D][ble_adv_controller:071]: Prepared packet: 22.9D.7A.BB.93.E1.0D.D2.A1.71.92.CE.63.AB.AF.4C.4B.EB.DC.4A.5F.85.F6.9C.A9.19 (26)
[11:13:04][D][zhijia:636]: UUID: '0xC630B1', tx: 12, Command: '0xAD', Args: [7,0,0]
[11:13:04][D][ble_adv_controller:071]: Prepared packet: 22.9D.86.40.97.E5.0E.D6.A5.75.91.C9.67.AF.AB.4F.4B.EC.D8.4A.5F.85.F6.9C.A9.19 (26)
[11:13:04][D][ble_adv_controller:085]: bedroom_bedsidelamp_my - start advertising at 178026
[11:13:05][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising at 178533
[11:13:05][D][ble_adv_controller:085]: bedroom_bedsidelamp_my - start advertising at 178539
[11:13:05][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising at 179043

I observe inappropriate fan behavior FanLamp v2
My sequence of actions in HA:

Set fan speed 6 (100%) - the fan on the lamp begins to rotate at maximum speed
Set fan speed 3 (50%) - fan rotating on half-speed
Turn off fan from ha button - fan stoping
Turn on fan from ha button - fan still not rotate (in HA fan speed 50%)
Change speed to another - fan rotating

log for last action (4,5)
[12:29:30][D][fan:021]: 'childroom_chandelier_fan' - Setting:
[12:29:30][D][fan:024]:   State: ON
[12:29:30][D][ble_adv_fan:027]: BleAdvFan::control called
[12:29:30][D][ble_adv_fan:038]: BleAdvFan::control - toggle
[12:29:30][D][fanlamp_pro:278]: ID: '0x960D13A2', tx: 85, Command: '0x31', Args: [0,0,0,0]
[12:29:31][D][ble_adv_controller:071]: Prepared packet: F<IP_ADDRESS>.E9.67.BC.2E.12.3E.35.3C.C8.F0.0D.98.5F.9D.D7.1B.12.1C.2A.FE.98.A0 (26)
[12:29:31][D][fan:120]: 'childroom_chandelier_fan' - Sending state:
[12:29:31][D][fan:121]:   State: ON
[12:29:31][D][fan:123]:   Speed: 3
[12:29:31][D][fan:129]:   Direction: FORWARD
[12:29:31][W][component:237]: Component api took a long time for an operation (56 ms).
[12:29:31][W][component:238]: Components should block for at most 30 ms.
[12:29:31][D][ble_adv_controller:085]: childroom_chandelier - start advertising at 539731
[12:29:31][D][ble_adv_controller:096]: childroom_chandelier - stop advertising at 539833
[12:29:52][D][fan:021]: 'childroom_chandelier_fan' - Setting:
[12:29:52][D][fan:024]:   State: ON
[12:29:52][D][fan:030]:   Speed: 4
[12:29:52][D][ble_adv_fan:027]: BleAdvFan::control called
[12:29:52][D][ble_adv_fan:031]: BleAdvFan::control - setup speed 4
[12:29:52][D][fanlamp_pro:278]: ID: '0x960D13A2', tx: 86, Command: '0x31', Args: [0,32,4,0]
[12:29:52][D][ble_adv_controller:071]: Prepared packet: F<IP_ADDRESS>.C8.01.CA.DE.EF.3C.2B.7C.7F.89.7A.30.7E.EF.FB.2F.91.01.CD.59.20.F1 (26)
[12:29:52][D][fan:120]: 'childroom_chandelier_fan' - Sending state:
[12:29:52][D][fan:121]:   State: ON
[12:29:52][D][fan:123]:   Speed: 4
[12:29:52][D][fan:129]:   Direction: FORWARD
[12:29:52][W][component:237]: Component api took a long time for an operation (63 ms).
[12:29:52][W][component:238]: Components should block for at most 30 ms.
[12:29:52][D][ble_adv_controller:085]: childroom_chandelier - start advertising at 562064
[12:29:52][D][ble_adv_controller:096]: childroom_chandelier - stop advertising at 562166
[12:32:54][W][api.connection:129]: Home Assistant 2024.7.3 (<IP_ADDRESS>) didn't respond to ping request in time. Disconnecting...
[12:32:55][D][api:102]: Accepted <IP_ADDRESS>
[12:32:56][D][api.connection:1375]: Home Assistant 2024.7.3 (<IP_ADDRESS>): Connected successfully

@cRazyK67, I reviewed the Fan and Light Algo to be smarter, this may solve your issues. Please note you can still experience flickering on first switch onjust after flash / power cut or things like that, but no more in standard usage. This includes the change of min_brigthness to a percentage value (0.21 or 21% for example), but it is the default so you can remove the line.
Also added "reversed" option for ZhiJia.
Reviewed the computation of the UUID for ZhiJia, you should go back to your previous forced_id 0xC630B1 and 0xC630B2 to avoid the need for re-pairing.

@NicoIIT Thanks for the quick fixes.
Here is a short report on them:

Also added "reversed" option for ZhiJia.

Works

Reviewed the computation of the UUID for ZhiJia, you should go back to your previous forced_id 0xC630B1 and 0xC630B2 to avoid the need for re-pairing.

Works without re-paring

I reviewed the Fan and Light Algo to be smarter, this may solve your issues. Please note you can still experience flickering on first switch onjust after flash / power cut or things like that, but no more in standard usage. This includes the change of min_brigthness to a percentage value (0.21 or 21% for example), but it is the default so you can remove the line.

Fan works fine.
The change in brightness also occurs without flickering, however, when the color temperature changes, the brightness increases, according to my feelings, to a level of 40-50%
I do the following sequence of steps:

I set the light to cold
Set the Brightness to 100%
Set the Brightness to 1%
Set up warm light
Set the brightness to 15%

After step 4, the brightness, as I wrote, is ~40-50%
After step 5, the brightness decreases and is approximately the minimum for my lamp.
Below is the log of these actions:
[21:51:23][D][light:352]: 'bedroom_bedsidelamp_my' - Setting cold/warm white channels using white/color temperature values.
[21:51:23][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[21:51:23][D][light:066]:   Color temperature: 167.0 mireds
[21:51:23][D][light:071]:   Cold white: 100%, warm white: 1%
[21:51:23][D][ble_adv_light:048]: Corrected brightness: 46%
[21:51:23][D][ble_adv_light:070]: ct: 167.001, br: 0.459
[21:51:23][D][ble_adv_light:075]: BleAdvLight::write_state - Requested color temperature: 0
[21:51:23][D][zhijia:636]: UUID: '0xC630B1', tx: 6, Command: '0xAE', Args: [0,0,0]
[21:51:23][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.77.BB.61.13.F<IP_ADDRESS>.6D.3C.91.59.5D.B3.B4.19.2E.4A.5F.85.F6.9C.A9.19 (26)
[21:51:24][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising
[21:51:27][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[21:51:27][D][light:051]:   Brightness: 100%
[21:51:27][D][ble_adv_light:048]: Corrected brightness: 100%
[21:51:27][D][ble_adv_light:070]: ct: 167.001, br: 1.000
[21:51:27][D][ble_adv_light:079]: BleAdvLight::write_state - Requested brightness: 255
[21:51:27][D][zhijia:636]: UUID: '0xC630B1', tx: 7, Command: '0xAD', Args: [255,0,0]
[21:51:27][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.8A.47.63.11.F<IP_ADDRESS>.6E.3D.93.5B.5F.B0.B4.18.2C.4A.5F.85.F6.9C.A9.19 (26)
[21:51:27][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising
[21:51:33][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[21:51:33][D][light:051]:   Brightness: 1%
[21:51:33][D][ble_adv_light:048]: Corrected brightness: 1%
[21:51:33][D][ble_adv_light:070]: ct: 167.001, br: 0.012
[21:51:33][D][ble_adv_light:079]: BleAdvLight::write_state - Requested brightness: 3
[21:51:33][D][zhijia:636]: UUID: '0xC630B1', tx: 8, Command: '0xAD', Args: [3,0,0]
[21:51:33][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.86.44.93.E1.0E.D2.A1.71.91.CD.63.AB.AF.4F.4B.E8.DC.4A.5F.85.F6.9C.A9.19 (26)
[21:51:35][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising
[21:51:37][D][light:352]: 'bedroom_bedsidelamp_my' - Setting cold/warm white channels using white/color temperature values.
[21:51:37][W][light:227]: 'bedroom_bedsidelamp_my' - Color temperature value 333.00 is out of range [167.0 - 333.0]!
[21:51:37][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[21:51:37][D][light:066]:   Color temperature: 333.0 mireds
[21:51:37][D][light:071]:   Cold white: 0%, warm white: 100%
[21:51:37][D][ble_adv_light:048]: Corrected brightness: 1%
[21:51:37][D][ble_adv_light:070]: ct: 333.000, br: 0.012
[21:51:37][D][ble_adv_light:075]: BleAdvLight::write_state - Requested color temperature: 255
[21:51:37][D][zhijia:636]: UUID: '0xC630B1', tx: 9, Command: '0xAE', Args: [255,0,0]
[21:51:37][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.78.BB.91.E3.0D.D0.A3.73.92.CC.61.A9.AD.4C.4B.E9.DE.4A.5F.85.F6.9C.A9.19 (26)
[21:51:37][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising
[21:51:45][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[21:51:45][D][light:051]:   Brightness: 15%
[21:51:45][D][ble_adv_light:048]: Corrected brightness: 15%
[21:51:45][D][ble_adv_light:070]: ct: 333.000, br: 0.149
[21:51:45][D][ble_adv_light:079]: BleAdvLight::write_state - Requested brightness: 38
[21:51:45][D][zhijia:636]: UUID: '0xC630B1', tx: 10, Command: '0xAD', Args: [38,0,0]
[21:51:45][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.A1.61.91.E3.0E.D0.A3.73.91.CF.61.A9.AD.4F.4B.EA.DE.4A.5F.85.F6.9C.A9.19 (26)
[21:51:45][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising

- platform: ble_adv_controller
   ble_adv_controller_id: bedroom_bedsidelamp_my
   name: bedroom_bedsidelamp_my
   default_transition_length: 0s
   min_brightness: 0%

I also noticed errors during compilation.
Everything compiles and works, but if you can fix the compiler warnings, then it's better to do so.
Compiling .pioenvs/esp-childroom-chandelier/src/esphome/components/esp32_ble/ble.cpp.o
src/esphome/components/ble_adv_controller/zhijia.cpp: In function 'void esphome::bleadvcontroller::msc16_msc26::whitening_init(uint8_t, int*, size_t)':
src/esphome/components/ble_adv_controller/zhijia.cpp:72:32: warning: narrowing conversion of '((((int)val) >> 5) & 1)' from 'int' to 'uint8_t' {aka 'unsigned char'} inside { } [-Wnarrowing]
     uint8_t v0[] = {(val >> 5) & 1, (val >> 4) & 1, (val >> 3) & 1, (val >> 2) & 1};
                     ~~~~~~~~~~~^~~
src/esphome/components/ble_adv_controller/zhijia.cpp:72:48: warning: narrowing conversion of '((((int)val) >> 4) & 1)' from 'int' to 'uint8_t' {aka 'unsigned char'} inside { } [-Wnarrowing]
     uint8_t v0[] = {(val >> 5) & 1, (val >> 4) & 1, (val >> 3) & 1, (val >> 2) & 1};
                                     ~~~~~~~~~~~^~~
src/esphome/components/ble_adv_controller/zhijia.cpp:72:64: warning: narrowing conversion of '((((int)val) >> 3) & 1)' from 'int' to 'uint8_t' {aka 'unsigned char'} inside { } [-Wnarrowing]
     uint8_t v0[] = {(val >> 5) & 1, (val >> 4) & 1, (val >> 3) & 1, (val >> 2) & 1};
                                                     ~~~~~~~~~~~^~~
src/esphome/components/ble_adv_controller/zhijia.cpp:72:80: warning: narrowing conversion of '((((int)val) >> 2) & 1)' from 'int' to 'uint8_t' {aka 'unsigned char'} inside { } [-Wnarrowing]
     uint8_t v0[] = {(val >> 5) & 1, (val >> 4) & 1, (val >> 3) & 1, (val >> 2) & 1};
                                                                     ~~~~~~~~~~~^~~
Compiling .pioenvs/esp-childroom-chandelier/src/esphome/components/esp32_ble/ble_advertising.cpp.o

@cRazyK67, For the compilation warning, the code is not mine but taken from someone else, I will correct but I need to perform some supplementary testing to be sure it does not impact the functionality (ZhiJia v0 and v1). For the issue you have,  from what I see in the logs, there is no "brightness" command issued when changing the color temperature, so it means the color temperature command itself is having an unexpected behavior. Still the command is quite basic (a code and a 1-byte value). I have 2 hypothesis but I would need your help to test it as I do not own any ZhiJia lamp. Could you please:

Add the following custom buttons to your config:

button:
- platform: ble_adv_controller
  ble_adv_controller_id: bedroom_bedsidelamp_my
  name: ct250
  cmd: custom
  args: [174,250,0,0,0]
- platform: ble_adv_controller
  ble_adv_controller_id: bedroom_bedsidelamp_my
  name: br1
  cmd: custom
  args: [173,3,0,0,0]

Perform Test 1:

set the light to cold
set the Brightness to 100%
set the Brightness to 1%
press button "ct250". This simulates a setting of color temperature but with a max arg of 250 instead of 255
tell me if you have the same behavior than in your step 4 or a proper behavior.

If it does not work, perform Test 2:

set the light to cold
set the Brightness to 100%
press button "br1" 2 times in a raw (in less than 1 second). This simulates a potential behavior of the app consisting in sending 2 times the message (kind of start and end...)
set color temperature to warm
tell me if you have the same behavior than in your step 4 or a proper behavior.

A last question, do you have the same issue when brightness is 100% and you switch color temperature?
Thanks in advance!

This is awesome! Thank you for giving some love to this already-awesome attempt to support FanLamp ceiling fans 🧡
I'm an owner of 2 v1b (or v1x). It is only capable of pairing when selecting v1b, but there are a couple of things not working yet:

I cannot control the direction of the fan. I get these logs when I try to change it

// Switch to reverse
15:47:09	[D]	[fan:021]	'Despacho Fanlamp' - Setting:
15:47:09	[D]	[fan:033]	  Direction: REVERSE
15:47:09	[D]	[ble_adv_fan:063]	BleAdvFan::control - Setting direction rev
15:47:09	[W]	[ble_adv_controller:059]	Unsupported command received: 34. Aborted.
15:47:09	[D]	[fan:120]	'Despacho Fanlamp' - Sending state:
15:47:09	[D]	[fan:121]	  State: ON
15:47:09	[D]	[fan:123]	  Speed: 1
15:47:09	[D]	[fan:129]	  Direction: REVERSE

// Switch to forward
15:47:57	[D]	[fan:021]	'Despacho Fanlamp' - Setting:
15:47:57	[D]	[fan:033]	  Direction: FORWARD
15:47:57	[D]	[ble_adv_fan:063]	BleAdvFan::control - Setting direction fwd
15:47:57	[W]	[ble_adv_controller:059]	Unsupported command received: 34. Aborted.
15:47:57	[D]	[fan:120]	'Despacho Fanlamp' - Sending state:
15:47:57	[D]	[fan:121]	  State: ON
15:47:57	[D]	[fan:123]	  Speed: 1
15:47:57	[D]	[fan:129]	  Direction: FORWARD

The other thing I cannot control is the "indirect light": the lamp has 2 lights: The main one (which works great), and a secondary light (facing upwards, and it doesn't allow brightness control). I tried using different index (tried with 1 and 2) to see if that helped... but it doesn't seem to take any effect. No errors in the logs, though.

// Turn ON
15:52:05	[D]	[light:036]	'Despacho Fanlamp Luz Indirecta' Setting:
15:52:05	[D]	[light:047]	  State: ON
15:52:05	[D]	[ble_adv_light:040]	BleAdvLight::write_state - Switch ON
15:52:05	[D]	[fanlamp_pro:220]	ID: '0x7BD40F46', tx: 12, Command: '0x10', Args: [0,0,0]
15:52:05	[D]	[ble_adv_light:048]	Corrected brightness: 100%
15:52:05	[D]	[ble_adv_controller:088]	despacho_fanlamp - start advertising: F<IP_ADDRESS>.F<IP_ADDRESS>E.31.51.BA.B2.FA.48.24.CB.3B.CC.71.DF.88.7E.94.EA.B4.4C (26)
15:52:05	[D]	[ble_adv_controller:096]	despacho_fanlamp - stop advertising

// Turn OFF
15:52:08	[D]	[light:036]	'Despacho Fanlamp Luz Indirecta' Setting:
15:52:08	[D]	[light:047]	  State: OFF
15:52:08	[D]	[ble_adv_light:032]	BleAdvLight::write_state - Switch OFF
15:52:08	[D]	[fanlamp_pro:220]	ID: '0x7BD40F46', tx: 13, Command: '0x11', Args: [0,0,0]
15:52:08	[D]	[ble_adv_controller:088]	despacho_fanlamp - start advertising: F<IP_ADDRESS>.F<IP_ADDRESS>E.31.51.BA.32.FA.48.24.CB.3B.4C.71.F7.A0.F0.BC.AD.F6.4C (26)
15:52:08	[D]	[ble_adv_controller:096]	despacho_fanlamp - stop advertising

My current config:
external_components:
  # shorthand
  source: github://NicoIIT/esphome-components

ble_adv_controller:
  - id: despacho_fanlamp
    encoding: fanlamp_pro
    variant: v1b
    duration: 500
    reversed: false
    forced_id: 0

light:
  - platform: ble_adv_controller
    ble_adv_controller_id: despacho_fanlamp
    name: Despacho Fanlamp
    index: 0
  - platform: ble_adv_controller
    ble_adv_controller_id: despacho_fanlamp
    name: Despacho Fanlamp Luz Indirecta
    index: 2

fan:
  - platform: ble_adv_controller
    ble_adv_controller_id: despacho_fanlamp
    name: Despacho Fanlamp
    speed_count: 6
    use_direction: true

button:
  - platform: ble_adv_controller
    ble_adv_controller_id: despacho_fanlamp
    name: Pair Despacho Fanlaml
    cmd: pair

Thank you again!

I also noticed errors during compilation. Everything compiles and works, but if you can fix the compiler warnings, then it's better to do so.
Compiling .pioenvs/esp-childroom-chandelier/src/esphome/components/esp32_ble/ble.cpp.o
src/esphome/components/ble_adv_controller/zhijia.cpp: In function 'void esphome::bleadvcontroller::msc16_msc26::whitening_init(uint8_t, int*, size_t)':
src/esphome/components/ble_adv_controller/zhijia.cpp:72:32: warning: narrowing conversion of '((((int)val) >> 5) & 1)' from 'int' to 'uint8_t' {aka 'unsigned char'} inside { } [-Wnarrowing]
     uint8_t v0[] = {(val >> 5) & 1, (val >> 4) & 1, (val >> 3) & 1, (val >> 2) & 1};
                     ~~~~~~~~~~~^~~
src/esphome/components/ble_adv_controller/zhijia.cpp:72:48: warning: narrowing conversion of '((((int)val) >> 4) & 1)' from 'int' to 'uint8_t' {aka 'unsigned char'} inside { } [-Wnarrowing]
     uint8_t v0[] = {(val >> 5) & 1, (val >> 4) & 1, (val >> 3) & 1, (val >> 2) & 1};
                                     ~~~~~~~~~~~^~~
src/esphome/components/ble_adv_controller/zhijia.cpp:72:64: warning: narrowing conversion of '((((int)val) >> 3) & 1)' from 'int' to 'uint8_t' {aka 'unsigned char'} inside { } [-Wnarrowing]
     uint8_t v0[] = {(val >> 5) & 1, (val >> 4) & 1, (val >> 3) & 1, (val >> 2) & 1};
                                                     ~~~~~~~~~~~^~~
src/esphome/components/ble_adv_controller/zhijia.cpp:72:80: warning: narrowing conversion of '((((int)val) >> 2) & 1)' from 'int' to 'uint8_t' {aka 'unsigned char'} inside { } [-Wnarrowing]
     uint8_t v0[] = {(val >> 5) & 1, (val >> 4) & 1, (val >> 3) & 1, (val >> 2) & 1};
                                                                     ~~~~~~~~~~~^~~
Compiling .pioenvs/esp-childroom-chandelier/src/esphome/components/esp32_ble/ble_advertising.cpp.o

I think this is from my code, I will try to correct it, But feel free to so if you want, I may have still have some test vectors to verify the change

@afharo, Thanks for the testing, you are the first to use Fan with fanlamp_pro v1x !
The 'direction' feature was simply not implemented for v1, I missed it 😄. It should work now with my last commit.
For the 'index' feature to handle multiple lights, I never tested it as I do not have such lights, this was a guess but this was maybe a complete wrong read of the code... Could you please use the custom service in order to make a few tests ?
The custom service is a new service, available in HA -> developer tools -> Services
Select the service "esphome: <device_name>_cmd_despacho_fanlamp"
Enter 0 for all fields, except for the "cmd":
-> 16 (and press "call service") should switch the main light ON, just for validating the service is working OK
-> 17: switch main light OFF
-> 18: switch "AssistLed" ON -> may switch ON your secondary light
-> 19: switch "AssistLed" OFF -> may switch OFF your secondary light
If this is switching your secondary light then I could implement the proper handling, else I will have to dive into java and android code and I really hate that 🥲

@14roiron, I already corrected the warning in my last commit, quite easy in fact 😄
I am not sure if you could help on another topic, but would you own ZhiJia lights using encoding v0 (MSC16) or v1 (MSC26)?  I do not own any so the software is pure reverse engineering and then end user testing would be really appreciated !

@NicoIIT

-> 18: switch "AssistLed" ON -> may switch ON your secondary light
-> 19: switch "AssistLed" OFF -> may switch OFF your secondary light

It's working! This is the way!

The 'direction' feature was simply not implemented for v1, I missed it 😄. It should work now with my last commit.

It still doesn't... 😢
FWIW, I tried the HA service with the command 21 and changing arg0 to 0 and 1, and it changed the direction. But using the direction selector in HA doesn't work.
I wonder if the code is missing a handler somewhere. Other actions, I can see lines like [fanlamp_pro:220] ID: ... Command: .... The same happens when using the service: ID: '0x7BD40F46', tx: 13, Command: '0x15', Args: [0,0,0] and ID: '0x7BD40F46', tx: 14, Command: '0x15', Args: [1,0,0]
However, when changing the direction via HA, I get this other log warning:
18:55:11	[W]	[ble_adv_controller:059]	Unsupported command received: 34. Aborted

@NicoIIT, I had the default refresh: 1d in the external_components 😅
After setting it to refresh: 0s, I got the latest and greatest and (drumroll) everything works!
 Thanks for the iterations and for the quick responses and fixes! 🧡 🧡

I had the default refresh: 1d in the external_components 😅
After setting it to refresh: 0s, I got the latest and greatest and (drumroll) everything works!

@afharo  Thanks for the hint.
Now I also automatically always have the latest version
@NicoIIT  thanks for

secondary: true

Now my chandelier also has a second light source.
I haven’t written to you about him yet, because... was busy testing switching brightness and color temperature on the chandelier

Do you have the same issue when brightness is 100% and you switch color temperature?

I have not tested the 'ble_adv_light' component  in such detail because... it didn't work correctly for me.

Did you have the same flickering issues with the 'ble_adv_light' component ?

Yes.

Perform Test 1:
set the light to cold
set the Brightness to 100%
set the Brightness to 1%
press button "ct250". This simulates a setting of color temperature but with a max arg of 250 instead of 255
tell me if you have the same behavior than in your step 4 or a proper behavior.

[21:27:57][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[21:27:57][D][light:051]:   Brightness: 52%
[21:27:57][D][ble_adv_light:048]: Corrected brightness: 52%
[21:27:57][D][ble_adv_light:070]: ct: 333.000, br: 0.522
[21:27:57][D][ble_adv_light:079]: BleAdvLight::write_state - Requested brightness: 133
[21:27:57][D][zhijia:635]: UUID: '0xC630B1', tx: 33, Command: '0xAD', Args: [133,0,0]
[21:27:57][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.D6.3D.45.37.F1.04.77.A7.6E.1B.B5.7D.79.B0.B4.3E.0A.4A.5F.85.F6.9C.A9.19 (26)
[21:27:57][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[21:27:57][D][ble_adv_light:048]: Corrected brightness: 52%
[21:27:58][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising
[21:28:05][D][light:352]: 'bedroom_bedsidelamp_my' - Setting cold/warm white channels using white/color temperature values.
[21:28:05][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[21:28:05][D][light:066]:   Color temperature: 167.0 mireds
[21:28:05][D][light:071]:   Cold white: 100%, warm white: 1%
[21:28:05][D][ble_adv_light:048]: Corrected brightness: 52%
[21:28:05][D][ble_adv_light:070]: ct: 167.001, br: 0.522
[21:28:05][D][ble_adv_light:075]: BleAdvLight::write_state - Requested color temperature: 0
[21:28:05][D][zhijia:635]: UUID: '0xC630B1', tx: 34, Command: '0xAE', Args: [0,0,0]
[21:28:05][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.53.BB.45.37.F2.04.77.A7.6D.18.B5.7D.79.B3.B4.3D.0A.4A.5F.85.F6.9C.A9.19 (26)
[21:28:05][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[21:28:05][D][ble_adv_light:048]: Corrected brightness: 52%
[21:28:07][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising
[21:28:08][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[21:28:08][D][light:051]:   Brightness: 100%
[21:28:08][D][ble_adv_light:048]: Corrected brightness: 100%
[21:28:08][D][ble_adv_light:070]: ct: 167.001, br: 1.000
[21:28:08][D][ble_adv_light:079]: BleAdvLight::write_state - Requested brightness: 255
[21:28:08][D][zhijia:635]: UUID: '0xC630B1', tx: 35, Command: '0xAD', Args: [255,0,0]
[21:28:08][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.AE.47.47.35.F1.06.75.A5.6E.19.B7.7F.7B.B0.B4.3C.08.4A.5F.85.F6.9C.A9.19 (26)
[21:28:08][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[21:28:08][D][ble_adv_light:048]: Corrected brightness: 100%
[21:28:09][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising
[21:28:14][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[21:28:14][D][light:051]:   Brightness: 1%
[21:28:14][D][ble_adv_light:048]: Corrected brightness: 1%
[21:28:14][D][ble_adv_light:070]: ct: 167.001, br: 0.012
[21:28:14][D][ble_adv_light:079]: BleAdvLight::write_state - Requested brightness: 3
[21:28:14][D][zhijia:635]: UUID: '0xC630B1', tx: 36, Command: '0xAD', Args: [3,0,0]
[21:28:14][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.AA.44.BF.CD.0E.FE.8D.5D.91.E1.4F.87.83.4F.4B.C4.F0.4A.5F.85.F6.9C.A9.19 (26)
[21:28:14][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[21:28:14][D][ble_adv_light:048]: Corrected brightness: 1%
[21:28:15][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising
[21:28:28][D][button:010]: 'ct250' Pressed.
[21:28:28][D][ble_adv_button:016]: BleAdvButton::press_action called
[21:28:28][D][zhijia:635]: UUID: '0xC630B1', tx: 37, Command: '0xAE', Args: [250,0,0]
[21:28:28][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.51.BE.BD.CF.0D.FC.8F.5F.92.E0.4D.85.81.4C.4B.C5.F2.4A.5F.85.F6.9C.A9.19 (26)
[21:28:28][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising
[21:28:33][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[21:28:33][D][light:051]:   Brightness: 20%
[21:28:33][D][ble_adv_light:048]: Corrected brightness: 20%
[21:28:33][D][ble_adv_light:070]: ct: 167.001, br: 0.200
[21:28:33][D][ble_adv_light:079]: BleAdvLight::write_state - Requested brightness: 51
[21:28:33][D][zhijia:635]: UUID: '0xC630B1', tx: 38, Command: '0xAD', Args: [51,0,0]
[21:28:33][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.98.74.BD.CF.0E.FC.8F.5F.91.E3.4D.85.81.4F.4B.C6.F2.4A.5F.85.F6.9C.A9.19 (26)
[21:28:33][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[21:28:33][D][ble_adv_light:048]: Corrected brightness: 20%
[21:28:33][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising

If it does not work, perform Test 2:
set the light to cold
set the Brightness to 100%
press button "br1" 2 times in a raw (in less than 1 second). This simulates a potential behavior of the app consisting in sending 2 times the message (kind of start and end...)
set color temperature to warm
tell me if you have the same behavior than in your step 4 or a proper behavior.

[22:21:20][D][light:352]: 'bedroom_bedsidelamp_my' - Setting cold/warm white channels using white/color temperature values.
[22:21:20][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[22:21:20][D][light:066]:   Color temperature: 167.0 mireds
[22:21:20][D][light:071]:   Cold white: 100%, warm white: 1%
[22:21:20][D][ble_adv_light:048]: Corrected brightness: 44%
[22:21:20][D][ble_adv_light:070]: ct: 167.001, br: 0.439
[22:21:20][D][ble_adv_light:075]: BleAdvLight::write_state - Requested color temperature: 0
[22:21:20][D][zhijia:635]: UUID: '0xC630B1', tx: 16, Command: '0xAE', Args: [0,0,0]
[22:21:20][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.61.BB.77.05.F<IP_ADDRESS>.6D.2A.87.4F.4B.B3.B4.0F.38.4A.5F.85.F6.9C.A9.19 (26)
[22:21:20][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[22:21:20][D][ble_adv_light:048]: Corrected brightness: 44%
[22:21:20][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising
[22:21:23][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[22:21:23][D][light:051]:   Brightness: 57%
[22:21:23][D][ble_adv_light:048]: Corrected brightness: 57%
[22:21:23][D][ble_adv_light:070]: ct: 167.001, br: 0.569
[22:21:23][D][ble_adv_light:079]: BleAdvLight::write_state - Requested brightness: 145
[22:21:23][D][zhijia:635]: UUID: '0xC630B1', tx: 17, Command: '0xAD', Args: [145,0,0]
[22:21:23][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.F<IP_ADDRESS>.F<IP_ADDRESS>.6E.2B.85.4D.49.B0.B4.0E.3A.4A.5F.85.F6.9C.A9.19 (26)
[22:21:24][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[22:21:24][D][ble_adv_light:048]: Corrected brightness: 57%
[22:21:24][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising
[22:21:25][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[22:21:25][D][light:051]:   Brightness: 100%
[22:21:25][D][ble_adv_light:048]: Corrected brightness: 100%
[22:21:25][D][ble_adv_light:070]: ct: 167.001, br: 1.000
[22:21:25][D][ble_adv_light:079]: BleAdvLight::write_state - Requested brightness: 255
[22:21:25][D][zhijia:635]: UUID: '0xC630B1', tx: 18, Command: '0xAD', Args: [255,0,0]
[22:21:25][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.60.B8.89.FB.0E.C8.BB.6B.91.D7.79.B1.B5.4F.4B.F2.C6.4A.5F.85.F6.9C.A9.19 (26)
[22:21:26][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising
[22:21:33][D][button:010]: 'br1' Pressed.
[22:21:33][D][ble_adv_button:016]: BleAdvButton::press_action called
[22:21:33][D][zhijia:635]: UUID: '0xC630B1', tx: 19, Command: '0xAD', Args: [3,0,0]
[22:21:33][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.62.BB.77.05.F<IP_ADDRESS>.6E.29.87.4F.4B.B0.B4.0C.38.4A.5F.85.F6.9C.A9.19 (26)
[22:21:33][D][button:010]: 'br1' Pressed.
[22:21:33][D][ble_adv_button:016]: BleAdvButton::press_action called
[22:21:33][D][zhijia:635]: UUID: '0xC630B1', tx: 20, Command: '0xAD', Args: [3,0,0]
[22:21:34][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising
[22:21:34][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.9A.44.8F.FD.0E.CE.BD.6D.91.D1.7F.B7.B3.4F.4B.F4.C0.4A.5F.85.F6.9C.A9.19 (26)
[22:21:34][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising
[22:21:36][D][light:352]: 'bedroom_bedsidelamp_my' - Setting cold/warm white channels using white/color temperature values.
[22:21:36][W][light:227]: 'bedroom_bedsidelamp_my' - Color temperature value 333.00 is out of range [167.0 - 333.0]!
[22:21:36][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[22:21:36][D][light:066]:   Color temperature: 333.0 mireds
[22:21:36][D][light:071]:   Cold white: 0%, warm white: 100%
[22:21:36][D][ble_adv_light:048]: Corrected brightness: 100%
[22:21:36][D][ble_adv_light:070]: ct: 333.000, br: 1.000
[22:21:36][D][ble_adv_light:075]: BleAdvLight::write_state - Requested color temperature: 255
[22:21:36][D][zhijia:635]: UUID: '0xC630B1', tx: 21, Command: '0xAE', Args: [255,0,0]
[22:21:36][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.64.BB.8D.FF.0D.CC.BF.6F.92.D0.7D.B5.B1.4C.4B.F5.C2.4A.5F.85.F6.9C.A9.19 (26)
[22:21:36][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[22:21:36][D][ble_adv_light:048]: Corrected brightness: 100%
[22:21:36][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising
[22:21:44][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[22:21:44][D][light:051]:   Brightness: 1%
[22:21:44][D][ble_adv_light:048]: Corrected brightness: 1%
[22:21:44][D][ble_adv_light:070]: ct: 333.000, br: 0.012
[22:21:44][D][ble_adv_light:079]: BleAdvLight::write_state - Requested brightness: 3
[22:21:44][D][zhijia:635]: UUID: '0xC630B1', tx: 22, Command: '0xAD', Args: [3,0,0]
[22:21:44][D][ble_adv_controller:088]: bedroom_bedsidelamp_my - start advertising: 22.9D.98.44.8D.FF.0E.CC.BF.6F.91.D3.7D.B5.B1.4F.4B.F6.C2.4A.5F.85.F6.9C.A9.19 (26)
[22:21:44][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[22:21:44][D][ble_adv_light:048]: Corrected brightness: 1%
[22:21:44][D][ble_adv_controller:096]: bedroom_bedsidelamp_my - stop advertising

in both tests, after changing the color temperature, the brightness increases

This works nearly perfectly for my needs, thank you @NicoIIT (also, this has come just in time for when I ordered a fan from aliexpress). Only issue I'm facing at the moment is that if I tie the light with a configuration of adaptive lighting (https://github.com/basnijholt/adaptive-lighting) it seems that while the light comes on, it immediately turns off, however commands still appear to be sent as per the logs below
logs_fanlamppro-controller_logs.txt
I will adjust the settings of adaptive lighting, perhaps the brightness / mired config is not going to work for this light.
Also noted in the logs is the following warning:
[20:35:49][W][light:227]: 'Master Bedroom Main Light' - Color temperature value 333.00 is out of range [167.0 - 333.0]!

@pantherale0, from what I saw in the logs the component you are using is sending a lot of commands to the light in a very short time-frame, and this not recommended.
I updated the doc to highlight the technical limitations of this kind of lights due to the BLE Advertising technology they are using.
To make it work you will either need:

to decrease (a lot) the duration (the minimum recommended by the BLE standard is 20ms) but it may have consequences (see the doc)
to configure the adaptive-lighting component so that it sends updates less frequently
Hope you will manage to make it work!

Nice, yeah I had assumed it was sending too much too quickly and sending the controller into another universe. Thank you :slightly_smiling_face:
I pulled my controller apart earlier to see what sort of chips are inside (all I saw in the ad was a picture of an app so had assumed there was some tuya based chip inside as thats what we normally get). There are 4 pads exposed on the bottom of my controller, I'm assuming its for programming purposes but maybe there are some signals that can be sent/received over this (I'd suggest some UART protocol but probably too advanced for the chips on these).

With the above information in mind, I think I've got adaptive lighting working. In case anyone else comes across this, within the config for adaptive-lighting:
transition: 0 (disable transitions)
initial_transition: 0 (disable transitions)
min_color_temp: 3000 (167 mired)
max_color_temp: 6000 (333 mired)
sleep_transition: 0 (disable transitions)
detect_non_ha_changes: false (no point having this on as documented, HA won't be aware of external changes anyway)
seperate_turn_on_commands: true (allows us to set a delay between sent commands to overcome BLE shenanigans)
send_split_delay: 50 (wait 50ms after sending each command)
adapt_delay: 2 (waits 2s after turning the light on to start adaptations)
intercept: true (intercepts light.turn_on service calls so that the adaptive lighting controller will start work straight away)
multi_light_intercept: true (same as above, only needs to be set if multiple lights are configured in the controller)

@cRazyK67, I added the secondary light control for ZhiJia, based on the fact the name in the software would be the same than for FanLamp Pro (Aid, do not ask me why 😄). Could you please test and tell me if it is working ?
Concerning the flickering issue, the next steps to progress on this will be quite huge:

Capture real traffic from ZhiJia App when the scenario is executed
Implement un-whitening of ZhiJia encoding (whatever v0/v1 or v2) in order to decode the packets and see what is effectively generated by the ZhiJia phone app. @14roiron , @aronsky : any idea how to do that ?

Given the amount of work, that the problem was already pre-existing and that the fix is not in the direct scope of this PR, I would recommend that we open a dedicated issue for this to track investigation progresses and resolution.
Sorry for not being able to solve this issue within the scope of this change 😢.

@NicoIIT,

I added the secondary light control for ZhiJia, based on the fact the name in the software would be the same than for FanLamp Pro (Aid, do not ask me why 😄). Could you please test and tell me if it is working ?

Checked it, works great
My config:
ble_adv_controller:
- id: livingroom_sofa_chandelier
   encoding: zhijia
   variant: v2
   duration: 500
   reversed: true
   forced_id: 0xC630B4

light:
- platform: ble_adv_controller
   ble_adv_controller_id: livingroom_sofa_chandelier
   name: livingroom_sofa_chandelier
   default_transition_length: 0s
   min_brightness: 0%

 - platform: ble_adv_controller
   ble_adv_controller_id: livingroom_sofa_chandelier
   name: livingroom_sofa_chandelier_2
   secondary: true

Sorry for not being able to solve this issue within the scope of this change 😢.

The work of the chandelier suits me even in the form it is now.
As a temporary option, I can suggest a solution to add the “sand” option to the light source description and if it is True, then after changing the color temperature, resend the brightness as well.
Yes, this will not eliminate flicker, but it will make it more or less comfortable to switch color temperatures.

Thanks for the code, it work very well on my fanlight_v2, actually I've 5 similar lamp in my house so will test other later.  But now find something missing:

no light temperature control
no reverse fan control
the brightness entity and fan speed entity not find in HA, only the light on/off, fan on/off available.
no natural fan speed (that speed turn up and down randomly), but I think it is not important.

ble_adv_controller:

id: living_controller
encoding: fanlamp_pro
variant: v2
duration: 200
reversed: false
forced_id: 0

light:

platform: ble_adv_controller
ble_adv_controller_id: living_controller
name: Living Light
min_brightness: 21%

fan:

platform: ble_adv_controller
ble_adv_controller_id: living_controller
name: Living Fan
speed_count: 6
use_direction: true

button:

platform: ble_adv_controller
ble_adv_controller_id: living_controller
name: Pair
cmd: pair

@cRazyK67 , I just implemented the workaround you requested, hope it will help while we investigate the issue on the separated thread 😃

Also noted in the logs is the following warning:
[20:35:49][W][light:227]: 'Master Bedroom Main Light' - Color temperature value 333.00 is out of range [167.0 - 333.0]!

@pantherale0 , I opened an issue  to esphome for this.

Thanks!! it works perfectly!

@NicoIIT,

I just implemented the workaround you requested, hope it will help while we investigate the issue on the separated thread 😃
EDIT: I would also advise to try to decrease the duration to 100ms, this may help smoother changes on the light side.

The combination of duration: 200ms and send_brightness_after_color_temperature_change: true works amazingly.
The flickering is slightly noticeable only at brightnesses below 20%, after that the flickering is visually unnoticeable.
On my chandelier with two light sources, controlled by FanLamp Pro v3, I noticed the followiing operation nuance : separately, both sources turn on and off perfectly, but if you turn on both sources and turn off the first source, then both sources are physically turned off.
In this case  second source switch in HA remains on.
The same behavior is observed in the native application, i.e. this is a feature of the lamp driver.
Is it possible to implement the following algorithm in Home Assistant: if the first source of the chandelier turns off, then forcibly turn off the second (provided that it is specified in the configuration).
For greater flexibility, this can be implemented through the setting "turnoff_secondary_with_main"

@cRazyK67 , For the first request, there is no need to implement something in the component, it is easy to benefit from esphome light automation features, this can be done by giving an id to your secondary light and switch it off when the main is switched off:
  - platform: ble_adv_controller
    ble_adv_controller_id: my_controller
    name: Main Light
    on_turn_off:
      then:
        light.turn_off: secondary_light
  - platform: ble_adv_controller
    ble_adv_controller_id:my_controller
    id: secondary_light
    name: Secondary Light
    secondary: true

Note that you can also implement the same at 'switch on' if you want 😄
For the second part, I am reviewing currently the pairing process to simplify it, I will integrate your requirement to the solution design, still the work is a bit heavy as it includes the 'sequential multi ble advertising' feature, should be ready in the coming days.
As a workaround to allow the pairing you can still process this way:

increase the duration to 10000 (10s)
process with the pairing, knowing that a press on the pair button will advertise the command for 10s
revert the duration to 200 once the pairing is OK

I think I will add a FAQ to the doc, you are probably not be the only one with the same questions / problems !

@NicoIIT I forgot about the possibility of event processing in ESPHome :(
Thank you very much for the prompt response.

@cRazyK67 , for the oscillation functionality, from the software I see 2 different possibilities, one is "Swing", the other is "Sway" and I would need you to tell me which one is the relevant one.
Could you please add the following 4 buttons and tell me which ones are working for you?
button:
- platform: ble_adv_controller
  ble_adv_controller_id: bedroom_bedsidelamp_my
  name: Sway ON
  cmd: custom
  args: [22,0,1,0,0]
- platform: ble_adv_controller
  ble_adv_controller_id: bedroom_bedsidelamp_my
  name: Sway OFF
  cmd: custom
  args: [22,0,0,0,0]
- platform: ble_adv_controller
  ble_adv_controller_id: bedroom_bedsidelamp_my
  name: Swing ON
  cmd: custom
  args: [176,0,1,0,0]
- platform: ble_adv_controller
  ble_adv_controller_id: bedroom_bedsidelamp_my
  name: Swing OFF
  cmd: custom
  args: [176,0,0,0,0]

@NicoIIT,

Could you please add the following 4 buttons and tell me which ones are working for you?
Sway On/Off is work for me

@cRazyK67, there is one command which starts being advertised at 22:10:06 and finishes being advertised at 22:10:16, so it works.
If it does not allow the pairing it is maybe due to the wrong variant used, you should try other variants, as v1a or v1b.

Thank you very much! It works for me with two lights (zhijia v0 and zhijia v1). The only problem is with flickering on zhijia v0 (zhijia v1 everything is fine!) when switching to warm light. (the chandelier starts to smoothly switch from warm to cold light, and so constantly, until I switch to any other mode)

@Privet-zdarova , Thanks a lot for the validation of ZhiJia v0 and v1 !!!
For the flickering, we put in place a workaround with the help of @cRazyK67 :

add 'send_brightness_after_color_temperature_change: true' to your light
set your 'duration' to 200 max

An issue is opened for the final solution but we need to understand how the phone app is handling this...

@NicoIIT I have error wits compile
INFO ESPHome 2024.7.2
INFO Reading configuration /config/esphome/esp-childroom-chandelier.yaml...
ERROR Unable to load component ble_adv_controller:
Traceback (most recent call last):
  File "/esphome/esphome/loader.py", line 176, in _lookup_module
    module = importlib.import_module(f"esphome.components.{domain}")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 936, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1074, in get_code
  File "<frozen importlib._bootstrap_external>", line 1004, in source_to_code
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/data/external_components/7652980b/components/ble_adv_controller/__init__.py", line 71
    cv.Optional(CONF_DURATION, default=200): cv.All(cv.positive_int, cv.Range(min=100, max=500))
                                             ^^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?
Failed config

@cRazyK67 , Oups ! corrected!

@NicoIIT I have multiple warnings when executing any command.
The command itself is not executed by the chandelier
[21:51:10][D][light:051]:   Brightness: 53%
[21:51:10][D][ble_adv_light:063]: Cold: 255, Warm: 0, Brightness: 135
[21:51:10][D][zhijia:655]: Zhi Jia - v2 - UUID: '0xC630B1', tx: 4, Command: '0xAD', Args: [135,0,0]
[21:51:10][D][ble_adv_controller:107]: bedroom_bedsidelamp_my_controller - start advertising: 22.9D.0E.C0.9F.ED.0E.DE.AD.7D.91.C1.6F.A7.A3.4F.4B.E4.D0.4A.5F.85.F6.9C.A9.19 (26)
[21:51:10][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[21:51:10][D][ble_adv_light:063]: Cold: 255, Warm: 0, Brightness: 135
[21:51:11][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:11][W][component:238]: Components should block for at most 30 ms.
[21:51:11][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:11][W][component:238]: Components should block for at most 30 ms.
[21:51:11][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:11][W][component:238]: Components should block for at most 30 ms.
[21:51:11][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:11][W][component:238]: Components should block for at most 30 ms.
[21:51:11][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:11][W][component:238]: Components should block for at most 30 ms.
[21:51:11][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:11][W][component:238]: Components should block for at most 30 ms.
[21:51:11][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:11][W][component:238]: Components should block for at most 30 ms.
[21:51:11][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:11][W][component:238]: Components should block for at most 30 ms.
[21:51:12][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:12][W][component:238]: Components should block for at most 30 ms.
[21:51:12][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:12][W][component:238]: Components should block for at most 30 ms.
[21:51:12][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:12][W][component:238]: Components should block for at most 30 ms.
[21:51:12][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:12][W][component:238]: Components should block for at most 30 ms.
[21:51:12][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:12][W][component:238]: Components should block for at most 30 ms.
[21:51:12][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:12][W][component:238]: Components should block for at most 30 ms.
[21:51:12][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:12][W][component:238]: Components should block for at most 30 ms.
[21:51:12][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:12][W][component:238]: Components should block for at most 30 ms.
[21:51:13][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:13][W][component:238]: Components should block for at most 30 ms.
[21:51:13][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:13][W][component:238]: Components should block for at most 30 ms.
[21:51:13][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:13][W][component:238]: Components should block for at most 30 ms.
[21:51:13][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:13][W][component:238]: Components should block for at most 30 ms.
[21:51:13][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:13][W][component:238]: Components should block for at most 30 ms.
[21:51:13][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:13][W][component:238]: Components should block for at most 30 ms.
[21:51:13][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:13][W][component:238]: Components should block for at most 30 ms.
[21:51:13][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:51:13][W][component:238]: Components should block for at most 30 ms.

[21:52:12][D][fan:021]: 'childroom_chandelier_fan' - Setting:
[21:52:12][D][fan:024]:   State: ON
[21:52:12][D][fan:030]:   Speed: 6
[21:52:12][D][ble_adv_fan:041]: BleAdvFan::control - Setting ON with speed 6
[21:52:12][D][fanlamp_pro:295]: FanLamp - v3 - ID: '0x960D13A2', tx: 2, Command: '0x31', Args: [0,32,6,0]
[21:52:12][D][fan:120]: 'childroom_chandelier_fan' - Sending state:
[21:52:12][D][fan:121]:   State: ON
[21:52:12][D][fan:123]:   Speed: 6
[21:52:12][D][fan:126]:   Oscillating: NO
[21:52:12][D][fan:129]:   Direction: FORWARD
[21:52:12][D][ble_adv_controller:107]: childroom_chandelier_controller - start advertising: F<IP_ADDRESS>.0A.E8.31.BE.8E.A0.23.AD.A9.FA.C2.0E.BB.5A.9E.35.1C.0F.29.31.F8.FF (26)
[21:52:13][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:52:13][W][component:238]: Components should block for at most 30 ms.
[21:52:13][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:52:13][W][component:238]: Components should block for at most 30 ms.
[21:52:13][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:52:13][W][component:238]: Components should block for at most 30 ms.
[21:52:13][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:52:14][W][component:238]: Components should block for at most 30 ms.
[21:52:14][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:52:14][W][component:238]: Components should block for at most 30 ms.
[21:52:14][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:52:14][W][component:238]: Components should block for at most 30 ms.
[21:52:14][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:52:18][W][component:238]: Components should block for at most 30 ms.
[21:52:18][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:52:18][W][component:238]: Components should block for at most 30 ms.
[21:52:18][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:52:18][W][component:238]: Components should block for at most 30 ms.
[21:52:18][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:52:18][W][component:238]: Components should block for at most 30 ms.
[21:52:18][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:52:18][W][component:238]: Components should block for at most 30 ms.
[21:52:18][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:52:18][W][component:238]: Components should block for at most 30 ms.
[21:52:18][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:52:18][W][component:238]: Components should block for at most 30 ms.
[21:52:24][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:52:24][W][component:238]: Components should block for at most 30 ms.
[21:52:24][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[21:52:24][W][component:238]: Components should block for at most 30 ms.

@cRazyK67 , I do not have such strange behavior at all on my side, I will need some input from you to understand from where the issue is coming:

Did it started just after the startup, meaning no command at all worked ?
I will need the full config
I need the logs of the very first transaction processed.
It is probably a difference in the bluetooth performances of the ESP32 board, I have an hard-coded value on my side that I will need to make dynamic, or review the process to adapt it.
Thanks in advance

All works fine for me so far @NicoIIT - although I also have the same "log spam" above but doesn't really bother me that much to be honest.
logs_fanlamppro-controller_run.txt

@NicoIIT,

Did it started just after the startup, meaning no command at all worked ?

This behavior is observed after performing any action in the HA (turning the light on/off, changing the brightness or color temperature).
The chandeliers themselves do not respond to commands (they stopped working from the component, although they work from native applications).

I will need the full config

esphome:
  name: esp-childroom-chandelier
  friendly_name: ESP-ChildRoom-Chandelier

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:
 # level: verbose

# Enable Home Assistant API
api:
  encryption:
    key: "*****************************"

ota:
  - platform: esphome
    password: "**************************************"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp-Childroom-Chandelier"
    password: "***************************"

external_components:
 source: github://NicoIIT/esphome-components
 refresh: 10s
# --------------------------------------------------------------
ble_adv_controller:
# --------------------------------------------------------------
 - id: bedroom_bedsidelamp_my_controller
   encoding: zhijia
   variant: v2
   duration: 100
   forced_id: 0xC630B1
# --------------------------------------------------------------
 - id: bedroom_bedsidelamp_notmy_controller
   encoding: zhijia
   variant: v2
   duration: 100
   forced_id: 0xC630B2
# --------------------------------------------------------------
 - id: livingroom_chandelier_controller
   encoding: zhijia
   variant: v2
   duration: 250
   forced_id: 0xC630B3
# --------------------------------------------------------------
 - id: livingroom_sofa_chandelier_controller
   encoding: zhijia
   variant: v2
   duration: 250
   reversed: true
   forced_id: 0xC630B4
# --------------------------------------------------------------
 - id: bedroom_chandelier_controller
   encoding: fanlamp_pro
   variant: v3
   #duration: 250
   reversed: false
   forced_id: 0
# --------------------------------------------------------------
 - id: childroom_chandelier_controller
   encoding: fanlamp_pro
   variant: v3
   #duration: 100
   reversed: false
   forced_id: 0x960D13A2
# --------------------------------------------------------------
light:
# --------------------------------------------------------------
 - platform: ble_adv_controller
   ble_adv_controller_id: bedroom_bedsidelamp_my_controller
   id: bedroom_bedsidelamp_my
   name: bedroom_bedsidelamp_my
   default_transition_length: 0s
   min_brightness: 0%
   #send_brightness_after_color_temperature_change: true
# --------------------------------------------------------------
 - platform: ble_adv_controller
   ble_adv_controller_id: bedroom_bedsidelamp_notmy_controller
   id: bedroom_bedsidelamp_notmy
   name: bedroom_bedsidelamp_notmy
   default_transition_length: 0s
   min_brightness: 0%
   #send_brightness_after_color_temperature_change: true
# --------------------------------------------------------------
 - platform: ble_adv_controller
   ble_adv_controller_id: livingroom_chandelier_controller
   id: livingroom_chandelier
   name: livingroom_chandelier
   default_transition_length: 0s
   min_brightness: 0%
# --------------------------------------------------------------
 - platform: ble_adv_controller
   ble_adv_controller_id: livingroom_sofa_chandelier_controller
   id: livingroom_sofa_chandelier_1
   name: livingroom_sofa_chandelier_1
   default_transition_length: 0s
   min_brightness: 0%
   on_turn_off:
    then:
     light.turn_off: livingroom_sofa_chandelier_2
# --------------------------------------------------------------
 - platform: ble_adv_controller
   ble_adv_controller_id: livingroom_sofa_chandelier_controller
   id: livingroom_sofa_chandelier_2
   name: livingroom_sofa_chandelier_2
   secondary: true
# --------------------------------------------------------------
 - platform: ble_adv_controller
   ble_adv_controller_id: bedroom_chandelier_controller
   id: bedroom_chandelier
   name: bedroom_chandelier
   min_brightness: 0%
# --------------------------------------------------------------
 - platform: ble_adv_controller
   ble_adv_controller_id: childroom_chandelier_controller
   id: childroom_chandelier
   name: childroom_chandelier
   min_brightness: 0%
# --------------------------------------------------------------
fan:
  - platform: ble_adv_controller
    ble_adv_controller_id: childroom_chandelier_controller
    id: childroom_chandelier_fan
    name: childroom_chandelier_fan
    speed_count: 6
    use_direction: true
    use_oscillation: true

button:
#  - platform: ble_adv_controller
#    ble_adv_controller_id: bedroom_bedsidelamp_my
#    name: Pair bedroom_bedsidelamp_my
#    cmd: pair

#  - platform: ble_adv_controller
#    ble_adv_controller_id: bedroom_bedsidelamp_notmy
#    name: Pair bedroom_bedsidelamp_notmy
#    cmd: pair

#  - platform: ble_adv_controller
#    ble_adv_controller_id: livingroom_chandelier
#    name: Pair livingroom_chandelier
#    cmd: pair

#  - platform: ble_adv_controller
#    ble_adv_controller_id: livingroom_sofa_chandelier
#    name: Pair livingroom_sofa_chandelier
#    cmd: pair

#  - platform: ble_adv_controller
#    ble_adv_controller_id: livingroom_sofa_chandelier
#    name: on livingroom_sofa_chandelier
#    cmd: light_wcolor

#  - platform: ble_adv_controller
#    ble_adv_controller_id: livingroom_sofa_chandelier
#    name: off livingroom_sofa_chandelier
#    cmd: light_wcolor

- platform: ble_adv_controller
  ble_adv_controller_id: bedroom_chandelier_controller
  name: Pair bedroom_chandelier
  cmd: pair

I need the logs of the very first transaction processed.

INFO ESPHome 2024.7.2
INFO Reading configuration /config/esphome/esp-childroom-chandelier.yaml...
INFO Updating https://github.com/NicoIIT/esphome-components.git@None
INFO Starting log output from <IP_ADDRESS> using esphome API
INFO Successfully connected to esp-childroom-chandelier @ <IP_ADDRESS> in 0.078s
INFO Successful handshake with esp-childroom-chandelier @ <IP_ADDRESS> in 0.090s
[22:54:24][I][app:100]: ESPHome version 2024.7.2 compiled on Jul 28 2024, 22:08:42
[22:54:24][C][wifi:599]: WiFi:
[22:54:24][C][wifi:427]:   Local MAC:
[22:54:24][C][wifi:432]:   SSID: [redacted]
[22:54:24][C][wifi:435]:   IP Address: <IP_ADDRESS>
[22:54:24][C][wifi:439]:   BSSID: [redacted]
[22:54:24][C][wifi:440]:   Hostname: 'esp-childroom-chandelier'
[22:54:24][C][wifi:442]:   Signal strength: -66 dB ▂▄▆█
[22:54:24][C][wifi:446]:   Channel: 3
[22:54:24][C][wifi:447]:   Subnet: <IP_ADDRESS>
[22:54:24][C][wifi:448]:   Gateway: <IP_ADDRESS>
[22:54:24][C][wifi:449]:   DNS1: <IP_ADDRESS>
[22:54:24][C][wifi:450]:   DNS2: <IP_ADDRESS>
[22:54:24][C][logger:185]: Logger:
[22:54:24][C][logger:186]:   Level: DEBUG
[22:54:24][C][logger:188]:   Log Baud Rate: 115200
[22:54:24][C][logger:189]:   Hardware UART: UART0
[22:54:24][C][light:103]: Light 'bedroom_bedsidelamp_my'
[22:54:24][C][light:105]:   Default Transition Length: 0.0s
[22:54:24][C][light:106]:   Gamma Correct: 2.80
[22:54:24][C][light:103]: Light 'bedroom_bedsidelamp_notmy'
[22:54:24][C][light:105]:   Default Transition Length: 0.0s
[22:54:24][C][light:106]:   Gamma Correct: 2.80
[22:54:24][C][light:103]: Light 'livingroom_chandelier'
[22:54:24][C][light:105]:   Default Transition Length: 0.0s
[22:54:24][C][light:106]:   Gamma Correct: 2.80
[22:54:24][C][light:103]: Light 'livingroom_sofa_chandelier_1'
[22:54:24][C][light:105]:   Default Transition Length: 0.0s
[22:54:24][C][light:106]:   Gamma Correct: 2.80
[22:54:24][C][light:103]: Light 'livingroom_sofa_chandelier_2'
[22:54:24][C][light:103]: Light 'bedroom_chandelier'
[22:54:24][C][light:105]:   Default Transition Length: 0.0s
[22:54:24][C][light:106]:   Gamma Correct: 2.80
[22:54:24][C][light:103]: Light 'childroom_chandelier'
[22:54:24][C][light:105]:   Default Transition Length: 0.0s
[22:54:24][C][light:106]:   Gamma Correct: 2.80
[22:54:24][C][ble_adv_controller:035]: BleAdvController 'bedroom_bedsidelamp_my_controller'
[22:54:24][C][ble_adv_controller:036]:   Hash ID 'C630B1'
[22:54:24][C][ble_adv_controller:037]:   Transmission Min Duration: 100 ms
[22:54:24][C][ble_adv_controller:038]:   Transmission Max Duration: 3000 ms
[22:54:24][C][ble_adv_controller:035]: BleAdvController 'bedroom_bedsidelamp_notmy_controller'
[22:54:24][C][ble_adv_controller:036]:   Hash ID 'C630B2'
[22:54:24][C][ble_adv_controller:037]:   Transmission Min Duration: 100 ms
[22:54:24][C][ble_adv_controller:038]:   Transmission Max Duration: 3000 ms
[22:54:24][C][ble_adv_controller:035]: BleAdvController 'livingroom_chandelier_controller'
[22:54:24][C][ble_adv_controller:036]:   Hash ID 'C630B3'
[22:54:24][C][ble_adv_controller:037]:   Transmission Min Duration: 250 ms
[22:54:24][C][ble_adv_controller:038]:   Transmission Max Duration: 3000 ms
[22:54:24][C][ble_adv_controller:035]: BleAdvController 'livingroom_sofa_chandelier_controller'
[22:54:24][C][ble_adv_controller:036]:   Hash ID 'C630B4'
[22:54:24][C][ble_adv_controller:037]:   Transmission Min Duration: 250 ms
[22:54:24][C][ble_adv_controller:038]:   Transmission Max Duration: 3000 ms
[22:54:24][C][ble_adv_controller:035]: BleAdvController 'bedroom_chandelier_controller'
[22:54:24][C][ble_adv_controller:036]:   Hash ID '609D199A'
[22:54:24][C][ble_adv_controller:037]:   Transmission Min Duration: 200 ms
[22:54:24][C][ble_adv_controller:038]:   Transmission Max Duration: 3000 ms
[22:54:24][C][ble_adv_controller:035]: BleAdvController 'childroom_chandelier_controller'
[22:54:24][C][ble_adv_controller:036]:   Hash ID '960D13A2'
[22:54:24][C][ble_adv_controller:037]:   Transmission Min Duration: 200 ms
[22:54:24][C][ble_adv_controller:038]:   Transmission Max Duration: 3000 ms
[22:54:24][C][ble_adv_light:024]: BleAdvLight
[22:54:24][C][ble_adv_light:126]:   Controller 'bedroom_bedsidelamp_my_controller'
[22:54:24][C][ble_adv_light:127]:   Type '0x0100'
[22:54:24][C][ble_adv_light:128]:   Index '0'
[22:54:24][C][ble_adv_light:026]:   Base Light 'bedroom_bedsidelamp_my'
[22:54:24][C][ble_adv_light:027]:   Cold White Temperature: 167.000000 mireds
[22:54:24][C][ble_adv_light:028]:   Warm White Temperature: 333.000000 mireds
[22:54:24][C][ble_adv_light:029]:   Minimum Brightness: 0x00
[22:54:24][C][ble_adv_light:024]: BleAdvLight
[22:54:24][C][ble_adv_light:126]:   Controller 'bedroom_bedsidelamp_notmy_controller'
[22:54:24][C][ble_adv_light:127]:   Type '0x0100'
[22:54:24][C][ble_adv_light:128]:   Index '0'
[22:54:24][C][ble_adv_light:026]:   Base Light 'bedroom_bedsidelamp_notmy'
[22:54:24][C][ble_adv_light:027]:   Cold White Temperature: 167.000000 mireds
[22:54:24][C][ble_adv_light:028]:   Warm White Temperature: 333.000000 mireds
[22:54:24][C][ble_adv_light:029]:   Minimum Brightness: 0x00
[22:54:24][C][ble_adv_light:024]: BleAdvLight
[22:54:24][C][ble_adv_light:126]:   Controller 'livingroom_chandelier_controller'
[22:54:24][C][ble_adv_light:127]:   Type '0x0100'
[22:54:24][C][ble_adv_light:128]:   Index '0'
[22:54:24][C][ble_adv_light:026]:   Base Light 'livingroom_chandelier'
[22:54:24][C][ble_adv_light:027]:   Cold White Temperature: 167.000000 mireds
[22:54:24][C][ble_adv_light:028]:   Warm White Temperature: 333.000000 mireds
[22:54:24][C][ble_adv_light:029]:   Minimum Brightness: 0x00
[22:54:24][C][ble_adv_light:024]: BleAdvLight
[22:54:24][C][ble_adv_light:126]:   Controller 'livingroom_sofa_chandelier_controller'
[22:54:24][C][ble_adv_light:127]:   Type '0x0100'
[22:54:24][C][ble_adv_light:128]:   Index '0'
[22:54:24][C][ble_adv_light:026]:   Base Light 'livingroom_sofa_chandelier_1'
[22:54:24][C][ble_adv_light:027]:   Cold White Temperature: 167.000000 mireds
[22:54:24][C][ble_adv_light:028]:   Warm White Temperature: 333.000000 mireds
[22:54:24][C][ble_adv_light:029]:   Minimum Brightness: 0x00
[22:54:24][C][ble_adv_light:088]: BleAdvSecLight
[22:54:24][C][ble_adv_light:126]:   Controller 'livingroom_sofa_chandelier_controller'
[22:54:24][C][ble_adv_light:127]:   Type '0x0100'
[22:54:24][C][ble_adv_light:128]:   Index '0'
[22:54:24][C][ble_adv_light:090]:   Base Light 'livingroom_sofa_chandelier_2'
[22:54:24][C][ble_adv_light:024]: BleAdvLight
[22:54:24][C][ble_adv_light:126]:   Controller 'bedroom_chandelier_controller'
[22:54:24][C][ble_adv_light:127]:   Type '0x0100'
[22:54:24][C][ble_adv_light:128]:   Index '0'
[22:54:24][C][ble_adv_light:026]:   Base Light 'bedroom_chandelier'
[22:54:24][C][ble_adv_light:027]:   Cold White Temperature: 167.000000 mireds
[22:54:24][C][ble_adv_light:028]:   Warm White Temperature: 333.000000 mireds
[22:54:24][C][ble_adv_light:029]:   Minimum Brightness: 0x00
[22:54:24][C][ble_adv_light:024]: BleAdvLight
[22:54:24][C][ble_adv_light:126]:   Controller 'childroom_chandelier_controller'
[22:54:24][C][ble_adv_light:127]:   Type '0x0100'
[22:54:24][C][ble_adv_light:128]:   Index '0'
[22:54:24][C][ble_adv_light:026]:   Base Light 'childroom_chandelier'
[22:54:24][C][ble_adv_light:027]:   Cold White Temperature: 167.000000 mireds
[22:54:24][C][ble_adv_light:028]:   Warm White Temperature: 333.000000 mireds
[22:54:24][C][ble_adv_light:029]:   Minimum Brightness: 0x00
[22:54:24][C][ble_adv_fan:022]: BleAdvFan 'childroom_chandelier_fan'
[22:54:24][C][ble_adv_fan:126]:   Controller 'childroom_chandelier_controller'
[22:54:24][C][ble_adv_fan:127]:   Type '0x0100'
[22:54:24][C][ble_adv_fan:128]:   Index '0'
[22:54:24][C][ble_adv_button:011]: BleAdvButton 'Pair bedroom_chandelier'
[22:54:24][C][ble_adv_button:126]:   Controller 'bedroom_chandelier_controller'
[22:54:24][C][ble_adv_button:127]:   Type '0x0100'
[22:54:24][C][ble_adv_button:128]:   Index '0'
[22:54:24][C][mdns:116]: mDNS:
[22:54:24][C][mdns:117]:   Hostname: esp-childroom-chandelier
[22:54:24][C][esphome.ota:073]: Over-The-Air updates:
[22:54:24][C][esphome.ota:074]:   Address: esp-childroom-chandelier.local:3232
[22:54:24][C][esphome.ota:075]:   Version: 2
[22:54:24][C][esphome.ota:078]:   Password configured
[22:54:24][C][safe_mode:018]: Safe Mode:
[22:54:24][C][safe_mode:020]:   Boot considered successful after 60 seconds
[22:54:24][C][safe_mode:021]:   Invoke after 10 boot attempts
[22:54:24][C][safe_mode:023]:   Remain in safe mode for 300 seconds
[22:54:24][C][api:139]: API Server:
[22:54:24][C][api:140]:   Address: esp-childroom-chandelier.local:6053
[22:54:24][C][api:142]:   Using noise encryption: YES
[22:54:37][D][fan:021]: 'childroom_chandelier_fan' - Setting:
[22:54:37][D][fan:024]:   State: ON
[22:54:37][D][ble_adv_fan:041]: BleAdvFan::control - Setting ON with speed 6
[22:54:37][D][fanlamp_pro:295]: FanLamp - v3 - ID: '0x960D13A2', tx: 4, Command: '0x31', Args: [0,32,6,0]
[22:54:37][D][fan:120]: 'childroom_chandelier_fan' - Sending state:
[22:54:37][D][fan:121]:   State: ON
[22:54:37][D][fan:123]:   Speed: 6
[22:54:37][D][fan:126]:   Oscillating: NO
[22:54:37][D][fan:129]:   Direction: FORWARD
[22:54:37][D][ble_adv_controller:107]: childroom_chandelier_controller - start advertising: F<IP_ADDRESS>.0B.9E.DA.CF.EC.F4.03.BC.3B.C9.1C.FC.07.AF.3A.41.70.2D.3F.D4.63.4B (26)
[22:54:37][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:37][W][component:238]: Components should block for at most 30 ms.
[22:54:38][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:38][W][component:238]: Components should block for at most 30 ms.
[22:54:38][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:38][W][component:238]: Components should block for at most 30 ms.
[22:54:38][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:38][W][component:238]: Components should block for at most 30 ms.
[22:54:38][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:38][W][component:238]: Components should block for at most 30 ms.
[22:54:38][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:38][W][component:238]: Components should block for at most 30 ms.
[22:54:38][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:38][W][component:238]: Components should block for at most 30 ms.
[22:54:38][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:38][W][component:238]: Components should block for at most 30 ms.
[22:54:38][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:38][W][component:238]: Components should block for at most 30 ms.
[22:54:39][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:39][W][component:238]: Components should block for at most 30 ms.
[22:54:39][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:39][W][component:238]: Components should block for at most 30 ms.
[22:54:39][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:39][W][component:238]: Components should block for at most 30 ms.
[22:54:39][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:39][W][component:238]: Components should block for at most 30 ms.
[22:54:39][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:39][W][component:238]: Components should block for at most 30 ms.
[22:54:39][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:39][W][component:238]: Components should block for at most 30 ms.
[22:54:39][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:39][W][component:238]: Components should block for at most 30 ms.
[22:54:39][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:39][W][component:238]: Components should block for at most 30 ms.
[22:54:40][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:40][W][component:238]: Components should block for at most 30 ms.
[22:54:40][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:40][W][component:238]: Components should block for at most 30 ms.
[22:54:40][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:40][W][component:238]: Components should block for at most 30 ms.
[22:54:40][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:40][W][component:238]: Components should block for at most 30 ms.
[22:54:40][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:40][W][component:238]: Components should block for at most 30 ms.
[22:54:40][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:40][W][component:238]: Components should block for at most 30 ms.
[22:54:40][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:40][W][component:238]: Components should block for at most 30 ms.
[22:54:40][D][ble_adv_controller:119]: childroom_chandelier_controller - stop advertising
[22:54:41][D][fan:021]: 'childroom_chandelier_fan' - Setting:
[22:54:41][D][fan:024]:   State: OFF
[22:54:41][D][ble_adv_fan:050]: BleAdvFan::control - Setting OFF
[22:54:41][D][fanlamp_pro:295]: FanLamp - v3 - ID: '0x960D13A2', tx: 5, Command: '0x31', Args: [0,32,0,0]
[22:54:41][D][fan:120]: 'childroom_chandelier_fan' - Sending state:
[22:54:41][D][fan:121]:   State: OFF
[22:54:41][D][fan:123]:   Speed: 6
[22:54:41][D][fan:126]:   Oscillating: NO
[22:54:41][D][fan:129]:   Direction: FORWARD
[22:54:41][D][ble_adv_controller:107]: childroom_chandelier_controller - start advertising: F<IP_ADDRESS>.33.B8.2E.B0.8E.2A.A6.5F.C0.3D.99.5E.BC.D6.B<IP_ADDRESS>.2B.A5.45.35 (26)
[22:54:41][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:41][W][component:238]: Components should block for at most 30 ms.
[22:54:42][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:42][W][component:238]: Components should block for at most 30 ms.
[22:54:42][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:42][W][component:238]: Components should block for at most 30 ms.
[22:54:42][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:42][W][component:238]: Components should block for at most 30 ms.
[22:54:42][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:42][W][component:238]: Components should block for at most 30 ms.
[22:54:42][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:42][W][component:238]: Components should block for at most 30 ms.
[22:54:42][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:42][W][component:238]: Components should block for at most 30 ms.
[22:54:42][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:42][W][component:238]: Components should block for at most 30 ms.
[22:54:42][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:42][W][component:238]: Components should block for at most 30 ms.
[22:54:43][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:43][W][component:238]: Components should block for at most 30 ms.
[22:54:43][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:43][W][component:238]: Components should block for at most 30 ms.
[22:54:43][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:43][W][component:238]: Components should block for at most 30 ms.
[22:54:43][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:43][W][component:238]: Components should block for at most 30 ms.
[22:54:43][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:43][W][component:238]: Components should block for at most 30 ms.
[22:54:43][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:43][W][component:238]: Components should block for at most 30 ms.
[22:54:43][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:43][W][component:238]: Components should block for at most 30 ms.
[22:54:43][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:43][W][component:238]: Components should block for at most 30 ms.
[22:54:43][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:43][W][component:238]: Components should block for at most 30 ms.
[22:54:44][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:44][W][component:238]: Components should block for at most 30 ms.
[22:54:44][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:44][W][component:238]: Components should block for at most 30 ms.
[22:54:44][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:44][W][component:238]: Components should block for at most 30 ms.
[22:54:44][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:44][W][component:238]: Components should block for at most 30 ms.
[22:54:44][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:44][W][component:238]: Components should block for at most 30 ms.
[22:54:44][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:44][W][component:238]: Components should block for at most 30 ms.
[22:54:44][D][ble_adv_controller:119]: childroom_chandelier_controller - stop advertising
[22:54:47][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[22:54:47][D][light:047]:   State: ON
[22:54:47][D][ble_adv_light:043]: BleAdvLight::write_state - Switch ON
[22:54:47][D][zhijia:655]: Zhi Jia - v2 - UUID: '0xC630B1', tx: 3, Command: '0xA5', Args: [0,0,0]
[22:54:47][D][ble_adv_light:063]: Cold: 255, Warm: 0, Brightness: 255
[22:54:47][D][zhijia:655]: Zhi Jia - v2 - UUID: '0xC630B1', tx: 4, Command: '0xAD', Args: [255,0,0]
[22:54:47][D][ble_adv_controller:107]: bedroom_bedsidelamp_my_controller - start advertising: 22.9D.79.B0.6F.1D.F9.2E.5D.8D.66.39.9F.57.53.B8.B4.1C.20.4A.5F.85.F6.9C.A9.19 (26)
[22:54:47][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[22:54:47][D][ble_adv_light:063]: Cold: 255, Warm: 0, Brightness: 255
[22:54:47][D][ble_adv_controller:119]: bedroom_bedsidelamp_my_controller - stop advertising
[22:54:47][D][ble_adv_controller:107]: bedroom_bedsidelamp_my_controller - start advertising: 22.9D.76.B8.9F.ED.0E.DE.AD.7D.91.C1.6F.A7.A3.4F.4B.E4.D0.4A.5F.85.F6.9C.A9.19 (26)
[22:54:47][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:47][W][component:238]: Components should block for at most 30 ms.
[22:54:47][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:47][W][component:238]: Components should block for at most 30 ms.
[22:54:48][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:48][W][component:238]: Components should block for at most 30 ms.
[22:54:48][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:48][W][component:238]: Components should block for at most 30 ms.
[22:54:48][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:48][W][component:238]: Components should block for at most 30 ms.
[22:54:48][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:48][W][component:238]: Components should block for at most 30 ms.
[22:54:48][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:48][W][component:238]: Components should block for at most 30 ms.
[22:54:48][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:48][W][component:238]: Components should block for at most 30 ms.
[22:54:48][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:48][W][component:238]: Components should block for at most 30 ms.
[22:54:48][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:48][W][component:238]: Components should block for at most 30 ms.
[22:54:49][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:49][W][component:238]: Components should block for at most 30 ms.
[22:54:49][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:49][W][component:238]: Components should block for at most 30 ms.
[22:54:49][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:49][W][component:238]: Components should block for at most 30 ms.
[22:54:49][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:49][W][component:238]: Components should block for at most 30 ms.
[22:54:49][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:49][W][component:238]: Components should block for at most 30 ms.
[22:54:49][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:49][W][component:238]: Components should block for at most 30 ms.
[22:54:49][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:49][W][component:238]: Components should block for at most 30 ms.
[22:54:49][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:49][W][component:238]: Components should block for at most 30 ms.
[22:54:50][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:50][W][component:238]: Components should block for at most 30 ms.
[22:54:50][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:50][W][component:238]: Components should block for at most 30 ms.
[22:54:50][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:50][W][component:238]: Components should block for at most 30 ms.
[22:54:50][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:50][W][component:238]: Components should block for at most 30 ms.
[22:54:50][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:50][W][component:238]: Components should block for at most 30 ms.
[22:54:50][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:50][W][component:238]: Components should block for at most 30 ms.
[22:54:50][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:50][W][component:238]: Components should block for at most 30 ms.
[22:54:50][D][ble_adv_controller:119]: bedroom_bedsidelamp_my_controller - stop advertising
[22:54:51][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[22:54:51][D][light:051]:   Brightness: 43%
[22:54:51][D][ble_adv_light:063]: Cold: 255, Warm: 0, Brightness: 110
[22:54:51][D][zhijia:655]: Zhi Jia - v2 - UUID: '0xC630B1', tx: 5, Command: '0xAD', Args: [110,0,0]
[22:54:51][D][ble_adv_controller:107]: bedroom_bedsidelamp_my_controller - start advertising: 22.9D.19.D6.61.13.F<IP_ADDRESS>.6E.3F.91.59.5D.B0.B4.1A.2E.4A.5F.85.F6.9C.A9.19 (26)
[22:54:51][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:51][W][component:238]: Components should block for at most 30 ms.
[22:54:51][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:51][W][component:238]: Components should block for at most 30 ms.
[22:54:52][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:52][W][component:238]: Components should block for at most 30 ms.
[22:54:52][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:52][W][component:238]: Components should block for at most 30 ms.
[22:54:52][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:52][W][component:238]: Components should block for at most 30 ms.
[22:54:52][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:52][W][component:238]: Components should block for at most 30 ms.
[22:54:52][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:52][W][component:238]: Components should block for at most 30 ms.
[22:54:52][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:52][W][component:238]: Components should block for at most 30 ms.
[22:54:52][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:52][W][component:238]: Components should block for at most 30 ms.
[22:54:52][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:52][W][component:238]: Components should block for at most 30 ms.
[22:54:52][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:52][W][component:238]: Components should block for at most 30 ms.
[22:54:53][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:53][W][component:238]: Components should block for at most 30 ms.
[22:54:53][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:53][W][component:238]: Components should block for at most 30 ms.
[22:54:53][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:53][W][component:238]: Components should block for at most 30 ms.
[22:54:53][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:53][W][component:238]: Components should block for at most 30 ms.
[22:54:53][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:53][W][component:238]: Components should block for at most 30 ms.
[22:54:53][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:53][W][component:238]: Components should block for at most 30 ms.
[22:54:53][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:53][W][component:238]: Components should block for at most 30 ms.
[22:54:53][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:53][W][component:238]: Components should block for at most 30 ms.
[22:54:54][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:54][W][component:238]: Components should block for at most 30 ms.
[22:54:54][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:54][W][component:238]: Components should block for at most 30 ms.
[22:54:54][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:54][W][component:238]: Components should block for at most 30 ms.
[22:54:54][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:54][W][component:238]: Components should block for at most 30 ms.
[22:54:54][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:54][W][component:238]: Components should block for at most 30 ms.
[22:54:54][D][ble_adv_controller:119]: bedroom_bedsidelamp_my_controller - stop advertising
[22:54:56][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[22:54:56][D][light:047]:   State: OFF
[22:54:56][D][ble_adv_light:035]: BleAdvLight::write_state - Switch OFF
[22:54:56][D][zhijia:655]: Zhi Jia - v2 - UUID: '0xC630B1', tx: 6, Command: '0xA6', Args: [0,0,0]
[22:54:56][D][ble_adv_controller:107]: bedroom_bedsidelamp_my_controller - start advertising: 22.9D.7F.B3.69.1B.FA.28.5B.8B.65.3C.99.51.55.BB.B<IP_ADDRESS>A.5F.85.F6.9C.A9.19 (26)
[22:54:56][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[22:54:56][D][ble_adv_light:035]: BleAdvLight::write_state - Switch OFF
[22:54:56][D][zhijia:655]: Zhi Jia - v2 - UUID: '0xC630B1', tx: 7, Command: '0xA6', Args: [0,0,0]
[22:54:56][D][ble_adv_controller:119]: bedroom_bedsidelamp_my_controller - stop advertising
[22:54:56][D][ble_adv_controller:107]: bedroom_bedsidelamp_my_controller - start advertising: 22.9D.81.4C.97.E5.05.D6.A5.75.9A.C2.67.AF.AB.44.4B.E7.D8.4A.5F.85.F6.9C.A9.19 (26)
[22:54:56][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:56][W][component:238]: Components should block for at most 30 ms.
[22:54:56][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:56][W][component:238]: Components should block for at most 30 ms.
[22:54:56][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:56][W][component:238]: Components should block for at most 30 ms.
[22:54:56][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:56][W][component:238]: Components should block for at most 30 ms.
[22:54:56][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:56][W][component:238]: Components should block for at most 30 ms.
[22:54:57][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:57][W][component:238]: Components should block for at most 30 ms.
[22:54:57][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:57][W][component:238]: Components should block for at most 30 ms.
[22:54:57][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:57][W][component:238]: Components should block for at most 30 ms.
[22:54:57][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:57][W][component:238]: Components should block for at most 30 ms.
[22:54:57][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:57][W][component:238]: Components should block for at most 30 ms.
[22:54:57][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:57][W][component:238]: Components should block for at most 30 ms.
[22:54:57][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:57][W][component:238]: Components should block for at most 30 ms.
[22:54:57][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:57][W][component:238]: Components should block for at most 30 ms.
[22:54:57][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:57][W][component:238]: Components should block for at most 30 ms.
[22:54:58][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:58][W][component:238]: Components should block for at most 30 ms.
[22:54:58][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:58][W][component:238]: Components should block for at most 30 ms.
[22:54:58][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:58][W][component:238]: Components should block for at most 30 ms.
[22:54:58][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:58][W][component:238]: Components should block for at most 30 ms.
[22:54:58][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:58][W][component:238]: Components should block for at most 30 ms.
[22:54:58][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:58][W][component:238]: Components should block for at most 30 ms.
[22:54:58][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:58][W][component:238]: Components should block for at most 30 ms.
[22:54:58][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:58][W][component:238]: Components should block for at most 30 ms.
[22:54:59][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:59][W][component:238]: Components should block for at most 30 ms.
[22:54:59][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:59][W][component:238]: Components should block for at most 30 ms.
[22:54:59][W][component:237]: Component <unknown> took a long time for an operation (52 ms).
[22:54:59][W][component:238]: Components should block for at most 30 ms.
[22:54:59][D][ble_adv_controller:119]: bedroom_bedsidelamp_my_controller - stop advertising

It is probably a difference in the bluetooth performances of the ESP32 board, I have an hard-coded value on my side that I will need to make dynamic, or review the process to adapt it.
Thanks in advance

My board Original WeMos ESP32 d1 mini

Actually, just to make a correction to my previous comment, I've realised that the controller on the unit I've got does not appear to respond to commands at all. I can't seem to get it to pair again either.

On my side I have an ESP32 WROOM, so more powerful, explaining why I have not seen the issue.
I just pushed a new version with an increased duration for sequencing, that may avoid overloading your boards.
I also added a 'seq_duration: 150' default value to the ble_adv_controller sections.
@cRazyK67 , @pantherale0 : I would appreciate if you could try to test this new version, and increase the 'seq_duration' to a higher value if it does not work, keeping in mind 'duration' should always be higher than 'seq_duration' by min 50.
@cRazyK67 , could you also please testing removing some of your controllers, their important number is maybe also causing overloading.
If this change does not work I will ad an option to deactivate the sequencing completely.
Sorry for the inconvenience caused 😢

@NicoIIT
The warnings are gone, but chandeliers don't work from HA.
[10:11:43][I][safe_mode:041]: Boot seems successful; resetting boot loop counter
[10:11:43][D][esp32.preferences:114]: Saving 1 preferences to flash...
[10:11:43][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[10:12:53][D][light:036]: 'bedroom_bedsidelamp_notmy' Setting:
[10:12:53][D][light:047]:   State: ON
[10:12:53][D][ble_adv_light:040]: BleAdvLight::write_state - Switch ON
[10:12:53][D][zhijia:651]: UUID: '0xC630B2', tx: 3, Command: '0xA5', Args: [0,0,0]
[10:12:53][D][ble_adv_light:048]: Corrected brightness: 100%
[10:12:53][D][ble_adv_light:070]: ct: 167.000, br: 1.000
[10:12:53][D][ble_adv_light:075]: BleAdvLight::write_state - Requested color temperature: 0
[10:12:53][D][zhijia:651]: UUID: '0xC630B2', tx: 4, Command: '0xAE', Args: [0,0,0]
[10:12:53][D][ble_adv_light:079]: BleAdvLight::write_state - Requested brightness: 255
[10:12:53][D][zhijia:651]: UUID: '0xC630B2', tx: 5, Command: '0xAD', Args: [255,0,0]
[10:12:53][D][ble_adv_controller:088]: bedroom_bedsidelamp_notmy_controller - start advertising: 22.9D.85.4F.93.E1.05.D2.A1.71.9A.C5.63.AB.AF.44.48.E3.DC.4A.5F.85.F6.9C.A9.19 (26)
[10:12:53][D][light:036]: 'bedroom_bedsidelamp_notmy' Setting:
[10:12:53][D][ble_adv_light:048]: Corrected brightness: 100%
[10:12:53][D][ble_adv_controller:096]: bedroom_bedsidelamp_notmy_controller - stop advertising
[10:12:53][D][ble_adv_controller:088]: bedroom_bedsidelamp_notmy_controller - start advertising: 22.9D.89.44.9F.ED.0E.DE.AD.7D.91.C2.6F.A7.A3.4F.48.E4.D0.4A.5F.85.F6.9C.A9.19 (26)
[10:12:53][D][ble_adv_controller:096]: bedroom_bedsidelamp_notmy_controller - stop advertising
[10:12:53][D][ble_adv_controller:088]: bedroom_bedsidelamp_notmy_controller - start advertising: 22.9D.74.B8.9D.EF.0D.DC.AF.7F.92.C3.6D.A5.A1.4C.48.E5.D2.4A.5F.85.F6.9C.A9.19 (26)
[10:12:53][D][ble_adv_controller:096]: bedroom_bedsidelamp_notmy_controller - stop advertising
[10:13:15][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[10:13:15][D][light:047]:   State: ON
[10:13:15][D][ble_adv_light:040]: BleAdvLight::write_state - Switch ON
[10:13:15][D][zhijia:651]: UUID: '0xC630B1', tx: 3, Command: '0xA5', Args: [0,0,0]
[10:13:15][D][ble_adv_light:048]: Corrected brightness: 100%
[10:13:15][D][ble_adv_light:070]: ct: 167.000, br: 1.000
[10:13:15][D][ble_adv_light:075]: BleAdvLight::write_state - Requested color temperature: 0
[10:13:15][D][zhijia:651]: UUID: '0xC630B1', tx: 4, Command: '0xAE', Args: [0,0,0]
[10:13:15][D][ble_adv_light:079]: BleAdvLight::write_state - Requested brightness: 255
[10:13:15][D][zhijia:651]: UUID: '0xC630B1', tx: 5, Command: '0xAD', Args: [255,0,0]
[10:13:15][W][component:237]: Component light took a long time for an operation (55 ms).
[10:13:15][W][component:238]: Components should block for at most 30 ms.
[10:13:15][D][ble_adv_controller:088]: bedroom_bedsidelamp_my_controller - start advertising: 22.9D.79.B0.6F.1D.F9.2E.5D.8D.66.39.9F.57.53.B8.B4.1C.20.4A.5F.85.F6.9C.A9.19 (26)
[10:13:15][D][light:036]: 'bedroom_bedsidelamp_my' Setting:
[10:13:15][D][ble_adv_light:048]: Corrected brightness: 100%
[10:13:15][D][ble_adv_controller:096]: bedroom_bedsidelamp_my_controller - stop advertising
[10:13:15][D][ble_adv_controller:088]: bedroom_bedsidelamp_my_controller - start advertising: 22.9D.75.BB.63.11.F<IP_ADDRESS>.6D.3E.93.5B.5F.B3.B4.1B.2C.4A.5F.85.F6.9C.A9.19 (26)
[10:13:15][D][ble_adv_controller:096]: bedroom_bedsidelamp_my_controller - stop advertising
[10:13:15][D][ble_adv_controller:088]: bedroom_bedsidelamp_my_controller - start advertising: 22.9D.<IP_ADDRESS>.F<IP_ADDRESS>.6E.3F.91.59.5D.B0.B4.1A.2E.4A.5F.85.F6.9C.A9.19 (26)
[10:13:15][D][ble_adv_controller:096]: bedroom_bedsidelamp_my_controller - stop advertising
[10:13:59][D][light:036]: 'bedroom_bedsidelamp_notmy' Setting:
[10:13:59][D][light:047]:   State: OFF
[10:13:59][D][ble_adv_light:032]: BleAdvLight::write_state - Switch OFF
[10:13:59][D][zhijia:651]: UUID: '0xC630B2', tx: 6, Command: '0xA6', Args: [0,0,0]
[10:14:00][D][ble_adv_controller:088]: bedroom_bedsidelamp_notmy_controller - start advertising: 22.9D.83.4C.95.E7.06.D4.A7.77.99.C0.65.AD.A9.47.48.E6.DA.4A.5F.85.F6.9C.A9.19 (26)
[10:14:00][D][light:036]: 'bedroom_bedsidelamp_notmy' Setting:
[10:14:00][D][ble_adv_light:032]: BleAdvLight::write_state - Switch OFF
[10:14:00][D][zhijia:651]: UUID: '0xC630B2', tx: 7, Command: '0xA6', Args: [0,0,0]
[10:14:04][D][ble_adv_controller:096]: bedroom_bedsidelamp_notmy_controller - stop advertising
[10:14:04][D][ble_adv_controller:088]: bedroom_bedsidelamp_notmy_controller - start advertising: 22.9D.7D.B3.6B.19.F9.2A.<IP_ADDRESS>E.9B.53.57.B8.B<IP_ADDRESS>A.5F.85.F6.9C.A9.19 (26)
[10:14:04][D][ble_adv_controller:096]: bedroom_bedsidelamp_notmy_controller - stop advertising
[10:14:31][D][light:036]: 'bedroom_bedsidelamp_notmy' Setting:
[10:14:31][D][light:047]:   State: ON
[10:14:31][D][ble_adv_light:040]: BleAdvLight::write_state - Switch ON
[10:14:31][D][zhijia:651]: UUID: '0xC630B2', tx: 8, Command: '0xA5', Args: [0,0,0]
[10:14:31][D][ble_adv_light:048]: Corrected brightness: 100%
[10:14:31][D][ble_adv_controller:088]: bedroom_bedsidelamp_notmy_controller - start advertising: 22.9D.71.B0.67.15.FA.<IP_ADDRESS>.31.97.5F.5B.BB.B<IP_ADDRESS>A.5F.85.F6.9C.A9.19 (26)
[10:14:31][D][light:036]: 'bedroom_bedsidelamp_notmy' Setting:
[10:14:31][D][ble_adv_light:048]: Corrected brightness: 100%
[10:14:31][D][ble_adv_controller:096]: bedroom_bedsidelamp_notmy_controller - stop advertising
[10:14:39][D][light:036]: 'livingroom_sofa_chandelier_2' Setting:
[10:14:39][D][light:047]:   State: ON
[10:14:39][D][ble_adv_light:106]: BleAdvSecLight::write_state - Switch ON
[10:14:39][D][zhijia:651]: UUID: '0xC630B4', tx: 5, Command: '0xAF', Args: [0,0,0]
[10:14:39][D][ble_adv_controller:088]: livingroom_sofa_chandelier_controller - start advertising: 22.9D.8F.45.99.EB.09.D8.AB.7B.96.C5.69.A1.A5.48.4E.E5.D6.4A.5F.85.F6.9C.A9.19 (26)
[10:14:39][D][ble_adv_controller:096]: livingroom_sofa_chandelier_controller - stop advertising
[10:14:40][D][light:036]: 'livingroom_sofa_chandelier_2' Setting:
[10:14:40][D][light:047]:   State: OFF
[10:14:40][D][ble_adv_light:109]: BleAdvSecLight::write_state - Switch OFF
[10:14:40][D][zhijia:651]: UUID: '0xC630B4', tx: 6, Command: '0xB0', Args: [0,0,0]
[10:14:40][D][ble_adv_controller:088]: livingroom_sofa_chandelier_controller - start advertising: 22.9D.93.5A.85.F7.16.C4.B7.67.89.C6.75.BD.B9.57.4E.E6.CA.4A.5F.85.F6.9C.A9.19 (26)
[10:14:41][D][ble_adv_controller:096]: livingroom_sofa_chandelier_controller - stop advertising

@cRazyK67 : the logs you are showing are from the older version of the component, not the last one, so if it does not work whereas you are using the previous version of the software I do not understand anymore...

@NicoIIT. My new config bellow. chandeliers still not work.

external_components:
 source: github://NicoIIT/esphome-components
 refresh: 10s
# --------------------------------------------------------------
ble_adv_controller:
# --------------------------------------------------------------
 - id: bedroom_bedsidelamp_my_controller
   encoding: zhijia
   variant: v2
   seq_duration: 150
   duration: 250
   forced_id: 0xC630B1
# --------------------------------------------------------------
 - id: bedroom_bedsidelamp_notmy_controller
   encoding: zhijia
   variant: v2
   seq_duration: 150
   duration: 250
   forced_id: 0xC630B2
light:
# --------------------------------------------------------------
 - platform: ble_adv_controller
   ble_adv_controller_id: bedroom_bedsidelamp_my_controller
   id: bedroom_bedsidelamp_my
   name: bedroom_bedsidelamp_my
   default_transition_length: 0s
   min_brightness: 0%
   #send_brightness_after_color_temperature_change: true
# --------------------------------------------------------------
 - platform: ble_adv_controller
   ble_adv_controller_id: bedroom_bedsidelamp_notmy_controller
   id: bedroom_bedsidelamp_notmy
   name: bedroom_bedsidelamp_notmy
   default_transition_length: 0s
   min_brightness: 0%

@cRazyK67 , could you please provide the logs (the previous ones are not the correct logs, the time is not good and logs are not corresponding to last software) and try to increase seq_duration to 200, then if it does not work 250 (and duration to 300) ?

@NicoIIT - still does not work, duration 200ms on the commit I ref before is working fine, but on this new version even 250ms does not work.
logs_fanlamppro-controller_logs(2).txt
relevant config:
# fanlamp pro

ble_adv_controller:
  - id: master_bed_controller
    encoding: fanlamp_pro
    variant: v3
    duration: 250
    reversed: false
    forced_id: 0
    seq_duration: 200

light:
  - platform: ble_adv_controller
    ble_adv_controller_id: master_bed_controller
    name: Master Bedroom Main Light
    min_brightness: 21%

fan:
  - platform: ble_adv_controller
    ble_adv_controller_id: master_bed_controller
    name: Master Bedroom Fan
    speed_count: 6
    use_direction: true

button:
  - platform: ble_adv_controller
    ble_adv_controller_id: master_bed_controller
    name: Master Bed Light Controller Pair
    cmd: pair

@NicoIIT ,

try to increase seq_duration to 200

crazyk_esp_home_config_2dev.txt
crazyk_esp_home_logs_2dev.txt

then if it does not work 250 (and duration to 300)

INFO ESPHome 2024.7.2
INFO Reading configuration /config/esphome/esp-childroom-chandelier.yaml...
Failed config

ble_adv_controller: [source /config/esphome/esp-childroom-chandelier.yaml:38]
  - id: bedroom_bedsidelamp_my_controller

    Invalid encoding: zhijia. accepted values: ['fanlamp_pro', 'lampsmart_pro'].
    encoding: zhijia
    variant: v2

    value must be at most 200.
    seq_duration: 250
    duration: 300
    forced_id: 12988593
  - id: bedroom_bedsidelamp_notmy_controller
    encoding: zhijia
    variant: v2
    seq_duration: 250

It's too late for me.
I can continue testing tomorrow

@cRazyK67, @pantherale0 , It is also too late for me... there was a bug in the bugfix... now corrected.

@NicoIIT tested again and still does not work
logs_fanlamppro-controller_run(1).txt

@cRazyK67 , @pantherale0 : Attempting a new fix 'in the dark' as I cannot reproduce on my side:

Please test with seq_duration 150 / 200 / 250 if possible
If not work, please test deactivation by putting seq_duration to 0 (should be equivalent to seq_duration = duration)
I added new logs to track a bit more the delays in between stop / start ....

@NicoIIT  Please add option "use_oscillation" in a8d91ba

@pantherale0 , @cRazyK67 , I finally managed to reproduce, nothing to do with the board performance ... I was registering on my side some supplementary config that hide the ESP2_BLE auto registration issue I introduced in the change... So now it is corrected and I am much more confident! Still on the dev branch, if you could have a look (you can remove the seq_duration config btw)😄 I will wait for your GO before putting it back to the main branch...
Thanks for your help on this issue!!!
@cRazyK67 , Fan oscillation is on both branches if you want

@NicoIIT

source: github://NicoIIT/esphome-components/tree/dev
Its correct source path?

if yes, then all work normal
Oscillation also work.

@cRazyK67, Well if you have this configuration near your pair button, then yes:

Present, only inactive

@cRazyK67, as it is working, I pushed the changes to main.
You can have a look to the Dynamic Configuration section and try to use the Pairing using all variants, as done by the Phone App.

@NicoIIT - all working perfect again now, thanks for all of this.
Was thinking, at the moment we default everything to an off state, perhaps we could store the last known state and use that instead? I've chucked the remote in the bottom of a drawer so assuming the state is suitable for my config as a bunch of automation is responsible for controlling the fan and light.
If you did think about implementing that, would probably recommend as a separate PR as this one seems quite big lol.

@Privet-zdarova, @cRazyK67, I just corrected a potential issue on ZhiJia encoding when changing brightness / color temperature that might be a cause of the flickering you experienced. To be tested to see if it helps.

@NicoIIT It didn't help me.
The flickering when switching color temperature remained.
I have an n52840 dongle, When I have time I will intercept packets from the application

@cRazyK67 , I am searching if the issue is coming from my software or was already existing in the software I used as a basis. Could you please try to use the component from this repo and attempt a pairing?

If it works it means I did not properly implement the encoder from this base repo, which could be the case as I did small changes to standardize the stack
if it does not work it means something was forgotten when the protocol was initially taken from the phone app, and that it is the direction to go

I found small differences for both cases, and I would appreciate if you could help.
Base configuration:
external_components:
  # shorthand
  source: github://flicker581/esphome-lampsmart

lampsmart_pro_light:

light:
  - platform: lampsmart_pro_light
    name: V1A light
    duration: 200
    variant: v1a

Please remove any reference to other source repo as it could conflict during the build.

@NicoIIT Im use this config https://github.com/flicker581/esphome-lampsmart/blob/main/example_lampsmart_pro_light.yaml
my chandelier still not pairing for all variants (v1..v2).

@pantherale0, in fact this is already implemented by base ESPHome Light, using restore_mode: RESTORE_DEFAULT_OFF 😄.

@aronsky , I think the fork is now very far from this initial repo with 600 new lines of docs and 2700 new lines of code, so I will continue the work there.
Thanks a lot for the initial work, I hope you did not spent too much time reviewing this (very changing huge) PR 😄
@ All testers and participants in this thread, thanks for your help testing this new software, should you want to continue making it evolve do not hesitate to open Issues to request for bug fixes or new features!

@Privet-zdarova, @cRazyK67, I just corrected a potential issue on ZhiJia encoding when changing brightness / color temperature that might be a cause of the flickering you experienced. To be tested to see if it helps.

Thank you very much!)) Everything works great for me with both zhijia v0 and zhijia v2!

@NicoIIT, I didn't get a chance to follow this discussion thoroughly, but taking a look at the fork, it certainly looks like you've done a fantastic job. I am considering merging this PR as is, as it seems that the discussion here is much more of a review than I could ever have done :)
Additionally, I've started work on transitioning this component to Home Assistant directly (without an explicit need for ESPHome). That's in early stages, we'll see how it goes. It'll be a lot easier for end users, I believe (and open up the component to people who have Bluetooth on their hub, but no ESP32 devices). But I imagine that translating all the encoding functions to Python is going to be a colossal PITA.

@aronsky , good luck to port this to home assistant! With the work done on the encoders/decoders this should be much more easy (only standard 'crc16' functions, only 2 'whiten' simple functions).
The main issue will be with the bluetooth stack that is much less stable in a linux docker environment, I let you refer to this comment. I personally tried to implement some standard BLE Leds in HA component requiring to maintain a BLE connection and it never worked ok, whereas I needed 20 lines of code to do it in ESP32.