But when I use the remote that comes with the lamp nothing appears… so I guess the remote is not bluetooth, but then why the lamp is transmitting some bluetooth signal?
Is there a possibility to control it via OpenMQTTGateway or it is encrypted?
this sounds interesting, as far as I knew Philips Hue was all Zigbee, and I would assume that the remote still controls the lamp via Zigbee, but obviously your dimmable white lamp also broadcasts some BLE info, possibly off its state.
While it’s unlikely it’ll be possible to control the lamp via bluetooth, it could be interesting to find out what the broadcasts represent. For that you would need to send the full MQTT messages with the clear “servicedata”:“hexstring”,“servicedatauuid”:“otherhexstring” along with the concurrent state of the lamp, i.e. ON and dimmed to 30%.
Other than that it could just be a BLE braodcast for integration into the Hue app on a phone with BLE identification.
Unfortunately the two strings don’t change with the status of the lamp, I’ve tried off, on 100% and on dimmed and got always
“servicedata”:“0210dde606”,“servicedatauuid”:“0xfe0f”
By the way the lamp is this one: amazon.it/dp/B07SV87BBZ/
Yes, it seems to be controllable via bluetooth as well, when connected to the lamp. So the OpenMQTTGateway WRITE command should be able to control the lamp, the same as it’s possible to control the lamp with the Hue app on a phone just over bluetooth, that is if the communication is not encypted.
Now getting the correct service, characteristic and which hex codes to send to control would be the next step.
Searching GitHub for it, with results like this
should get you further, also exploring the services and characteristics with the nrfConnect app, and reading up on the WRITE command for OMG
I paired it to my laptop (I had to install Hue app on my phone to put the lamp in pairing mode) and read the attributes:
Primary Service (Handle 0x0009)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0039
b8843add-0000-4aa1-8794-c3f462030bda
Vendor specific
Characteristic (Handle 0x7324)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0039/char0041
b8843add-0004-4aa1-8794-c3f462030bda
Vendor specific
Characteristic (Handle 0x7324)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0039/char003f
b8843add-0003-4aa1-8794-c3f462030bda
Vendor specific
Characteristic (Handle 0x7324)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0039/char003c
b8843add-0002-4aa1-8794-c3f462030bda
Vendor specific
Descriptor (Handle 0x0015)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0039/char003c/desc003e
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
Characteristic (Handle 0xa528)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0039/char003a
b8843add-0001-4aa1-8794-c3f462030bda
Vendor specific
Primary Service (Handle 0xa920)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0023
932c32bd-0000-47a2-835a-a8d455b859dd
Vendor specific
Characteristic (Handle 0xc434)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0023/char0037
932c32bd-1005-47a2-835a-a8d455b859dd
Vendor specific
Characteristic (Handle 0xc434)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0023/char0034
932c32bd-0007-47a2-835a-a8d455b859dd
Vendor specific
Descriptor (Handle 0x0015)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0023/char0034/desc0036
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
Characteristic (Handle 0xe688)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0023/char0032
932c32bd-0006-47a2-835a-a8d455b859dd
Vendor specific
Characteristic (Handle 0xe688)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0023/char0029
932c32bd-0003-47a2-835a-a8d455b859dd
Vendor specific
Descriptor (Handle 0x0015)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0023/char0029/desc002b
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
Characteristic (Handle 0x0608)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0023/char0026
932c32bd-0002-47a2-835a-a8d455b859dd
Vendor specific
Descriptor (Handle 0x0015)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0023/char0026/desc0028
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
Characteristic (Handle 0x2d78)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0023/char0024
932c32bd-0001-47a2-835a-a8d455b859dd
Vendor specific
Primary Service (Handle 0xa920)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0011
0000fe0f-0000-1000-8000-00805f9b34fb
Unknown
Characteristic (Handle 0x3c84)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0011/char0021
97fe6561-a001-4f62-86e9-b71ee2da3d22
Vendor specific
Characteristic (Handle 0x3c84)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0011/char001f
97fe6561-2004-4f62-86e9-b71ee2da3d22
Vendor specific
Characteristic (Handle 0x3c84)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0011/char001d
97fe6561-2002-4f62-86e9-b71ee2da3d22
Vendor specific
Characteristic (Handle 0x3c84)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0011/char001b
97fe6561-2001-4f62-86e9-b71ee2da3d22
Vendor specific
Characteristic (Handle 0x3c84)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0011/char0018
97fe6561-0008-4f62-86e9-b71ee2da3d22
Vendor specific
Descriptor (Handle 0x0015)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0011/char0018/desc001a
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
Characteristic (Handle 0x9658)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0011/char0016
97fe6561-0004-4f62-86e9-b71ee2da3d22
Vendor specific
Characteristic (Handle 0x9658)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0011/char0014
97fe6561-0003-4f62-86e9-b71ee2da3d22
Vendor specific
Characteristic (Handle 0x9658)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0011/char0012
97fe6561-0001-4f62-86e9-b71ee2da3d22
Vendor specific
Primary Service (Handle 0xa920)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service000a
0000180a-0000-1000-8000-00805f9b34fb
Device Information
Characteristic (Handle 0xbad4)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service000a/char000f
00002a28-0000-1000-8000-00805f9b34fb
Software Revision String
Characteristic (Handle 0xbad4)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service000a/char000d
00002a24-0000-1000-8000-00805f9b34fb
Model Number String
Characteristic (Handle 0xbad4)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service000a/char000b
00002a29-0000-1000-8000-00805f9b34fb
Manufacturer Name String
Primary Service (Handle 0xa920)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0001
00001801-0000-1000-8000-00805f9b34fb
Generic Attribute Profile
Characteristic (Handle 0xdf44)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0001/char0002
00002a05-0000-1000-8000-00805f9b34fb
Service Changed
Descriptor (Handle 0x0015)
/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0001/char0002/desc0004
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
According to the python code I found here GitHub - walter5138/hue_ble_python: Project controlling Philips Hue Bluetooth Color bulbs. Python version. it seems the characteristic used to switch on/off the lamp is /org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/service0023/char0026.
Switching the lamp on and off with hue_on_off.py does work, but I don’t get what I should send via mqtt. Also I am not sure if it would work, since the lamp is not paired to my esp32 running OpenMQTTGateway.
The facts that I do not know nor bluetooth neither python do not help I guess
Yes, the pairing might be an issue, but did you have it paired when testing the hue_on_off.py on your PC?
So here you have the required service and characteristic already, which you would also need for an OpenMQTTGateway WRITE command, but for a dimmable lamp I would have expected not just an On/OFF, but possibly brightness setting, with 0 being OFF, 255 ON, and in between all the dimming states - hue_brightness_set.py?!?
But do try the ON/OFF first, with the service/characteristc given above with publishing to
the value 00 just being a test for switching the lamp OFF, 01 for ON, not having examined the code further, but you can also read the current value with your phone for /service0023/char0026
The brightness seems to use the same service, but characteristic 0029, so testing with the value (in hex between 00 - ff) would be my next trial
So I tried reading and writing to service 932c32bd-0000-47a2-835a-a8d455b859dd and char 932c32bd-0002-47a2-835a-a8d455b859dd but it didn’t work either.
Sending 00 or 01 via nrfconnect from my phone to 932c32bd-0002-47a2-835a-a8d455b859dd works so I guess that pairing is the issue
That’s seems to be the problem then on one hand good for security, on the other hand bad for not being able to use OpenMQTTGateway for controlling the lamp.
BTW - the name of your BLE OpemMQTTGateway is just OpenMQTTGateway, or is it possibly OpenMQTTGateway_ESP32_BLE if you’re using the default BLE binary?
The WRITE commands would need the proper gateway name to work, if at all possible.
Yes, it’s OpenMQTTGateway_ESP32_BLE from your first posting
I tried again all the commands, this time with the right topic. At least now I get a response from the lamp, unfortunately even when it reports “success” the lamp does not change state:
Most likely a pairing issue, what kind of pairing did it do when you connected with your phone? Did you need to enter a pin code or select yes/no? NimBLE should auto pair if the characteristic requires security to read/write to it, but if the device doesn’t respond with that being required when reading/writing then that won’t happen and needs to be done manually.
I just built and uploaded your fork to my esp32 and tried this, without success unfortunately.
I added "secure":true, to the json string, is this correct?
If you are unsuccessful could you please enable NimBLE debug logging by adding -DCONFIG_NIMBLE_CPP_LOG_LEVEL=5 to your build flags and post the log of the error?