Dimming BLE lamps from a dashboard slider via an ESP32 bridge
Translated from Türkçe by AI ·
Hi. We have 6 cheap BLE LED dimmers in the workshop. The good part is that brightness is set by writing a single byte between 0 and 255 to one GATT characteristic; I tested it with nRF Connect and it works. I built an ESP32 as a bridge: it connects to the dimmers over BLE and to Hermetry over Wi-Fi using MQTT. The dimmers show up as child devices of the gateway, and I send their brightness with v1/gw/telemetry, and the graphs come in.Now I’ve put a Slider on the dashboard, but the card says “Choose a command in this widget’s settings” and I’m stuck. I don’t know where to define the command and how the ESP32 will receive it. Since the dimmers are separate devices, I think I need to attach the slider to the child device.
Selam. Atölyede 6 tane ucuz BLE LED dimmer var. Güzel tarafı, parlaklık tek bir GATT karakteristiğine 0-255 arası tek bayt yazılarak ayarlanıyor, nRF Connect ile denedim çalışıyor. Bir ESP32’yi köprü yaptım: BLE’den dimmer’lara bağlanıyor, Wi-Fi’dan MQTT ile Hermetry’ye bağlı. Dimmer’lar gateway’in child cihazları olarak görünüyor, v1/gw/telemetry ile parlaklıklarını gönderiyorum, grafikleri geliyor.
Şimdi panoya bir Slider koydum ama kartta “Choose a command in this widget’s settings” yazıyor ve takıldım. Komutu nereye tanımlayacağımı ve ESP32’nin bunu nasıl alacağını bilmiyorum. Dimmer’lar ayrı ayrı cihaz olduğu için slider’ı child cihaza bağlamam gerekir diye düşündüm.
Translated from Türkçe by AI ·
Did you define the command in the Commands tab of your profile? The dashboard can only send commands from the profile’s catalog, it does not accept raw methods.
Profilin Commands sekmesinde komut tanımladın mı? Pano sadece profilin kataloğundaki komutları gönderebiliyor, ham method kabul etmiyor.
Translated from Türkçe by AI ·
I defined it. light.set, with parameter level. I first set the Tier to Privileged, got the “This command cannot be sent from a board” error, then moved it to Basic. But when I select the child device, the command doesn’t go out, it stays at Sent.
Tanımladım. light.set diye, parametre level. Tier’ı Privileged yaptım önce, “This command cannot be sent from a board” hatası aldım, Basic’e çektim. Ama child cihazı seçince komut gitmiyor, Sent’te kalıyor.
Translated from Türkçe by AI ·
The child gets the command, and the spot you’re stuck on is the ESP32 side. A command sent to a device behind the gateway comes down to the gateway over v1/gw/rpc, and shared attribute changes come over v1/gw/attributes. Your code most likely only listens on v1/rpc/req/+, which is for the gateway’s own commands. That’s why the command stays in Sent. I got stuck in the same place with the water stations too.Here’s what I did:
- Added the light.set command to the dimmers’ profile (not the gateway’s), Basic tier, parameter level (Number, 0-100).
- On the slider card: Run a command: Device = atolye-3 child, Command = light.set, for level The control’s value. I convert the 0-100 slider to 0-255 on the ESP32 side.
- Bound the Current value slot to the level telemetry of the same child, so the card shows the dimmer’s real value.
- For the light I turned off Ask before running, so it doesn’t ask for confirmation on every slide.
On the ESP32 side, after every connection, subscribe to v1/gw/rpc. Print the incoming message to the serial port first and look at its structure, then work out which child it’s for from there and do the BLE write:
mqtt.subscribe("v1/gw/rpc", 1);
void onMsg(char* topic, byte* payload, unsigned int len) {
if (strcmp(topic, "v1/gw/rpc") == 0) {
Serial.write(payload, len); // önce yapıya bak
Serial.println();
// child adını ve level'ı çöz:
// bleSetLevel(name, map(level, 0, 100, 0, 255));
}
}
The control card rules are here: Kontrol kartları
Child’a komut gidiyor, takıldığın yer ESP32 tarafı. Gateway arkasındaki bir cihaza gönderilen komut gateway’e v1/gw/rpc üzerinden iniyor, shared attribute değişiklikleri de v1/gw/attributes üzerinden. Senin kod büyük ihtimalle sadece v1/rpc/req/+ dinliyor, o da gateway’in kendi komutları için. Komut o yüzden Sent’te kalıyor. Ben de su istasyonlarında aynı yerde takılmıştım.
Yaptığım şey şöyle:
- light.set komutunu dimmer’ların profiline ekle (gateway’inkine değil), Basic tier, parametre level (Number, 0-100).
- Slider kartında Run a command: Device = atolye-3 child’ı, Command = light.set, level için The control’s value. 0-100 slider’ı ESP32 tarafında 0-255’e çeviriyorum.
- Current value slot’unu aynı child’ın level telemetrisine bağla, kart dimmer’ın gerçek değerini göstersin.
- Işık için Ask before running’i kapattım, her kaydırmada onay sormasın.
ESP32 tarafında her bağlantıdan sonra v1/gw/rpc‘ye abone ol. Gelen mesajı önce seri porta bastırıp yapısına bak, hangi child için geldiğini oradan çözüp BLE yazmasını yaparsın:
mqtt.subscribe("v1/gw/rpc", 1);
void onMsg(char* topic, byte* payload, unsigned int len) {
if (strcmp(topic, "v1/gw/rpc") == 0) {
Serial.write(payload, len); // önce yapıya bak
Serial.println();
// child adını ve level'ı çöz:
// bleSetLevel(name, map(level, 0, 100, 0, 255));
}
}
Kontrol kartlarının kuralları burada: Kontrol kartları
Translated from Türkçe by AI ·
It works, thanks. The ESP32 wasn’t actually subscribed to v1/gw/rpc, and I had put the command in the gateway’s profile. I added 6 sliders, each one bound to its own child. Also, the slider only sends when released. I thought it was sending on every movement and was getting ready to write a queue on the ESP32, but it’s not needed now.
Çalıştı, sağ olun. ESP32 gerçekten v1/gw/rpc’ye abone değilmiş, komutu da gateway’in profiline koymuşum. 6 slider koydum, her biri kendi child’ına bağlı. Bir de slider sadece bırakınca gönderiyor, ben her harekette gidiyor sanıp ESP32’de kuyruk yazmaya hazırlanıyordum, gerek kalmadı.
- You must be logged in to reply to this topic.
Join the conversation
Sign in to ask and answer, like helpful posts and mark the reply that solved your problem. Every contribution earns points and levels.

