Controlling BLE ceiling light with HA

Well in fact the refresh: 0s is necessary in your case as per the logs you do not have the last version :frowning:, you should have (31) at the end of the request start advertising logs.

EDIT: my bad, I pushed on dev branch, not on main… corrected!

Let’s see, I’ll install again, and I’ll attach everything I have.

Yaml to install:(i add refresh)

esphome:
  name: daiconesp
  friendly_name: DaiconESP

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "xxxxxxxx="

ota:
  - platform: esphome
    password: "xxxxxxx"

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Daiconesp Fallback Hotspot"
    password: "xxxxxxx"

captive_portal:

external_components:
  - source: github://NicoIIT/esphome-components@main
    refresh: 0s
  
ble_adv_controller:
  # A controller per device, or per remote in fact as it has the same role
  - id: my_controller
    # encoding: could be any of 'zhijia', 'fanlamp_pro', 'smartlamp_pro' (the 2 last are the same)
    encoding: fanlamp_pro
    # variant: variant of the encoding 
    # For ZhiJia: Can be v0 (MSC16), v1 (MSC26) or v2 (MSC26A), default is v2
    # For Fanlamp: Can be any of 'v1a', 'v1b', 'v2' or 'v3', depending on how old your lamp is... Default is 'v3'
    variant: v3
    # max_duration (default 3000, range 300 -> 10000): the maximum duration during which the command is advertized.
    # if a command is received before the 'max_duration' but after the 'duration', it is processed immediately 
    # Increasing this parameter will have no major consequences, the component will just keep advertize the command
    # Could be interesting at pairing time to have the pairing command advertized for a long time
    max_duration: 3000
    # duration (default 200, range 100 -> 500): the MINIMUM duration during which the command is sent.
    # if a command is received before the 'duration' it is queued and processed later, 
    # if there is already a similar command pending, in this case the pending command is removed from the queue
    # Increasing this parameter will make the combination of commands slower. See 'Dynamic Configuration'.
    duration: 200
    # reversed: reversing the cold / warm at encoding time, needed for some controllers
    # default to false
    reversed: false
    # forced_id: provide the 4 bytes identifier key extracted from your app phone traffic 
    # to share the same key than the phone
    # example: 0xBFF62757
    # For ZhiJia, default to 0xC630B8 which was the value hard-coded in ble_adv_light component. Max 0xFFFFFF.
    # For FanLamp: default to 0, uses the hash id computed by esphome from the id/name of the controller
    forced_id: 0
    # show_config (default true): shows the dynamic configuration in the device info page in Home Automation
    show_config: true

light:
  - platform: ble_adv_controller
    # ble_adv_controller_id: the ID of your controller
    ble_adv_controller_id: my_controller
    # name: the name as it will appear in Home Assistant
    name: First Light
    # min_brightness: % minimum brightness supported by the light before it shuts done
    # just setup this value to 0, then test your lamp by decreasing the brightness percent by percent. 
    # when it switches off, you have the min_brightness to setup here.
    # Default to 21%
    min_brightness: 21%
    # send_brightness_after_color_temperature_change: refresh the brightness after the color temperature was changed.
    # workaround for issue https://github.com/aronsky/esphome-components/issues/18
    send_brightness_after_color_temperature_change: false

fan:
  - platform: ble_adv_controller
    ble_adv_controller_id: my_controller
    name: my fan
    # speed_count: the number of speed level available on your remote / app. Can be 0 / 3 / 6.
    # if not properly setup the remote and this component does not behave properly together
    # only speed 6 is available for zhijia, and this is the default
    speed_count: 6
    # use_direction: ability to change the fan direction forward / reverse.
    # default to true, not available for zhijia
    use_direction: true
    # use_oscillation: ability to start / stop the fan oscillation.
    # default to false, only available for FanLamp v2 / v3
    use_oscillation: false

