Controlling BLE ceiling light with HA

Not sure what guide you need as @aronsky has already put the details in his github.

If you have any specific questions, you can ask here and see if anyone can answer. :slight_smile:

Depends how noob is noob. Before I came across this I hadn’t had any reason to set up ESPHome in HA. I’ve played with ESP boards for various things before but if you haven’t this is pretty daunting.

Prerequisites:

  • Home assistant installed
  • ESPHome addon installed
  • some form of ESP32-based development board (I’m using a nodeMCU ESP32S)
  • a USB lead to connect the ESP dev board to a computer
  • Chrome/Edge browser (supports USB device interactions)

There might be some driver stuff you need too so that your computer can talk over USB serial to the device. Sorry, can’t remember. This page might help

Steps

  1. Open ESPHome from Home Assistant on a computer
  2. Plug in your ESP USB device
  3. Click “New device”
  4. Give it a name
  5. Click “Connect”
  6. Select the port (here it’s /dev/ttyUSB0)
  7. Wait a while (and it is a while especially the first time) for the ESPHome firmware to build in the background, then upload to your device. If this step doesn’t work, you may need to check out the link above for pointers
  8. Once you’ve got a device installed, it should appear as “online” in the ESPHome dashboard
  9. Click “Edit” to view the config.yaml
  10. Copy the following at the end of the file:
external_components:
  source: github://aronsky/esphome-components

light:
  - platform: lampsmart_pro_light
    name: My Light
    duration: 1000
    default_transition_length: 0s
  1. Click “Install” - you should be able to install wirelessly if your ESP board is online
  2. Once it’s installed, go to Settings → Devices and Integrations
  3. Add the newly-discovered ESPHome device (if not appearing, add the ESPHome integration)
  4. Put your board near the light you want to control
  5. Open Developer Tools → Services in Home Assistant
  6. Search for ‘pair’ to find the pairing service
  7. Put your light in pairing mode (here that’s switch it off, then on again)
  8. Click “Call service” (within 5 seconds of powering on)
  9. Hopefully, that’s your light paired!
  10. You can now toggle your light on and off and set brightness and temperature using Home Assistant

I do appreciate the irony that I’m writing this all out, having failed to get it working myself, but I don’t think that’s because of anything I’ve written above. My lights just seem to be uncooperative.

1 Like

Great guide…Just take note the pairing must be done within 5 secs of turning on the lights.

Sad to hear you have not yet managed to get your lights working. Hope you can be successful soon! :slight_smile:

thanks - I’ve added the 5 seconds comment.

Yeah, I’m currently waiting for the builders to get out of the way later this week so I can sit directly under the offending light for 30 minutes and do some proper testing! :grinning_face_with_smiling_eyes:

1 Like

Hey guys, quick and simple question (I hope) - what if my base codes are different for my lamp ?
How can I easily alter the code from Aronsky and pass it to ESPHome - without publishing a new repo on Github and linking ESP to it ?

You could try downloading and editing just the lampsmart_pro_light.cpp and .h files then adding them as an include:

esphome:
  includes:
    - my_custom_component.h

…but I’ve no idea if that will work. I forked the repo and pointed my ESPHome config at that.

Something like that, indeed, so, to bring a github repo locally in ESPHome:

  • clone repo under /esphome/my_components (or any folder structure you want under the esphome config root)
  • add it as an external component in yaml:
    external_components:
    source: my_components
  • add the component normally:
    light:
    platform: lampsmart_pro_light

I’ll play around with it locally and post any meaningful findings.

@aronsky Thanks for figuring this out!

Currently I use HA with a RPi3, how would I go about it to make an integration that would use the internal bluetooth of the RPi? As I have no prior experience with ESP and would like to avoid any extra cables.

I tried sniffing out the commands via HCI on android to be able to send out these command via a RPi to the controller provided with the light, however the commands were really not readable. Anyone any luck with using the RPi combined with the included controller?

Basically, you have to figure out how to send BLE advertisement packets in Home Assistant. Once you can do that, all it should take is go through the code of my component, see how the packets are built, and send similar packets from Home Assistant.

1 Like

@aronsky Thanks, i’ll give it a try maybe in the future. Not familiar with c++ and BLE, so a bit too challenging for now.

For now I just order an ESP32:)

Thanks all for the help, especially aronsky for the repository and jymbob for the tutorial.
I got my ESP up and running and the logs are working.

However, I am unable to pair with my lights (after turning off and on and pairing within 5 seconds). I looked into the logs within ESPHome in Home assistant and get the following when running the service:

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

I’m using the NodeMCU-32S board and the LampSmartPro app is working perfectly fine. A different light than previously mentioned in topic is used. @jymbob , I followed your tutorial, but saw you were having a simillar issue as I have. Did you manage to solve the issue?

Not yet. We’re in the middle of building works so I haven’t had a huge amount of time to fiddle with this. That should be finishing in the next week or so, so I might be able to get back to it then.

Hi everyone, thanks for the awesome work @aronsky, and for the really helpful noob guide, @jymbob!

It helped me thus far, and after figuring out that my ESP32 was not installing because my USB cable was a power cable and not a data cable, I finally got the ESP online!

Now I am following the noob guide closely, but was not able to find the pairing service in step 16. Am I doing it right?

Did you do step 12? Going over to Integrations and Installing the newly discovered ESPHome

Yes sir, it is BobESP, added and “online” state.

Actually, I uninstalled and reinstalled everything and it’s working now! I don’t really know what went wrong, but thanks again @jymbob!

1 Like

I feel your pain: I went through at least 4 micro-USB cables lying around in a drawer before I found one that actually had working data pins!

After not paying attention to the forum for the last 4 months, really happy to see the multiple light option working! Finally able to run 4 lights on just on ESP32, thanks for the awesome work!

Hello everyone and many thanks to @aronsky.
According to the recommendations in this topic, I set up ESP 32 and connected the chandelier to the Home Assistant.

However, I have a chandelier with fans and it is completely controlled from the Fan Smart Pro application.
Is it possible to add fan control on the chandelier to your firmware?

Question 2: The chandelier allows you to link only one thing - the application or ESP32, but in the application you can find out "current_uuid":"46f0b210-8b6b-4558-829a-885733b43268".

Is it possible to specify this UID in your firmware so that both the application on the phone and ESP32 work at the same time?