BT and Lighting System: Basic advice

Hi! I have an Alliance BT lighting system, which has a terrible interface and uses BTLE for the transformer as well as each individual lights. I want to create my own controls for the system that I would like to integrate into Home Assistant through MQTT.

I have figured out the basics for on-off control of the transformer through sniffing (the first and most important step) and set up my ESP32 with OpenMQTT. I am seeing the devices and seem stuck in being able to use the ESP32 to write commands to the device.

I am very new to this, so maybe just formatting and basic direction, her is what I have:

  1. Know the service UUID.
  2. Know the characteristic UUID (which is a custom one).
  3. The write values in binary are 0x01 for “ON” and 0x00 for “OFF”
  4. My home base computer is mac, and I am using MQTT Explorer which seems to be sending the publish command, but this is where I am not sure how to set this up or format the commands as there is no response.
  5. I am able to use nRF Connect to send command with no issues
  6. Ultimately want to send these commands through MQTT via home assistant.

Thank you for helping me and walking me through the necessary steps.

Hi @amellomd,

with knowing the service uuid and characteristics uuid, did you have a look at the documentation section for using the READ and WRITE commands?

Possibly try it with the uudis in the full 128-bit, but also just with the 16-bit versions of them, as some of my devices seem to only respond to the 16-bit version.

Hope this gets you closer to controlling your lighting system with OMG :slight_smile:

Thanks I’ll try to 16-bit versions. Also seems that using nRF, is issuing a WRITE request and not a WRITE command (which doesn’t work). Is there a specification in the MQTT topic that can specify write request?

Thanks

I assume it’s the difference between Write With and Without Response, which are both implemented in OMG.

Could you post the service and characteristic uuids here, together with the complete WRITE command you’re trying to send?

1 Like

I am using MQTT.fx to publish=test:

Topic: home/OpenMQTTGateway_ESP32_BLE_C/commands/BTtoMQTT/config -m
Payload:
{
“ble_write_address” : “CC:3B:3E:11:1A:06”,
“ble_write_service” : “3a3e0eae-edbf-11e4-90ec-1681e6b88ec1”,
“ble_write_char” : “f36c1708-1c28-11e5-9a21-1697f925ec7b”,
“ble_write_value” : “01”,
“value_type” : “TEXT”,
“ttl” : 4,
“immediate” : true
}

Also, I’ve tried value type “HEX” with “0x01” as well for value

home/OpenMQTTGateway_ESP32_BLE_C/commands/MQTTtoBT/config

easy to miss when starting with the commands :wink:

and I would also keep HEX to test with the above, but just with "00"/"01"

Also be aware of the curly quotation marks when copy and pasting here, to be avoided by preformatting the relevant text (</> in the above formatting options )

Thanks…duh…

At least now I receive a response back from the device:

{
“id” : “CC:3B:3E:11:1A:06”,
“service” : “3a3e0eae-edbf-11e4-90ec-1681e6b88ec1”,
“characteristic” : “f36c1708-1c28-11e5-9a21-1697f925ec7b”,
“write” : “01”,
“success” : true
}

However still not triggering effect “Turn ON/OFF”. I suspect there is a difference for this device between write REQUEST and write COMMAND, still works fine with nRF with write REQUEST…just haven’t been able to figure out how to differentiate with mosquitto_pub or MQTT topic command.

And also no luck with the 16-bit uuids? …

{
"ble_write_address" : "CC:3B:3E:11:1A:06",
"ble_write_service" : "0eae",
"ble_write_char" : "1708",
"ble_write_value" : "01",
"value_type":"HEX",
"immediate" : true
}

otherwise it could really have to do with

or the binary "00"/"01" not corresponding to the respective hex values.

No. When using 16-bit, returns “Success”: false

Apparently, while hunting this down, some manufacturers will only program for write request to be accepted, not write command. Even though for BLE, these are only differentiated by a return message (with request). I guess will need to figure out how to parse this difference into OMG and define the applicable MQTT command…?

Yes, that could very well be and might need looking into, not knowing too much about that side of the BLE library myself.

Just out of curiosity, what HEX values do you get when READING the relevant service/characteristic with nRF Connect?

Value: “(0x) 01” received when reading for the characteristic

So it is probably the write REQUEST vs. write COMMAND issue, where I unfortunately can’t help any further.

Thanks so much, you’ve been extremely helpful!

I’m sure someone with the appropriate expertise on that side will comment further on your issue so that it will work in the future :slight_smile:

Hi there. How have things progressed? I’m in the same boat and would love to know if youvr sold the problem?!

@h2zero do you think we could add write request on the mqtt api?

We could certainly add it if needed but this issue should be resolved as of Use write with response non-response write is not available. (#1136) · 1technophile/OpenMQTTGateway@8b40b68 · GitHub

If not, I can look at adding this to the api.

1 Like

Hi,

Could you try with the last version?