button:
  - platform: ble_adv_controller
    ble_adv_controller_id: my_controller
    name: Pair
    # cmd: the action to be executed when the button is pressed
    # any of 'pair', 'unpair', 'custom', 'light_on', ...
    cmd: pair

And now the whole log with the installation and the pair attempt:

INFO ESPHome 2024.7.3
INFO Reading configuration /config/esphome/daiconesp.yaml...
INFO Updating https://github.com/NicoIIT/esphome-components.git@main
INFO Generating C++ source...
INFO Compiling app...
Processing daiconesp (board: esp32dev; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.1.3
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.2.2
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- noise-c @ 0.1.4
Compiling .pioenvs/daiconesp/src/esphome/components/ble_adv_controller/ble_adv_controller.cpp.o
Compiling .pioenvs/daiconesp/src/esphome/components/ble_adv_controller/ble_adv_handler.cpp.o
Compiling .pioenvs/daiconesp/src/esphome/components/ble_adv_controller/button/ble_adv_button.cpp.o
Compiling .pioenvs/daiconesp/src/esphome/components/ble_adv_controller/fan/ble_adv_fan.cpp.o
Compiling .pioenvs/daiconesp/src/esphome/components/ble_adv_controller/fanlamp_pro.cpp.o
Compiling .pioenvs/daiconesp/src/esphome/components/ble_adv_controller/light/ble_adv_light.cpp.o
Compiling .pioenvs/daiconesp/src/esphome/components/ble_adv_controller/zhijia.cpp.o
Compiling .pioenvs/daiconesp/src/main.cpp.o
Linking .pioenvs/daiconesp/firmware.elf
RAM:   [==        ]  16.2% (used 52984 bytes from 327680 bytes)
Flash: [========= ]  90.3% (used 1656877 bytes from 1835008 bytes)
Building .pioenvs/daiconesp/firmware.bin
Creating esp32 image...
Successfully created esp32 image.
esp32_create_combined_bin([".pioenvs/daiconesp/firmware.bin"], [".pioenvs/daiconesp/firmware.elf"])
Wrote 0x1a5ec0 bytes to file /data/build/daiconesp/.pioenvs/daiconesp/firmware.factory.bin, ready to flash to offset 0x0
esp32_copy_ota_bin([".pioenvs/daiconesp/firmware.bin"], [".pioenvs/daiconesp/firmware.elf"])
========================= [SUCCESS] Took 33.97 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.1.102
INFO Uploading /data/build/daiconesp/.pioenvs/daiconesp/firmware.bin (1662656 bytes)
Uploading: [============================================================] 100% Done...


INFO Upload took 14.29 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.1.102 using esphome API
INFO Successfully connected to daiconesp @ 192.168.1.102 in 11.297s
INFO Successful handshake with daiconesp @ 192.168.1.102 in 0.099s
[10:48:56][I][app:100]: ESPHome version 2024.7.3 compiled on Aug  1 2024, 10:48:02
[10:48:56][C][wifi:599]: WiFi:
[10:48:56][C][wifi:427]:   Local MAC: E8:6B:EA:36:77:54
[10:48:56][C][wifi:432]:   SSID: [redacted]
[10:48:56][C][wifi:435]:   IP Address: 192.168.1.102
[10:48:56][C][wifi:439]:   BSSID: [redacted]
[10:48:56][C][wifi:440]:   Hostname: 'daiconesp'
[10:48:56][C][wifi:442]:   Signal strength: -81 dB ▂▄▆█
[10:48:56][C][wifi:446]:   Channel: 1
[10:48:56][C][wifi:447]:   Subnet: 255.255.255.0
[10:48:56][C][wifi:448]:   Gateway: 192.168.1.1
[10:48:56][C][wifi:449]:   DNS1: 80.58.61.250
[10:48:56][C][wifi:450]:   DNS2: 80.58.61.254
[10:48:56][C][logger:185]: Logger:
[10:48:56][C][logger:186]:   Level: DEBUG
[10:48:56][C][logger:188]:   Log Baud Rate: 115200
[10:48:56][C][logger:189]:   Hardware UART: UART0
[10:48:56][C][light:103]: Light 'First Light'
[10:48:56][C][light:105]:   Default Transition Length: 0.0s
[10:48:56][C][light:106]:   Gamma Correct: 2.80
[10:48:56][C][ble_adv_light:024]: BleAdvLight
[10:48:56][C][ble_adv_light:149]:   Controller 'my_controller'
[10:48:56][C][ble_adv_light:026]:   Base Light 'First Light'
[10:48:56][C][ble_adv_light:027]:   Cold White Temperature: 167.000000 mireds
[10:48:56][C][ble_adv_light:028]:   Warm White Temperature: 333.000000 mireds
[10:48:56][C][ble_adv_light:029]:   Minimum Brightness: 0xA0000000
[10:48:56][C][ble_adv_fan:022]: BleAdvFan 'my fan'
[10:48:56][C][ble_adv_fan:149]:   Controller 'my_controller'
[10:48:56][C][ble_adv_button:011]: BleAdvButton 'Pair'
[10:48:56][C][ble_adv_button:149]:   Controller 'my_controller'
[10:48:56][C][esp32_ble:383]: ESP32 BLE:
[10:48:56][C][esp32_ble:385]:   MAC address: E8:6B:EA:36:77:56
[10:48:56][C][esp32_ble:386]:   IO Capability: none
[10:48:56][C][ble_adv_controller:052]: BleAdvController 'my_controller'
[10:48:56][C][ble_adv_controller:053]:   Hash ID '388E6F12'
[10:48:56][C][ble_adv_controller:054]:   Transmission Min Duration: 0 ms
[10:48:56][C][ble_adv_controller:055]:   Transmission Max Duration: 3000 ms
[10:48:56][C][ble_adv_controller:056]:   Transmission Sequencing Duration: 50 ms
[10:48:56][C][ble_adv_controller:057]:   Configuration visible: YES
[10:48:56][C][captive_portal:088]: Captive Portal:
[10:48:56][C][mdns:116]: mDNS:
[10:48:56][C][mdns:117]:   Hostname: daiconesp
[10:48:56][C][esphome.ota:073]: Over-The-Air updates:
[10:48:56][C][esphome.ota:074]:   Address: daiconesp.local:3232
[10:48:56][C][esphome.ota:075]:   Version: 2
[10:48:56][C][esphome.ota:078]:   Password configured
[10:48:56][C][safe_mode:018]: Safe Mode:
[10:48:56][C][safe_mode:020]:   Boot considered successful after 60 seconds
[10:48:56][C][safe_mode:021]:   Invoke after 10 boot attempts
[10:48:56][C][safe_mode:023]:   Remain in safe mode for 300 seconds
[10:48:56][C][api:139]: API Server:
[10:48:56][C][api:140]:   Address: daiconesp.local:6053
[10:48:56][C][api:142]:   Using noise encryption: YES
[10:49:49][I][safe_mode:041]: Boot seems successful; resetting boot loop counter
[10:49:49][D][esp32.preferences:114]: Saving 1 preferences to flash...
[10:49:49][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[10:49:59][D][api.connection:197]: Home Assistant 2024.7.4 (192.168.1.51) requested disconnected
[10:49:59][D][api:102]: Accepted 192.168.1.51
[10:49:59][D][api.connection:1375]: Home Assistant 2024.7.4 (192.168.1.51): Connected successfully
[10:50:04][D][select:062]: 'my_controller - Encoding' - Setting
[10:50:04][D][select:115]: 'my_controller - Encoding' - Set selected option to: FanLamp - All
[10:50:04][D][select:015]: 'my_controller - Encoding': Sending state FanLamp - All (index 0)
[10:50:09][D][button:010]: 'Pair' Pressed.
[10:50:09][D][ble_adv_button:016]: BleAdvButton::press_action called
[10:50:09][D][fanlamp_pro:241]: FanLamp - v1a - ID: '0x388E6F12', tx: 2, Command: '0x28', Args: [18,96,129]
[10:50:09][D][fanlamp_pro:241]: FanLamp - v1b - ID: '0x388E6F12', tx: 2, Command: '0x28', Args: [18,96,129]
[10:50:09][D][fanlamp_pro:291]: FanLamp - v2 - ID: '0x388E6F12', tx: 2, Command: '0x28', Args: [0,0,0,0]
[10:50:09][D][fanlamp_pro:291]: FanLamp - v3 - ID: '0x388E6F12', tx: 2, Command: '0x28', Args: [0,0,0,0]
[10:50:09][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.03.77.F8.B6.5F.2B.5E.00.FC.31.51.CC.F2.9E.40.22.4A.7B.FC.02.D0.C5.A6.9E.B5.A8.1A (31)
[10:50:09][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.03.F9.08.49.13.F0.69.25.4E.31.51.BA.AE.D0.0E.6C.CD.BA.BC.71.41.16.3A.0A.59.C7.4C (31)
[10:50:09][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.16.F0.08.10.80.0A.E8.31.BE.3E.DC.A0.03.A9.E3.C2.0E.9B.5C.9E.D4.BA.0F.29.31.D6.B8 (31)
[10:50:09][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.16.F0.08.10.80.DC.37.11.01.D1.48.49.24.92.29.9E.03.16.84.E6.B6.2D.B6.04.5B.06.B5 (31)
[10:50:09][W][component:237]: Component ble_adv_controller took a long time for an operation (63 ms).
[10:50:09][W][component:238]: Components should block for at most 30 ms.
[10:50:12][D][ble_adv_controller:142]: my_controller - request stop advertising
[10:50:19][D][number:054]: 'my_controller - Duration' - Setting number value
[10:50:19][D][number:113]:   New number value: 500.000000
[10:50:19][D][number:012]: 'my_controller - Duration': Sending state 500.000000
[10:50:21][D][number:054]: 'my_controller - Duration' - Setting number value
[10:50:21][D][number:113]:   New number value: 460.000000
[10:50:21][D][number:012]: 'my_controller - Duration': Sending state 460.000000
[10:50:22][D][number:054]: 'my_controller - Duration' - Setting number value
[10:50:22][D][number:113]:   New number value: 500.000000
[10:50:22][D][number:012]: 'my_controller - Duration': Sending state 500.000000
[10:50:27][D][button:010]: 'Pair' Pressed.
[10:50:27][D][ble_adv_button:016]: BleAdvButton::press_action called
[10:50:27][D][fanlamp_pro:241]: FanLamp - v1a - ID: '0x388E6F12', tx: 3, Command: '0x28', Args: [18,96,129]
[10:50:27][D][fanlamp_pro:241]: FanLamp - v1b - ID: '0x388E6F12', tx: 3, Command: '0x28', Args: [18,96,129]
[10:50:27][D][fanlamp_pro:291]: FanLamp - v2 - ID: '0x388E6F12', tx: 3, Command: '0x28', Args: [0,0,0,0]
[10:50:27][D][fanlamp_pro:291]: FanLamp - v3 - ID: '0x388E6F12', tx: 3, Command: '0x28', Args: [0,0,0,0]
[10:50:28][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.03.77.F8.B6.5F.2B.5E.00.FC.31.51.CC.F2.9E.40.22.4A.FB.FC.DC.0E.4E.78.C1.6A.8E.3F (31)
[10:50:28][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.03.F9.08.49.13.F0.69.25.4E.31.51.BA.AE.D0.0E.6C.CD.BA.3C.71.3D.6A.AB.76.E7.11.4C (31)
[10:50:28][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.16.F0.08.10.80.25.48.FE.EF.F5.40.9A.D4.7D.15.29.A9.00.E9.CD.DC.1F.FB.D8.59.97.00 (31)
[10:50:28][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.16.F0.08.10.80.AF.48.AB.71.EC.02.7C.57.7A.C0.8A.83.4F.DA.1D.22.E1.FB.68.48.CB.50 (31)
[10:50:28][W][component:237]: Component ble_adv_controller took a long time for an operation (63 ms).
[10:50:28][W][component:238]: Components should block for at most 30 ms.
[10:50:29][D][button:010]: 'Pair' Pressed.
[10:50:29][D][ble_adv_button:016]: BleAdvButton::press_action called
[10:50:29][D][fanlamp_pro:241]: FanLamp - v1a - ID: '0x388E6F12', tx: 4, Command: '0x28', Args: [18,96,129]
[10:50:29][D][fanlamp_pro:241]: FanLamp - v1b - ID: '0x388E6F12', tx: 4, Command: '0x28', Args: [18,96,129]
[10:50:29][D][fanlamp_pro:291]: FanLamp - v2 - ID: '0x388E6F12', tx: 4, Command: '0x28', Args: [0,0,0,0]
[10:50:29][D][fanlamp_pro:291]: FanLamp - v3 - ID: '0x388E6F12', tx: 4, Command: '0x28', Args: [0,0,0,0]
[10:50:29][D][ble_adv_controller:142]: my_controller - request stop advertising
[10:50:29][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.03.77.F8.B6.5F.2B.5E.00.FC.31.51.CC.F2.9E.40.22.4A.1B.FC.14.C6.9E.B0.38.E0.73.A4 (31)
[10:50:29][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.03.F9.08.49.13.F0.69.25.4E.31.51.BA.AE.D0.0E.6C.CD.BA.DC.71.DC.8B.B8.97.F5.5B.4C (31)
[10:50:29][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.16.F0.08.10.80.0B.9E.DA.CF.5C.88.80.12.3B.D0.1C.FC.27.A9.3A.A5.38.2D.3F.D4.AA.09 (31)
[10:50:29][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.16.F0.08.10.80.33.B9.2E.B0.3E.56.25.F1.C0.24.99.5E.9C.D6.B8.83.2C.14.2B.A5.BC.E2 (31)
[10:50:29][W][component:237]: Component ble_adv_controller took a long time for an operation (63 ms).
[10:50:29][W][component:238]: Components should block for at most 30 ms.
[10:50:31][D][light:036]: 'First Light' Setting:
[10:50:31][D][light:047]:   State: ON
[10:50:31][D][ble_adv_light:043]: BleAdvLight::write_state - Switch ON
[10:50:31][D][fanlamp_pro:241]: FanLamp - v1a - ID: '0x388E6F12', tx: 5, Command: '0x10', Args: [0,0,0]
[10:50:31][D][fanlamp_pro:241]: FanLamp - v1b - ID: '0x388E6F12', tx: 5, Command: '0x10', Args: [0,0,0]
[10:50:31][D][fanlamp_pro:291]: FanLamp - v2 - ID: '0x388E6F12', tx: 5, Command: '0x10', Args: [0,0,0,0]
[10:50:31][D][fanlamp_pro:291]: FanLamp - v3 - ID: '0x388E6F12', tx: 5, Command: '0x10', Args: [0,0,0,0]
[10:50:31][D][ble_adv_light:063]: Cold: 255, Warm: 0, Brightness: 255
[10:50:31][D][fanlamp_pro:241]: FanLamp - v1a - ID: '0x388E6F12', tx: 6, Command: '0x21', Args: [255,0,0]
[10:50:31][D][fanlamp_pro:241]: FanLamp - v1b - ID: '0x388E6F12', tx: 6, Command: '0x21', Args: [255,0,0]
[10:50:31][D][fanlamp_pro:291]: FanLamp - v2 - ID: '0x388E6F12', tx: 6, Command: '0x21', Args: [0,0,255,0]
[10:50:31][D][fanlamp_pro:291]: FanLamp - v3 - ID: '0x388E6F12', tx: 6, Command: '0x21', Args: [0,0,255,0]
[10:50:31][W][component:237]: Component light took a long time for an operation (87 ms).
[10:50:31][W][component:238]: Components should block for at most 30 ms.
[10:50:31][D][ble_adv_controller:142]: my_controller - request stop advertising
[10:50:31][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.03.77.F8.B6.5F.2B.5E.00.FC.31.51.D0.F2.9E.08.24.CB.9B.FC.7E.AC.A9.DA.74.E2.5F.57 (31)
[10:50:31][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.03.F9.08.49.13.F0.69.25.4E.31.51.BA.B2.D0.0E.24.CB.3B.5C.71.1C.4B.D7.57.AD.63.4C (31)
[10:50:31][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.16.F0.08.10.80.4A.FA.EF.E7.3C.7A.63.44.3C.38.A8.01.E8.CC.DD.1E.FA.1A.D9.6F.EA.60 (31)
[10:50:31][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.16.F0.08.10.80.5C.49.45.8C.A4.21.51.A7.8B.1B.A2.4B.6F.7E.BD.BB.82.62.7A.2F.44.18 (31)
[10:50:31][W][component:237]: Component ble_adv_controller took a long time for an operation (61 ms).
[10:50:31][W][component:238]: Components should block for at most 30 ms.
[10:50:32][D][ble_adv_controller:142]: my_controller - request stop advertising
[10:50:32][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.03.77.F8.B6.5F.2B.5E.00.FC.31.51.5C.F2.9E.F7.24.CB.5B.FC.98.4A.14.3C.AE.82.64.CD (31)
[10:50:32][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.03.F9.08.49.13.F0.69.25.4E.31.51.BA.3E.D0.0E.DB.CB.3B.9C.71.B3.E4.2F.F8.AD.62.4C (31)
[10:50:32][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.16.F0.08.10.80.BA.2F.B6.2A.2C.C3.40.FF.0B.BF.59.9B.D1.40.0A.1A.13.DB.2C.70.10.FE (31)
[10:50:32][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.16.F0.08.10.80.94.B6.A1.63.94.09.33.0B.A0.1E.A2.B7.25.B8.4E.43.18.D0.A5.2C.D9.D8 (31)
[10:50:32][W][component:237]: Component ble_adv_controller took a long time for an operation (63 ms).
[10:50:32][W][component:238]: Components should block for at most 30 ms.
[10:50:32][D][light:036]: 'First Light' Setting:
[10:50:32][D][light:047]:   State: OFF
[10:50:32][D][ble_adv_light:035]: BleAdvLight::write_state - Switch OFF
[10:50:32][D][fanlamp_pro:241]: FanLamp - v1a - ID: '0x388E6F12', tx: 7, Command: '0x11', Args: [0,0,0]
[10:50:32][D][fanlamp_pro:241]: FanLamp - v1b - ID: '0x388E6F12', tx: 7, Command: '0x11', Args: [0,0,0]
[10:50:32][D][fanlamp_pro:291]: FanLamp - v2 - ID: '0x388E6F12', tx: 7, Command: '0x11', Args: [0,0,0,0]
[10:50:32][D][fanlamp_pro:291]: FanLamp - v3 - ID: '0x388E6F12', tx: 7, Command: '0x11', Args: [0,0,0,0]
[10:50:32][D][ble_adv_controller:142]: my_controller - request stop advertising
[10:50:32][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.03.77.F8.B6.5F.2B.5E.00.FC.31.51.50.F2.9E.08.24.CB.DB.FC.1B.C9.76.BF.39.2D.35.1E (31)
[10:50:32][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.03.F9.08.49.13.F0.69.25.4E.31.51.BA.32.D0.0E.24.CB.3B.1C.71.0D.5A.AE.46.5E.2B.4C (31)
[10:50:32][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.16.F0.08.10.80.BC.52.71.61.B1.28.29.44.F2.70.FE.63.76.E4.86.8F.43.D6.64.03.3F.21 (31)
[10:50:32][D][ble_adv_controller:130]: my_controller - request start advertising: 02.01.02.1B.16.F0.08.10.80.1C.F2.D1.C1.11.88.89.E4.52.D0.5E.C3.D6.44.26.E5.9C.76.C4.3C.5E.03 (31)
[10:50:32][W][component:237]: Component ble_adv_controller took a long time for an operation (62 ms).
[10:50:32][W][component:238]: Components should block for at most 30 ms.
[10:50:35][D][ble_adv_controller:142]: my_controller - request stop advertising

SAme result :frowning:
@NicoIIT

Is it possible to control a BL fan/light directly with a USB Bluetooth dongle from my NAS which is running Home Assistant?

It should be possible, but not with this esphome based solution a priori which needs an ESP32 microcontroller.

Porting it to HA with its bluetooth component would require a very important amount of work (not the same coding language nor base framework), but you can try :smile:

What about this application? GitHub - MasterDevX/lampify: A simple CLI application to control the BLE lamp

From what I understand it runs on a normal server with USB Bluetooth adapter. However it seems to only control lights and it is not Home Assistant compatible?

Is there any easy ESP32 with usb I can connect to my server and use for my ceiling fan with light that is using the FanLamp Pro Bluetooth app.

If I go the ESP32 route, is there some specific board I should get? And do you communicate from HA to the ESP32 board with WiFi which in turn connects to the ceiling fan with Bluetooth? Have you placed the board close to the fan or close to the server? I have no USB connection in the fan, otherwise it would be nice to integrate it into the fan.
Would this board work well?

My ceiling fan with light is controlled with FanLamp Pro on iOS

Any ESP32 should work, I personally use an ESP32 WROOM. ESP32-C3 should also work. Communication with HA is indeed done in WiFi and messages are broadcasted to the ceiling fan in Bluetooth Low Energy, 4.0 minimum. My board is near the server and 4m from the fan, but it can be relatively far from your WiFi router as it uses WiFi 2.4G. After flash and first install, the USB is only used to power on the board, or you could use a 220v / 3.3v or 220v / 5.0v small alim if you want to install it in the Fan.

Awesome work @NicoIIT , I am using the same code posted by @daicon and im having almost the same results , I have this ceiling Fan https://www.amazon.com/dp/B0C78MHCGZ that uses the FanLamp Pro app.

edit: managed to make it work :metal: , the problem I was having was the pairing

it is possible to manage different Fan speeds ? can you give me some advice how to do it ?

How work? I cant pair
Any help?

Hey @daicon , in my case first I was trying to do the pair manually with the wall switch.

My wall switch is a smart-switch , so I can control it also from Home Assistant , but I was doing it manually with the first test (trying to pairing) then I started to do it from home assistant so I think this cut a delay I was having between the pairing mode of the fan and the wall switch , I try it in different ways like first pressing the pair button from the home assistant and then turn off/on the smart-switch and then the other way around ( first the fan control “setup” button and then the pair button from Home assistant ) . hope it helps

Mmm,
I understand.
But my wall switch is not smart.

What I don’t understand is that you have a button on the fan control that is “configuration”???
I didn’t understand that.

I only have to use the mobile app to pair, I don’t have to do anything with the fan controller.

Fan Speed, Light Brightness and Temperature, all is included already. From the ESP device page In HA simply click on the name of your Fan entity, it will open a window where you can handle Fan speed and direction.

but your device does not have a physical control and a button to pair BT ? like :

image

I don’t think my smart-switch make it different ,just to have the correct timing to pair it it was the difficult past, in my case i think I was losing time going to the wall switch and then to the computer to click the pair button

Also I see on your logs

[10:50:32][W][component:238]: Components should block for at most 30 ms.

I think thats when you are trying different encodings , when that shows its not working

my current config, witch could or not be the same as yours is

300
FanLamp - v3

Thank you @NicoIIT , Yes <3 .
didn’t saw it first because its in % percentage

1 Like

In fact yes and no, this warning indeed happens when you use multiple encodings because it takes time to compute all of them, and then more time than what ESPHome think is reasonnable to spend in a component, thus the warning issued by ESPHome. Still it has nothing to do with the result of the pairing given that it is not possible to know from the ESP if the pairing was successful or not given that communication is unidirectional.

1 Like

I am having the hardest time getting anything related to this working. Granted, this is my first time ever using an ESP32 and ESPHome. I’m using an ESP-WROOM-32 and it’s been a struggle even getting it set up with the firmware—it keeps cutting out mid upload. After plugging it directly into my HA Green over USB and uploading the firmware that way, I can get it to appear on my network and I can access it via my web browser, but it loses network access soon after doing anything. I got my light to turn off once, and then the ESP32 just drops off the network.

I’m guessing this is a hardware issue. Maybe this particular board can’t handle using BLE and Wifi at the same time? Does this sound possible?

@NicoIIT

I got another of the same fan and tried your latest changes in main. Works flawlessly!

Only note for others is sometimes you get a fan that uses one version of the protocol and sometimes its another. The first fan i bought used v3 and this newest one uses v1b. All the functions seem to work the same but if you are having trouble pairing you should change the version and try again.

I hope all the features work on the other protocol versions/variants, so far it seems just fine

EDIT: One more thing, i see you added duration as a slider in HA. Can I get the same for min_brightness? Thanks a bunch!

If the device cannot completely upload a firmware that will give trouble. It should complete 100%. Try plugging in the device to a desktop or laptop computer and using https://web.esphome.io/ on that computer to flash the default installation. After this completes it should take you to a captive portal of your esp32 device. Then you know the HA Green is not properly able to flash the device.

I got the firmware installed, YAML below. The trickiest thing is finding a place to actually put the ESP32 that gets good WiFi and good BLE to the light fixture. How is BLE with going through walls, etc?

I believe I have it in a good spot but it’s hard to tell because I can’t get anything to work. The light fixture connects perfectly fine to my phone using the LampSmart Pro app but none of the variants seem to pair.

Any idea what to try next?

substitutions:
  name: esphome-web-1298a0
  friendly_name: ESPHome Web 1298a0

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  min_version: 2024.6.0
  name_add_mac_suffix: false
  project:
    name: esphome.web
    version: '1.0'

esp32:
  board: esp32dev

# Enable logging
logger:

# Enable Home Assistant API
api:

# Allow Over-The-Air updates
ota:
- platform: esphome

# Allow provisioning Wi-Fi via serial
improv_serial:

wifi:
  # Set up a wifi access point
  # output_power: 16
  ap: {}

# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:

dashboard_import:
  package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main
  import_full_config: true

# Sets up Bluetooth LE (Only on ESP32) to allow the user
# to provision wifi credentials to the device.
esp32_improv:
  authorizer: none

# To have a "next url" for improv serial
web_server:

external_components:
  # shorthand
  source: github://NicoIIT/esphome-components

ble_adv_controller:
  - id: my_controller
    encoding: lampsmart_pro
    duration: 200

light:
  - platform: ble_adv_controller
    ble_adv_controller_id: my_controller
    name: Kitchen Light

button:
  - platform: ble_adv_controller
    ble_adv_controller_id: my_controller
    name: Pair
    cmd: pair

My ESP32 works through the wall with such a lamp. The distance from the ESP to the lamp is about 3 meters