New: the AI firewall watches the whole platform and explains each incident in plain words. See how it works

Dimming BLE lamps from a dashboard slider via an ESP32 bridge

Dimming BLE lamps from a dashboard slider via an ESP32 bridge

Solved 4 3

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.

♥ 0

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.

Sahadan selamlar.
♥ 0

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.

♥ 2

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:

  1. Added the light.set command to the dimmers’ profile (not the gateway’s), Basic tier, parameter level (Number, 0-100).
  2. 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.
  3. Bound the Current value slot to the level telemetry of the same child, so the card shows the dimmer’s real value.
  4. 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ı

Accepted solution♥ 5

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.

♥ 0
Viewing 5 posts – 1 through 5 (of 5 total)
  • 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.

Share