Controlling BLE ceiling light with HA

Nope, the same error

Are you sure you effectivelly refreshed the repo? Please be sure to specify the external_components refresh as ESPHome is specifying it to 1 day by default.

external_components:
  - source: github://NicoIIT/esphome-components
    refresh: 0s

All is ok. The light are working without problems which I told early

Not possible to update, got error that componnet not found

  
  Component not found: ble_adv_controller.
  - id: my_controller
    encoding: fanlamp_pro
    variant: v3
    duration: 200
    reversed: False
    forced_id: 0

this is my code:

external_components:
  - source: github://NicoIIT/esphome-components
    components: [ble_adv_controller]
    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
    # duration: the duration during which the command is sent. 
    # Increasing this parameter will make the combination of commands slower, 
    # but it may be needed if your light is taking time to process a command
    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

EDIT: Seems needed to delete componenet…

I splitted the component in 2: ble_adv_controller and ble_adv_handler, in order to ease future integration of ble_adv_remote component, and both are needed to have it work (even if it is transparent in the config). Still if you filter the components to only ble_adv_controller, you will miss ble_adv_handler.

For the adventurous ones, big update is available in dev branch: the components are now able to listen and decode the BLE ADV messages, and then new features are available:

  • Updated list of officially fully supported Phone Apps, with corrected variants to send exactly the same messages than the Phone Apps
  • Listening to Phone App traffic and extract parameters to shadow it with a ble_adv_controller without the need to pair the ESP32
  • Listening to physical remotes and update HA state when remote is used, or do whatever action you want
  • BLE ADV raw message decoding and injection, for the ones that have devices that cannot be controlled by the Phone Apps given.

doc (beta)

Configuring dev branch:

external_components:
  - source: github://NicoIIT/esphome-components@dev
    refresh: 0s

Please note some other changes have been done in the variant names, custom buttons and verifying the forced_id. Just follow the error messages if any and it should help you perform migrations.

Should you face issues or want your remote to be supported, you can open issues here, providing the needed DEBUG logs and your config.

3 Likes

I just updated things seem to work so far. My remote was working before does the update take the remote function away?

never mind remote still works

WOW! Thanks to all contributors! Great job!

i tryed a few months ago and were imposible to connect, today i have connected to a zhiguang and a lampsmart_pro, still testing but almost it works

@NicoIIT
I tryed to use the ‘dev’ branch, but when compiling i’m getting an error on ‘cmd: pair’

This is the log i’m getting:

INFO ESPHome 2024.9.1
INFO Reading configuration /config/esphome/blelamp-controller.yaml...
INFO Updating https://github.com/NicoIIT/esphome-components.git@dev
Failed config

button.ble_adv_controller: [source /config/esphome/blelamp-controller.yaml:52]
  platform: ble_adv_controller
  ble_adv_controller_id: EntradaLamparaController
  name: Emparejar Entrada
  
  ble_adv_controller button is DEPRECATED, please perform migration to standard template button and ble_adv_controller 'pair' Action:
  From:
  
  button:
    - platform: ble_adv_controller
      ble_adv_controller_id: my_controller
      cmd: pair
  
  To:
  
  button:
    - platform: template
      entity_category: config         # only if you want to have the button in the 'Configuration' part in HA
      on_press:
        ble_adv_controller.pair: my_controller.
  cmd: pair

Well everything is in the error message I think: you have a small change to do in the configuration if you want to keep the pair button. This was done in order to be more in line with ESPHome spirit which is to work with actions instead of creating new custom entities.

So for you, as indicated in the error message, the pair button should be replaced by:

  button:
    - platform: template
      entity_category: config
      name: Emparejar Entrada
      on_press:
        ble_adv_controller.pair: EntradaLamparaController

Thank you Nico.
I commented the button code part to test the ‘dev’ branch and appears to work well.

Testing the lampsmart_pro (v1) i set the reverse parameter and all works like a charm.

The zhiguang (v0) lamp turns on and off well but looks that if i use any other function like bright or color temperature only every time is setting the same state (bright and color)

if i have any time i’m going to try to test/debug the remote commands but i’m still not very familiar with esphome :slight_smile:

The zhiguang (v0) lamp turns on and off well but looks that if i use any other function like bright or color temperature only every time is setting the same state (bright and color)

Try option separate_dim_cct: true at light level, as described in doc here.

Uooo! you made it!
all is working!!!

thank you so much!
i readed before the option of separate cct, but forget it after reading, configuring and test.

Nico, please, let me buy you a beer.
Your work and help make my day!

Edit to post the esphome code, maybe it can help someone:

external_components:
  - source: github://NicoIIT/esphome-components@dev
    refresh: 0s

