This code can be used to program an ESP board to act as an intermediate between Home Assistant and LEDVANCE Bluetooth bulbs. It supports On/Off and also setting the brightness level.
It is based on the On-Off client example from the ESP idf examples
The code is not clean or anything but it works and might help others to write better code.
To install the code on the ESP follow the steps below:
What you need:
- nRF Mesh App (https://www.nordicsemi.com/Products/Development-tools/nrf-mesh/getstarted) -> To provision the lamps and the ESP
- ESP board
- ESP IDE -> If not already done, follow the Getting Started guide to install the ESP IDE (I used the VSCode Extension) https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html
- Provision the lamps with the nRF Connect App (they need to be in pairing mode to be provisioned)
- In the App, assign it an Application Key
- In the Elements of the App, assign the same Application Key to the following Elements:
(Not sure if all of them are really required but this is how it works for me)
- Generic OnOff Server
- Generic Level Server
- Generic Power OnOff Server
- Light Lightness Server
- The lamp will now have an Unicast Address -> take a note of this
- Repeat the steps above for all your lamps
- Clone the repository
- Adopt the sdkconfig example with your WIFI password and the Home Assistant credentials (create a new User in HA to use with MQTT) & rename the file to sdkconfig
- Build and flash the project to your ESP
- Open the IP address of your ESP and add your lights on the homepage. Name & Unicast Address (from Step 4) are required (whenever new lamps are added, the ESP will require a restart so that the MQTT subscribes also to the newly added lights)
- Restart the ESP32 to load the new config at startup
- Provision the ESP -> same as Steps 1-3, with the following Elements:
- Generic OnOff Client
- Generic Level Client
- Light Lightness Client
Example config message:
Topic: homeassistant/light/test/config
Payload:
{
"name":null,
"~":"homeassistant/light/test",
"cmd_t":"~/set",
"stat_t":"~/state",
"schema": "json",
"brightness": true,
"bri_scl":50,
"pl_on": "ON",
"pl_off": "OFF",
"uniq_id":"lamp04",
"dev":{
"ids":[
"lamp04"
],
"name":"Lamp Office"
}
}
Once the entity appears in Home Assistant, it should work.