ble_adv_controller:
  - id: EntradaLamparaController
    encoding: zhiguang
    variant: v0
    reversed: True
  - id: SalonLamparaController
    encoding: lampsmart_pro
    variant: v1
    reversed: True

light:
  - platform: ble_adv_controller
    ble_adv_controller_id: EntradaLamparaController
    separate_dim_cct: True
    name: Entrada Lampara
  - platform: ble_adv_controller
    ble_adv_controller_id: SalonLamparaController
    name: Salon Lampara

button:
  - platform: template
    entity_category: config
    name: Emparejar Entrada
    on_press:
      ble_adv_controller.pair: EntradaLamparaController
  - platform: template
    entity_category: config
    name: Emparejar Salon
    on_press:
      ble_adv_controller.pair: SalonLamparaController
1 Like

Hello! I’ve bought a led ceiling lamp working with the LampSmart pro app and a remote as well.
I’ve a spare ESP32 C3 super mini to test it out.
Can you share a link where I can find the yaml file to be compiled into the esp32?
Many thanks!

Had this working, but it seems to have stopped, tried to update it but getting an error while installing it.

Have this installed on a SMLIGHT.SLZB-06. I have noticed that it seems to turn the light off when the app starts. Not sure if that is default behavior but it seems to be in a boot loop on what is installed on the device so tried upgrading using the configuration options specified below. What am I missing?

external_components:
  - source: github://tube0013/esphome-stream-server-v2
# Office Fan Support
  - source: github://NicoIIT/esphome-components@main
    components: [ble_adv_controller, ble_adv_handler]

# 9. Office Fan Control
ble_adv_controller:
  - id: officefan
    encoding: fanlamp_pro
    variant: v2
    duration: 500

light:
  - platform: ble_adv_controller
    ble_adv_controller_id: officefan
    name: Office Light    

fan:
  - platform: ble_adv_controller
    ble_adv_controller_id: officefan
    name: Office Fan    

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

INFO ESPHome 2024.10.2
INFO Reading configuration /config/esphome/slzb-06-thread_bluetooth-167850.yaml...
WARNING 'slzb-06-thread_bluetooth': Using the '_' (underscore) character in the hostname is discouraged as it can cause problems with some DHCP and local name services. For more information, see https://esphome.io/guides/faq.html#why-shouldn-t-i-use-underscores-in-my-device-name
WARNING GPIO5 is a strapping PIN and should only be used for I/O with care.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO12 is a strapping PIN and should only be used for I/O with care.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
INFO Generating C++ source...
INFO Compiling app...
Processing slzb-06-thread_bluetooth (board: esp32dev; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
Library Manager: Installing esphome/noise-c @ 0.1.6
INFO Installing esphome/noise-c @ 0.1.6
Unpacking  [####################################]  100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Library Manager: Resolving dependencies...
INFO Resolving dependencies...
Library Manager: Installing esphome/libsodium @ 1.10018.4
INFO Installing esphome/libsodium @ 1.10018.4
Unpacking  [####################################]  100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- WiFi @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- noise-c @ 0.1.6
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/api/api_connection.cpp.o
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/api/api_frame_helper.cpp.o
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/api/api_pb2.cpp.o
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/api/api_pb2_service.cpp.o
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/api/api_server.cpp.o
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/api/list_entities.cpp.o
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/api/proto.cpp.o
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/api/subscribe_state.cpp.o
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/api/user_services.cpp.o
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/binary_sensor/automation.cpp.o
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/binary_sensor/binary_sensor.cpp.o
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/binary_sensor/filter.cpp.o
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/ble_adv_controller/ble_adv_controller.cpp.o
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/ble_adv_controller/button/ble_adv_button.cpp.o
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/ble_adv_controller/fan/ble_adv_fan.cpp.o
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/ble_adv_controller/light/ble_adv_light.cpp.o
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/ble_adv_handler/ble_adv_handler.cpp.o
Compiling .pioenvs/slzb-06-thread_bluetooth/src/esphome/components/ble_adv_handler/fanlamp_pro.cpp.o
src/esphome/components/ble_adv_handler/ble_adv_handler.cpp: In member function 'bool esphome::ble_adv_handler::BleAdvHandler::identify_param(const esphome::ble_adv_handler::BleAdvParam&, bool)':
src/esphome/components/ble_adv_handler/ble_adv_handler.cpp:276:117: error: expected primary-expression before ';' token
         nodiff ? ESP_LOGI(TAG, "Decoded / Re-encoded with NO DIFF") : ESP_LOGE(TAG, "DIFF after Decode / Re-encode");
                                                                                                                     ^
*** [.pioenvs/slzb-06-thread_bluetooth/src/esphome/components/ble_adv_handler/ble_adv_handler.cpp.o] Error 1
========================= [FAILED] Took 13.09 seconds =========================

Still unable to install with the above compilation error. Anyone have any ideas?