Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect to alternative brand of lights - incorrect base code? #5

Open
jymbob opened this issue Jun 16, 2023 · 68 comments
Open

Comments

@jymbob
Copy link

jymbob commented Jun 16, 2023

I'm not having any success pairing any of the three lights I've got here.
I've set up a second ESP32 as a sniffer to help me debug what's going on.

ESP32 controller sends:

Adv data: 02.01.02.1B.16.F0.08.10.80.0A.EE.31.BE.0A.F3.67.CB.A9.E3.C2.0E.9B.5C.9E.D4.BA.0F.29.31.31.93 (31)

Whereas hitting “pair” in the Android app sends (example):

Adv data: 02.01.01.1B.03.77.F8.B6.5F.2B.5E.00.FC.31.51.CC.E4.92.56.2E.4A.1B.FC.AC.ED.F4.1B.7C.B6.89.00 (31)

The first 5 digits always appear to be 02.01.01.1B.03, but just swapping those in the prefix doesn't work either.

I'm working on the assumption that the command needed is very slightly different for my brand of light, but altering these bits manually is then throwing off some sort of checksum value?

I'm not familiar enough with C to fully understand what manipulation takes place for the rest of the values. I expect if I replayed a working command it'd work as expected, but can't see how to build the right packet

@aronsky
Copy link
Owner

aronsky commented Jun 17, 2023

Hi,

Two things:

  1. The packets you captured are "whitened". You have to "unwhiten" them in order to really see what's going on inside. Use the ble_whiten function for a reference, it should receive a buffer of 18 bytes taken from the 10th byte onwards of each packet (0A in packet one, 2B in packet two). The seed is a short 2 bytes before the end of each packet, that is 0x3129 for the first packet, and 0xb67c for the second one (or 0x3129/0x7cb6, not sure about endianness). Once you "unwhiten" the packet, it should be more readable, and you can check the values of the different fields properly.
  2. For the life of me, I can't see how the prefix (the bytes before the 10th byte of the packets) would be different. I'm looking at the code of the app (both the Java decompiled code in JADX, and the native functions called from Java code to actually generated the BLE packet's buffer) - and the first 9 bytes are hard-coded. There's nothing dynamic about them - they should be the same. I'm at a loss about how your app generates those bytes differently from what I'm seeing in the disassembly. Which version of the app are you using - can you send me the APK?

@jymbob
Copy link
Author

jymbob commented Jun 19, 2023

The app I'm using is from https://play.google.com/store/apps/details?id=com.jingyuan.lamp - v1.2.3

I'll see if I can get "unwhitened" packets into the console so I have a better idea of what's going on. I'm not particularly at home with C but will give it a try.

NB: Which app have you been basing your work off? Doing a quick search I can also see https://play.google.com/store/apps/details?id=com.alllink.smart_lighting which appears to be functionally equivalent. I wouldn't be surprised if there are others.

@aronsky
Copy link
Owner

aronsky commented Jun 19, 2023

Yep - it's the same app and version that I disassembled (LampSmart Pro 1.2.3). Very strange.

@aronsky
Copy link
Owner

aronsky commented Jun 19, 2023

I've unwhitened the packets for you. Here's a Python code to do that:

XBOXES = [
  0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC,
  0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15,
  0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A,
  0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75,
  0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85,
  0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8,
  0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5,
  0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2,
  0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C,
  0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79,
  0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9,
  0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08,
  0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94,
  0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF,
  0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68,
  0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16
]

def unwhiten(buf, size, seed):
  res = []
  for i in range(size):
    res.append(buf[i] ^ XBOXES[(seed + i + 9) & 0x1f])
    res[i] ^= seed
    res[i] &= 0xff
  return res

As expected, the output of the packet from the app is absolutely garbled (i.e., it probably wasn't "whitened" with that function to begin with). Are you sure you're capturing the correct packet from the app? Maybe there are additional packets going out that you're missing?

@jymbob
Copy link
Author

jymbob commented Jun 19, 2023

Thanks, getting more info.

I may have had the wrong packet earlier.

Latest transmit from here:
[10:27:02][VV][esp32_ble_tracker:419]: Adv data: 02.01.01.1B.03.F0.08.10.80.D1.A2.BA.77.9E.70.9E.AE.C2.5F.67.6E.A6.9D.65.F4.B4.A0.51.A8.9A.C8 (31)

So, I can extract that into a packet and seed:

buf = [0xD1,0xA2,0xBA,0x77,0x9E,0x70,0x9E,0xAE,0xC2,0x5F,0x67,0x6E,0xA6,0x9D,0x65,0xF4,0xB4,0xA0]
seed= 0xa851

and plugging it into your unwhiten function:

00 11 00 01 7d 54 78 02 00 28 00 00 00 00 00 00 00 00

@aronsky
Copy link
Owner

aronsky commented Jun 19, 2023

That looks much better - but then, it also looks exactly like the packet sent by the ESP32, so I'm not sure why it's not working...

This is the packet sent by the ESP32 (from your first message):

00 04 00 01 26 40 49 f0 00 28 00 00 00 00 00 00 00 00

The 2nd byte seems to be just a counter, so it makes sense it differs. And the 4 bytes starting at index 4 (26 40 49 f0) are simply a random 32-bit identifier for the lamp...

You can make a few changes to the code and force it to send the same packet as the app, see if that works.

  1. Keep the counter (the 2nd byte) constant at 0x11. Though my testing shows that it does need to change, doubt if that will work.
  2. Use a hard-coded identifier of 0xf0494026 (or reverse the bytes, again - not sure about the endianness). Theoretically, if that pairing above succeeded, and the lamp is controllable by the phone - if you hardcode the identifier into the code, it should control the lamp without pairing. If that does work, the issue is only with the pairing mechanism.

@jymbob
Copy link
Author

jymbob commented Jun 19, 2023

Yeah, the app definitely appears to be sending two distinct codes (although not every time, or maybe I'm just missing some of them), one which I can "unlighten" and one which I can't.

Locking down the identifier to my light (yes, it's little-endian) I can send packets that look almost exactly like some of the ones coming from the phone, but still no response from the light itself.

Here's a sample

esp
[14:52:19][VV][esp32_ble_tracker:419]: Adv data: 02.01.01.1B.03.F0.08.10.80.CB.51.1A.0F.F4.73.B6.E8.FB.28.DC.3C.E7.69.FA.65.F8.ED.FF.B7.5F.1A (31)
00 0b 00 01 7a 54 78 02 00 10 00 00 00 00 00 00 00 00

esp
[14:52:20][VV][esp32_ble_tracker:419]: Adv data: 02.01.01.1B.03.F0.08.10.80.0B.96.DA.CF.34.B3.76.28.3B.D9.1C.FC.27.56.C5.A5.38.2D.3F.D4.04.48 (31)
00 0c 00 01 7a 54 78 02 00 21 00 00 00 ff ff 00 00 00

esp
[14:54:14][VV][esp32_ble_tracker:419]: Adv data: 02.01.01.1B.03.F0.08.10.80.4A.EF.EF.E7.54.41.95.7E.3C.39.A8.01.E8.CC.DD.1E.FA.1A.D9.6F.67.44 (31)
00 10 00 01 7a 54 78 02 00 11 00 00 00 00 00 00 00 00

app
[14:55:23][VV][esp32_ble_tracker:419]: Adv data: 02.01.01.1B.03.F0.08.10.80.28.87.2A.3E.D7.9B.BE.08.9E.49.9A.D0.BE.0B.1B.12.DA.E1.2D.5A.63.40 (31)
00 30 00 01 7a 54 78 02 01 11 00 00 00 00 00 00 00 00

app
[14:55:23][VV][esp32_ble_tracker:419]: Adv data: 02.01.01.1B.03.F9.08.49.13.F0.69.25.4E.31.51.BA.32.C6.82.24.CB.3B.78.71.9E.5A.55.C6.49.4C.4C (31)
23 ab 24 ab 34 8f ea f1 9a 43 f0 8d 1f 55 90 ea e9 24

app
[14:55:23][VV][esp32_ble_tracker:419]: Adv data: 02.01.01.1B.03.F0.08.10.80.28.87.2A.3E.D7.9B.BE.08.9E.49.9A.D0.BE.0B.1B.12.DA.E1.2D.5A.63.40 (31)
00 30 00 01 7a 54 78 02 01 11 00 00 00 00 00 00 00 00

app
[14:55:24][VV][esp32_ble_tracker:419]: Adv data: 02.01.01.1B.03.77.F8.B6.5F.2B.5E.00.FC.31.51.50.E4.12.08.24.CB.BF.FC.AD.EC.F4.1A.20.CF.24.05 (31)
ae 9b d1 ad c9 40 65 c0 f5 0b c7 f3 09 d9 17 cb c6 ba


app
[15:16:08][VV][esp32_ble_tracker:419]: Adv data: 02.01.01.1B.03.F0.08.10.80.52.BA.12.37.5D.B0.78.E2.3A.94.26.B9.24.D9.DB.C1.C8.04.23.4D.C8.2F (31)
00 41 00 01 7a 54 78 02 01 21 00 00 00 e8 78 00 00 00

app
[15:16:07][VV][esp32_ble_tracker:419]: Adv data: 02.01.01.1B.03.F0.08.10.80.D4.B0.E1.23.BC.72.85.71.E1.5E.E2.F7.65.EF.76.C2.57.90.E5.C1.29.9B (31)
00 40 00 01 7a 54 78 02 01 21 00 00 00 e8 78 00 00 00

Not sure where to go from here. I might just set up something to send the exact codes I'm receiving back and see if I can get a response.

@aronsky
Copy link
Owner

aronsky commented Jun 19, 2023

OK. So it looks like the main difference between the app and the ESP32 (assuming the garbage packets are irrelevant) is the byte right after the identifier and before the command, which is set to 0 on the ESP32 (hard-coded), and seems to be 1 in the app.

Try setting it to 1 (on this line: https://github.com/aronsky/esphome-components/blob/main/components/lampsmart_pro_light/lampsmart_pro_light.cpp#L163), and see if that helps?

I don't remember whether I set it to 0 because it's what the app does, or because I had no other values to go off, and assumed it to be 0 - but it looks like 1 is the correct value, at least for you.

Let me know if that works.

@cekosss
Copy link

cekosss commented Jul 1, 2023

Hello guys, I also have issues with pairing my Lampsmart Pro compatible Lamp with the esp32. What do you mean with setting to 1? I am not good at programming, but I can manage to change the code. Can you please write what I have to write instead of 0x0?

Try setting it to 1 (on this line: https://github.com/aronsky/esphome-components/blob/main/components/lampsmart_pro_light/lampsmart_pro_light.cpp#L163), and see if that helps?

I don't remember whether I set it to 0 because it's what the app does, or because I had no other values to go off, and assumed it to be 0 - but it looks like 1 is the correct value, at least for you.

@aronsky
Copy link
Owner

aronsky commented Jul 1, 2023

Change the 0x0 on the line I linked to 1, that's it.

However, I'm not sure it will work - I was hoping it would, but @jymbob hasn't come back with positive results, which, I suspect, means that it didn't help...

@cekosss
Copy link

cekosss commented Jul 1, 2023

I've just tested it - unfortunately it didn't work either.
Below my message, I have attached the log from my esp32 tracker when I controlled the Lamp from my iPhone with the beloved Lampsmart Pro iOS App. Maybe it can be useful for you. It looks similar to the adv in the first posting.

[22:27:10][VV][esp32_ble_tracker:396]: Ad Flag: 26
[22:27:10][VV][esp32_ble_tracker:399]: Service UUID: 0xF877
[22:27:10][VV][esp32_ble_tracker:399]: Service UUID: 0x5FB6
[22:27:10][VV][esp32_ble_tracker:399]: Service UUID: 0x5E2B
[22:27:10][VV][esp32_ble_tracker:399]: Service UUID: 0xFC00
[22:27:10][VV][esp32_ble_tracker:399]: Service UUID: 0x5131
[22:27:10][VV][esp32_ble_tracker:399]: Service UUID: 0x935C
[22:27:10][VV][esp32_ble_tracker:399]: Service UUID: 0x0892
[22:27:10][VV][esp32_ble_tracker:399]: Service UUID: 0xCBBC
[22:27:10][VV][esp32_ble_tracker:399]: Service UUID: 0xFC7E
[22:27:10][VV][esp32_ble_tracker:399]: Service UUID: 0xC030
[22:27:10][VV][esp32_ble_tracker:399]: Service UUID: 0x36F4
[22:27:10][VV][esp32_ble_tracker:399]: Service UUID: 0x0ADD
[22:27:10][VV][esp32_ble_tracker:399]: Service UUID: 0x8B58
[22:27:10][VV][esp32_ble_tracker:418]: Adv data: >02.01.1A.1B.03.77.F8.B6.5F.2B.5E.00.FC.31.51.5C.93.92.08.BC.CB.7E.FC.30.C0.F4.36.DD.0A.58.8B (31)

@jymbob
Copy link
Author

jymbob commented Jul 1, 2023 via email

@cekosss
Copy link

cekosss commented Jul 2, 2023

Hello again,

I just have logged the signal of the remote control, which was delivered with the lamp. The button I pressed was the SETUP button for pairing with the lamp. I hope, that this could be useful for you, since the adv data of the pairing command looks a little bit different.

[20:52:27][VV][esp32_ble_tracker:368]: Parse Result:
[20:52:27][VV][esp32_ble_tracker:385]: Address: 10:9E:3A:10:25:5D (RANDOM)
[20:52:27][VV][esp32_ble_tracker:387]: RSSI: -28
[20:52:27][VV][esp32_ble_tracker:388]: Name: ''
[20:52:27][VV][esp32_ble_tracker:396]: Ad Flag: 2
[20:52:27][VV][esp32_ble_tracker:413]: Service data:
[20:52:27][VV][esp32_ble_tracker:414]: UUID: 0x08F0
[20:52:27][VV][esp32_ble_tracker:415]: Data: 10.00.27.30.1A.D7.E2.C8.46.0C.62.FF.C7.CE.06.3D.C5.54.14.00.F1.15.F8.36 (24)
[20:52:28][VV][esp32_ble_tracker:418]: Adv data: 02.01.02.1B.16.F0.08.10.00.27.30.1A.D7.E2.C8.46.0C.62.FF.C7.CE.06.3D.C5.54.14.00.F1.15.F8.36 (31)

@aronsky
Copy link
Owner

aronsky commented Jul 3, 2023

I'll need to unwhiten that message to check its contents. But at least as far as the beginning goes, it looks similar to what the compnent transmits.

@jymbob @cekosss has any of you used lampify successfully? If so, a fallback to lampify's algorithm (which seems quite different from what I disassembled from the app), could work.

@aronsky
Copy link
Owner

aronsky commented Jul 3, 2023

[20:52:28][VV][esp32_ble_tracker:418]: Adv data: 02.01.02.1B.16.F0.08.10.00.27.30.1A.D7.E2.C8.46.0C.62.FF.C7.CE.06.3D.C5.54.14.00.F1.15.F8.36 (31)

@cekosss so the unwhitened data in this packet looks like this:

56 23 00 01 a1 4c 00 00 00 28 00 00 00 00 00 00 00 00

Broken down, that is (note, it's little-endian, so the bytes for each field are reversed):

  • 56: unknown, might be part of the packet number
  • 23: packet number (increases every packet)
  • 0100: type (should be 0100, so correct)
  • 00004ca1: identifier
  • 00: should be zero
  • 0028: command type, 0x28 for pairing (correct)
  • 00: value for channel 1, should be zero for pairing (correct)
  • 00: value for channel 2, should be zero for pairing (correct)
  • 00000: 3 zero bytes (correct)

So, that matches what this component sends out pretty well, except:

  1. The first byte is always 00, and here it is 56. Since the following byte is an 8-bit packet number, there's a chance that I misunderstood, and both bytes are a 16-bit packet number (so in the above packet, the packet number is 0x2356). That's the most likely explanation to the discrepancy, and makes it irrelevant (as the packet number seems irrelevant mostly, other than having to change).
  2. The identifier seems to be only 16 bits (and not 32 bits) wide. That should hardly matter - i.e., if the lamp expects a 16-bit identifier, it will simply look at the 1st 2 bytes out of the 4. So, again, unlikely that this is the culprit.

So, if that button press worked, and the lamp was paired - I'm quite at a loss as to what may cause this. The current code is really spot-on, other than the above 2 points. I made a branch with those changes for you to test out: https://github.com/aronsky/esphome-components/tree/support-additional-lamps
The first commit fixes the 1st point, whereas the 2nd commit fixes the 2nd point (in case you want to revert each separately and test if it helps).

If that doesn't help, you can take the main branch and hardcode 0x56 to be the last byte on line

.prefix = {0x02, 0x01, 0x02, 0x1B, 0x16, 0xF0, 0x08, 0x10, 0x80, 0x00},
(instead of 0x00). I really doubt that it will help, but worth trying if all the other options fail.

Finally, if none of the above works - I'm not sure what else can be done. Clearly the code works the same as the remote control, so if the remote control works - so should the code... Any chance the lights are simply too far away from the ESP32?

@jymbob
Copy link
Author

jymbob commented Jul 3, 2023 via email

@cekosss
Copy link

cekosss commented Jul 3, 2023

Unfortunately lampify doesn't work on my Raspberry Pi Zero 2W, which is supposed to support BLE...
Getting a "failed to send notification" message.

@jymbob @cekosss has any of you used lampify successfully? If so, a fallback to lampify's algorithm (which seems quite different from what I disassembled from the app), could work.

@andyxpert
Copy link
Contributor

andyxpert commented Jul 8, 2023

Hi Aronsky,

Great work !! Used this for a month and then because of a crack in the housing I had to replace the entire fixture.
This new one (although 95% identical with the previous one) works with a different app - http://mihuan.iotworkshop.com/zhiguang/
Not working with any of the ones mentioned above (Previous one worked with LampSmart Pro, this one doesn't).

Anyway, same issue as OP, your code or the fork can't pair, lampify similarly doesn't connect - no light flicker to confirm.

Is there a guide or a script I can use to sniff what the remote or the app send (BT codes I mean, ideally unwhitened) ??

Also, couldn't you code be simplified ? I.e. separating the static part of the bytes sent for setup from the dynamic part to make it easier to try some combinations for other devices as such ?

Have a linux with a BT dongle and a few ESPs, HA, a RPi, etc

@aronsky
Copy link
Owner

aronsky commented Jul 9, 2023

Sorry, if that fixture doesn't work with LampSmart Pro, it's out of scope for this repo. A different app means that the protocol is probably completely different (otherwise it would support the other apps).

@andyxpert
Copy link
Contributor

andyxpert commented Jul 10, 2023

Thank for the reply.
Not sure it's that different, it's the same fixture as the previous one, only difference is the app, which is pretty much identical to the old one, and I can bet it's the same protocol (as the HW is the same), maybe only a few bytes are different.
How could I go about debugging it ??
With btmon I sniffed this command that is sent in the pairing/setup phase:

From the Remote: 18f90849b2ce2c109a9efd050320c9412c10111213141516171819
The App is sending many UUIDs:

HCI Event: LE Meta Event (0x3e) plen 43 #170 [hci0] 7.056681
LE Advertising Report (0x02)
Num reports: 1
Event type: Connectable undirected - ADV_IND (0x00)
Address type: Random (0x01)
Address: 69:E5:B6:0E:2B:60 (Resolvable)
Data length: 31
Flags: 0x01
LE Limited Discoverable Mode
16-bit Service UUIDs (complete): 13 entries
Unknown (0x08f9)
Unknown (0xb249)
Unknown (0x2cce)
Unknown (0x3b8f)
Unknown (0x906b)
Unknown (0x3e0e)
Unknown (0x3de1)
Unknown (0xa5dc)
Intercom (0x1110)
Unknown (0x1312)
Unknown (0x1514)
Unknown (0x1716)
Unknown (0x1918)
RSSI: -86 dBm (0xaa)

Don't know yet how to alter your code for ESP locally (without publishing my own GitHub repo) but I can use the base Lampify code locally where I can easily change the base bytes that are sent. Tried with a few combinations without any luck.
Any pointers would be great.

Alternatively I can unpack the apk and decompile it but I'm not sure what to look for there also.

@andyxpert
Copy link
Contributor

I think I'm close...
Used nRF Connect on Android to sniff the BT communication, here's what I got:

Remote Control:
18f90849b2ce2c51dbdfbc444220886b5910111213141516171819
1848464b4a69e8b0d5fb6a94c8cacfc218e90b9a39101112131415
UUID: 0x5558
Data: 0x1eff5855 then the strings above 18...

Aronsky ESP:
1080534181640a4b4106dc6954c6a4ad61f433f146f6a982
1080c8df4f2cabfdecff781a5ce9f9f03803fb6acf8c7ec7
UUID: 0x08f0
Data: 0x1080... - the string from above

Now, I tried altering the lampify script to send these hex values, but I may be doing something wrong, as not all the array elements need to be updated, only some of them... will try some more later this evening.
It would be great though to be able to play with your code without the need to publish it on GitHUB so that ESP can grab the custom_component.
How can I play with it locally and use your altered code in ESP more easily ?
I'll also try to alter the generated image from ESPHome server, but I think they're already built...

@aronsky
Copy link
Owner

aronsky commented Jul 10, 2023

Hi,
You can fork this repo and point your ESPHome config to your fork (replace my username with yours). You can also download the code and put it in a custom_components subfolder in your ESPHome directory - I don't recall the exact details, but look it up, it's possible (I started with that before uploading my code to GitHub).

However, be advised, that this may be more difficult than you expect. There are multiple apps that work with the lamps supported by this repo, so clearly there is some protocol that remains shared between all those apps. Since you say that you had to switch to a different app, and other apps don't work - it's quite possible that underneath a similar appearance, the protocol is completely different.

In any case, guessing what bytes need to be changed based on BLE monitoring alone is moot. The data you see is encoded, and without decoding it properly, there's no chance you will see a single byte or two of difference - the whole packet will look different. You'll have to disassemble the app and see what it's doing.

@cekosss
Copy link

cekosss commented Jul 11, 2023

Since I am not a programmer, I may not be very useful in developing the code, but I can offer you me testing your work with my ESP32 and my lamp.

If you like to get more information about the specific remote control of my lamp, just let me know and I will do my best to provide the information you need.

Never give up :-)

@andyxpert
Copy link
Contributor

:) never give up, indeed, until I decompiled that chinese apk (about 35MB) and got a bit scared... it tries to constantly send data to some chinese servers...
So I did the normal rational thing - bought 3 other fairly similar fixtures, this one I'll return for a refund... and out of the new ones I hope to find one that works way easier without the need to hack the bytes sent to it...

With ESP what I managed to do is grab Aronsky's code and put it locally so I can play with it, tried a few byte changes but it's pretty much pointless, as after decompiling the APK I saw that every packet sent to the light is followed by another packet... so somehow they always send a pair of packets.
Couldn't understand much of the payload as the apk is done on some existing frameworks and there are waaaaaaaaaaay too many interfaces and abstractizations and a few decorators... so unless I convert the decompiled apk into a working Android project I can't do much on it :(

@Zulex
Copy link

Zulex commented Jul 23, 2023

I was running at the same issue as @jymbob .

Tried the

  • main,
  • the branch with the 2 fixes,
  • the main + hardcoded the 0x56,
  • the branch with 2 fixes + hardcoded the 0x56 + changed 0x0 -> 1.

All are not able to pair with the light. Could it be the board I am using? (NodeMCU-32S).

Logs are always saying the device is trying to pair:
[11:27:42][D][lampsmartpro:146]: LampSmartProLight::on_pair called! [11:27:43][W][component:204]: Component api took a long time for an operation (1.00 s). [11:27:43][W][component:205]: Components should block for at most 20-30ms.

I have managed to sniff out the 'setup' button on the BLE controller that was provided with the light:

0201021B16F0081000759804E5F373A4BD201DA7C5CC00955290DA270338FC
If correct that should give:

buf = [0x75,0x98,0x04,0xE5,0xF3,0x73,0xA4,0xBD,0x20,0x1D,0xA7,0xC5,0xCC,0x00,0x95,0x52,0x90,0xDA]
seed= 0x0327
result: [86, 120, 0, 1, 204, 194, 134, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0]

I also tried to see what the code would be after a few clicks and also after reconnecting (2 times).

After a few clicks: [86, 133, 0, 1, 204, 194, 134, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0]
After reconnecting 2 times: [86, 135, 0, 1, 204, 194, 134, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0]

It seems like the only thing that is changing is the counter, as you already figured. I am not sure how to go on from here, it does not seem to match with the signal we are sending out if I read correctly above. I also noticed that you mention 0x28 is the command for pairing, however, it looks like 0x40 is used here. (@aronsky , any clue what the 40 does? It might also just be a verification which is send later).

So here I also tried too just change the 0x28 definition by 0x40, however that also did not do the trick unfortunately.

I am really not sure where to go from here actually.

@Justin8428
Copy link

I also had the same issues as described above -- the commands would send to the esp32 (light flashes) but lamp does not respond, even after trying the various branches
If it helps @aronsky @cekosss I actually managed to get lampify to work on a laptop running Debian 12 with an Intel AC-8265 wireless card (was a bit of an adventure to get it working actually -- it wouldn't work on Ubuntu, nor on a newer laptop with an AX210 -- not really sure why it would matter, but anyway...).
I don't have a Raspberry Pi to test but I think with lampify the "failed to send notification" message doesn't necessarily mean its not working, that particular error likely refers to some gnome notification dependencies.

@aronsky
Copy link
Owner

aronsky commented Jul 30, 2023

I also had the same issues as described above -- the commands would send to the esp32 (light flashes) but lamp does not respond

What do you mean the light flashes? The light on the ESP32, or the lamp you're trying to control flashes after using the ESP32 to pair?

@Justin8428
Copy link

Sorry should have been clearer -- I meant the led on the esp32, not the lamp itself :-)

@aronsky
Copy link
Owner

aronsky commented Jul 30, 2023

In that case (especially since lampify works for you), it seems like the protocol emulated in this repo is not supported by your lamp. Does LampSmart Pro work for you?

@aronsky
Copy link
Owner

aronsky commented Nov 21, 2023 via email

@jymbob
Copy link
Author

jymbob commented Nov 30, 2023

@Georgerdx the easiest way I've found of reliably sniffing packets is to get a second ESP32 and install https://esphome.io/components/esp32_ble_tracker.html to scan for packets, although how useful that will be depends on the number of other chatty BLE devices in your vicinity.

@igui
Copy link

igui commented Dec 2, 2023

Hello All,
Interesting reading here.
i would be interested to know how are you guys able to sniff the remote and the pairing command from the phone.
I’ve got wireshark & nrf52840 setup, but i can’t recognoze the phone or the lamp remote in the traffic. I know the bluetooth mac address of my phone but there are no packets visible unfortunately.
I am using iphone xr with the lampsmart pro app on it.

It is possible to capture packets using a Rasperry Pi.

The command I use is sudo tcpdump -i bluetooth0 --packet-buffered -w - > bluetooth-capture.dmp without any setup. I can read packets from other devices like packages from neighbours, so it can be noisy as @jymbob pointed out.

@StevenReitsma
Copy link

The code in this repository didn't work for my lights either, but Lampify worked perfectly. I wanted to use an ESP however, so I ported the Lampify code over to ESPHome.

https://github.com/StevenReitsma/esphome-lampsmart-pro

It's basically a merge of the ESPHome component in this repository and the Lampify protocol. Hopefully it's of some use to others as well!

@oxcid3
Copy link

oxcid3 commented Feb 19, 2024

Hey aronsky, thanks for all your work getting this far.

I have a lamp that works wtih LampSmartPro, but sadly doesn't pair using this repo.

I'm technical, and reasonably familiar with Wireshark, but not a dev by any stretch.
I've managed to log the Bluetooth HCI output from the app, and after a fight with my phone, managed to get it out
Looking at some of the info above, I think I've identified the string that was the initial pairing request:
(because it starts with "02.01.01.1b.03.77")

02.01.01.1b.03.77.f8.b6.5f.2b.5e.00.fc.31.51.cc.46.92.f4.2e.4a.eb.fc.00.59.f4.af.7c.75.ef.3f

I wondered if anyone could help 'unwhiten' this so help me see if perhaps my light uses a different number for the pairing command.

Here's the packet info:

Frame 1057: 39 bytes on wire (312 bits), 39 bytes captured (312 bits)
Bluetooth
Bluetooth HCI H4
[Direction: Sent (0x00)]
HCI Packet Type: HCI Command (0x01)
Bluetooth HCI Command - LE Set Extended Advertising Data
Command Opcode: LE Set Extended Advertising Data (0x2037)
0010 00.. .... .... = Opcode Group Field: LE Controller Commands (0x08)
.... ..00 0011 0111 = Opcode Command Field: LE Set Extended Advertising Data (0x037)
Parameter Total Length: 35
Advertising Handle: 0x02
Data Operation: Complete scan response data (0x03)
Fragment Preference: Controller should not fragment or should minimize fragmentation of Host data (0x01)
Data Length: 31
Advertising Data
Flags
Length: 2
Type: Flags (0x01)
000. .... = Reserved: 0x0
...0 .... = Simultaneous LE and BR/EDR to Same Device Capable (Host): false (0x0)
.... 0... = Simultaneous LE and BR/EDR to Same Device Capable (Controller): false (0x0)
.... .0.. = BR/EDR Not Supported: false (0x0)
.... ..0. = LE General Discoverable Mode: false (0x0)
.... ...1 = LE Limited Discoverable Mode: true (0x1)
16-bit Service Class UUIDs
Length: 27
Type: 16-bit Service Class UUIDs (0x03)
UUID 16: Unknown (0xf877)
UUID 16: Unknown (0x5fb6)
UUID 16: Unknown (0x5e2b)
UUID 16: Unknown (0xfc00)
UUID 16: Unknown (0x5131)
UUID 16: Unknown (0x46cc)
UUID 16: Unknown (0xf492)
UUID 16: Unknown (0x4a2e)
UUID 16: Avi-On (0xfceb)
UUID 16: Unknown (0x5900)
UUID 16: Unknown (0xaff4)
UUID 16: Unknown (0x757c)
UUID 16: Unknown (0x3fef)
[Response in frame: 1058]
[Command-Response Delta: 0.738ms]

Really appreciate any support.

@jymbob
Copy link
Author

jymbob commented Feb 19, 2024

The code in this repository didn't work for my lights either, but Lampify worked perfectly. I wanted to use an ESP however, so I ported the Lampify code over to ESPHome.

https://github.com/StevenReitsma/esphome-lampsmart-pro

It's basically a merge of the ESPHome component in this repository and the Lampify protocol. Hopefully it's of some use to others as well!

This is also working for at least one of my lights!

@Zulex
Copy link

Zulex commented Feb 19, 2024

The code in this repository didn't work for my lights either, but Lampify worked perfectly. I wanted to use an ESP however, so I ported the Lampify code over to ESPHome.

https://github.com/StevenReitsma/esphome-lampsmart-pro

It's basically a merge of the ESPHome component in this repository and the Lampify protocol. Hopefully it's of some use to others as well!

Also worked for my light without any hassle, thanks/bedankt Steven!

@aronsky
Copy link
Owner

aronsky commented Feb 19, 2024

The code in this repository didn't work for my lights either, but Lampify worked perfectly. I wanted to use an ESP however, so I ported the Lampify code over to ESPHome.

https://github.com/StevenReitsma/esphome-lampsmart-pro

It's basically a merge of the ESPHome component in this repository and the Lampify protocol. Hopefully it's of some use to others as well!

Glad that it worked for you, and it looks like it's working for additional people. If you feel like it, you're welcome to merge the code so that the two repos can be combined, and the end-user can choose the subtype of the lights (i.e., the protocol to use) in the configuration.

@flicker581
Copy link
Contributor

flicker581 commented Feb 19, 2024

I'm also trying to reverse-engineer RC protocol for these lamps. Unfortunately, now I have two different remotes at hands and zero lights (they are installed at friend's home, we will try to control them someday).
What I've managed to know so far:

Both remotes send TWO different advertisements each time. One adv comes with MAC 10:9E:3A:10:25:5D and second with MAC 59:BA:2B:D2:57:8D. Advertisements come really fast, interval is about 1-2ms. nRF Connect catches ~200 copies of each message, except for Setup, which does ~800 copies. This violates BLE specs, AFAIK, because proper advertisement interval cannot be less than ~20ms.

Those two advertisements are very different. Type1 (10:9E:3A:10:25:5D) is almost the same as used in this repo (with several slight differences), and Type2 (59:BA:2B:D2:57:8D) is similar to lampify protocol, but with important differences in layout and CRC calculation. I'm not sure which of advs (or both) is needed for our lights. They carry almost the same information.

Also, I'm unsure if emulator should fake those MACs to gain control. 10:9E: looks like regular random address and can be sent from ESP32, but 59:BA: is RPA address and ESP32 is, AFAIK, unable to fake it.
Sadly, I've not managed yet to re-calculate CRC for Type2 protocol. Honestly, I cannot be sure that it is CRC at all.

0x56 from the discussion above is somewhat like variant number. One remote with white lights has 0x56, and second one for RGB light has 0x57. This number appear in different places: at the beginning of Type1 packet, in header of Type2 packet (you may see it as manufacturer data with id 0x5556 or 0x5557), and in Setup request of Type2.

Also, ble_whiten from this repo is not proper BLE whitening, it is some kind of encryption for Type1. Whereas the lampify tool use proper BLE whitening for channel 37. In fact, it looks that this part of message is transmitted over the air unwhitened, which is somewhat strange and may be legacy of some non-bluetooth radio receivers.

@flicker581
Copy link
Contributor

flicker581 commented Feb 19, 2024

@oxcid3,

02.01.01.1b.03.77.f8.b6.5f.2b.5e.00.fc.31.51.cc.46.92.f4.2e.4a.eb.fc.00.59.f4.af.7c.75.ef.3f

Unfortunately, this packet is using some different format. The app is sending three (as far as I can see from BT logs) different setup commands. Only one of them follow known protocol.

0201021b03f0083080b864e1279cfb26d76544a49f67f6b67f0e8b532ba064 - this one can be deciphered.
0201021b03f9084913f069254e3151baae86023ac1ba7c7186c6555a29c94c
0201021b0377f8b65f2b5e00fc3151cca492162e4abbfc9356f4a0a208c40a - these are different.

@oxcid3
Copy link

oxcid3 commented Feb 20, 2024

@flicker581

Thanks for taking a look - Just to be clear the one I posted starts 020101, not 020102
But I've found a packet that very closely matches that top one, again the only difference is the 3rd pair is "01" not "02"
which appears to be something to do with 'Limited Discovery Mode' being True
Here's a bunch of values that all start with the same 0201011b03 prefix if that helps:

0201011b03f0083080b86ee127dbfc4be76544a49f67f6b65db88b532bddbe
0201011b0377f8b65f2b5e00fc3151cc4692f42e4aebfc0059f4af7c75ef3f
0201011b03f9084913f069254e3151baae6402d8c1ba2c71ea3655aa33684c

0201011b03f9084913f069254e3151baae6402d8c1bacc71528e551259a64c
0201011b0377f8b65f2b5e00fc3151cc4692f42e4a0bfc1049f4bf9fd03f65

0201011b03f0083080b86fe127dbfc4be76544a49f67f6b6d6a88b532b4ab5
0201011b03f0083080b868e127dbfc4be76544a49f67f6b694f18b532bf25c
0201011b03f9084913f069254e3151baae6402d8c1ba4c71ed3155adffe04c

@flicker581
Copy link
Contributor

flicker581 commented Feb 21, 2024

@oxcid3
It looks like LampSmartPro now implements two versions of the protocol by Allinktec. Newer one, called v3, is not studied yet.

Implemented is v2, and I'd like to find out where v1 was used. Presumably, it is the thing which lampify does.

It is unclear which one is needed for your lamps.

Update: v3 algorithm is almost the same as v2, but it implements additional AES message signature. It is these random-looking 2 bytes near the end of the packet:
001c00013f528b920028000000000036d300

It is easy to replicate.

@flicker581
Copy link
Contributor

flicker581 commented Feb 23, 2024

I'd like to come with PR to add v3 to this code, but I'm afraid it won't be soon. So, here is a snippet from my python code which calculates and checks the signature.

from Crypto.Cipher import AES
...
    seed = int.from_bytes(s[27:29], 'little')
...
    fields = ['prefix', 'variant', 'counter', 'type', 'id', 'p1', 'cmd', 'p2', 'p3', 'ch1', 'ch2', 'ch3', 'sigv3', 'p6']
    v = struct.unpack("<9sBBHLBBBBBBBHB", s[:27])
    tx = {k: v for k, v in zip(fields, v)}
    assert tx['variant'] in [0x57, 0x56, 0], f"variant unknown: {tx['variant']}"
    assert tx['type'] == 0x100, f"type unsupported: {tx['type']}"
    sigv3 = tx['sigv3']
    if sigv3 != 0:
        tx['version'] = 3
        # secret key
        key = bytearray.fromhex('0000000DBFE6426841992D0FB054BB16')
        key[0] = seed & 0xFF
        key[1] = (seed >> 8) & 0xFF
        key[2] = tx['counter']
        ctx = AES.new(key, AES.MODE_ECB)
        cipher = ctx.encrypt(s[8:24])
        checkv3 = cipher[0] + (cipher[1] << 8)
        if checkv3 == 0:
            checkv3 = 0xFFFF
        assert sigv3 == checkv3, f"V3 signature does not match: {checkv3=:x} {sigv3=:x}"
    else:
        tx['version'] = 2

Also, I would confirm that the app (LampSmart Pro 1.2.9) supports three different messages to lamps. Two of them are probably encoded in flutter libapp.so. They are most likely "v1".

@flicker581
Copy link
Contributor

Someone may try this:
https://github.com/flicker581/esphome-lampsmart

In this branch, I've implemented two lampify-like versions of control protocol, but I am unable to test it on real lamps. See sample config.

Still, there are many more variants.

@jymbob
Copy link
Author

jymbob commented Mar 5, 2024

Nice. That's a much better approach than mine - I was just creating multiple components in one repo. I'll give it a test tomorrow. Maybe I'll finally get some response out of this ceiling light

@Di1Ly
Copy link

Di1Ly commented Mar 6, 2024

In this branch, I've implemented two lampify-like versions of control protocol, but I am unable to test it on real lamps. See sample config.
Thanx for your work. Just compile and upload the code. Non of 4 version work for me, but C project work https://github.com/MasterDevX/lampify.
For V3 there is an errors in the log:
[11:40:14][D][light:036]: 'V3 light' Setting: [11:40:14][D][light:047]: State: ON [11:40:14][D][light:085]: Transition length: 1.0s [11:40:14][D][lampsmartpro:180]: LampSmartProLight::write_state called! Requested cw: 0, ww: 0 [11:40:14][D][lampsmartpro:405]: Prepared packet: 02.01.02.1B.16.F0.08.10.80.92.42.FB.BA.CA.FC.75.D0.4B.4A.99.7D.9D.46.C8.34.03.59.5E.62.6B.67 (31) [11:40:14][D][lampsmartpro:409]: Advertising start [11:40:14][D][lampsmartpro:180]: LampSmartProLight::write_state called! Requested cw: 0, ww: 0 [11:40:14][D][lampsmartpro:180]: LampSmartProLight::write_state called! Requested cw: 0, ww: 0 [11:40:14][D][lampsmartpro:180]: LampSmartProLight::write_state called! Requested cw: 7, ww: 7 [11:40:15][D][lampsmartpro:180]: LampSmartProLight::write_state called! Requested cw: 7, ww: 7 [11:40:15][D][lampsmartpro:180]: LampSmartProLight::write_state called! Requested cw: 7, ww: 7 [11:40:15][D][lampsmartpro:180]: LampSmartProLight::write_state called! Requested cw: 7, ww: 7 [11:40:15][D][lampsmartpro:180]: LampSmartProLight::write_state called! Requested cw: 7, ww: 7 [11:40:15][D][lampsmartpro:180]: LampSmartProLight::write_state called! Requested cw: 7, ww: 7 [11:40:15][D][lampsmartpro:180]: LampSmartProLight::write_state called! Requested cw: 7, ww: 7 [11:40:15][D][lampsmartpro:180]: LampSmartProLight::write_state called! Requested cw: 7, ww: 7 [11:40:15][E][lampsmartpro:381]: Error putting command to queue

@flicker581
Copy link
Contributor

@Di1Ly,
thanks for your feedback.
First of all, if lampify works for you, then variant 1b also should (it is very similar, but I could miss something). Have you done binding of the ESP to your lamp? In this project, you need to call a service to do that, e.g. "ESPHome: ble_lampsmart_pair_v1b_light".

As for the error, "error putting command to queue" means that there are too many commands had been submitted, and waiting for a chance to be sent. For now, the queue is static and limited to 10. I see multiple write_state calls with the same (low) brightness in the same second.
This is because I have tried to make the thing asynchronous and get rid of delays. We may ignore the error for now and concentrate on Prepared packet/Advertising start/Advertising stop.

@Di1Ly
Copy link

Di1Ly commented Mar 6, 2024

@flicker581 fogot about pair... I have try to pair now but no results. No blinking by lamp after pair was started. I have power off lamp by switch every time before pair.

her is the log:
[12:37:48][D][lampsmartpro:200]: LampSmartProLight::on_pair called! [12:37:48][D][lampsmartpro:405]: Prepared packet: 02.01.02.1B.03.71.0F.55.13.F0.69.25.4E.31.51.BA.AE.08.0A.B4.C9.BA.BC.71.DF.88.7E.94.8B.2C.4C (31) [12:37:48][D][lampsmartpro:409]: Advertising start [12:37:49][D][lampsmartpro:396]: Advertising stop [12:38:12][D][lampsmartpro:200]: LampSmartProLight::on_pair called! [12:38:12][D][lampsmartpro:405]: Prepared packet: 02.01.02.1B.03.77.F8.B6.5F.2B.5E.00.FC.31.51.CC.CB.92.79.2E.4A.7B.FC.25.F7.51.81.E9.97.FB.14 (31) [12:38:12][D][lampsmartpro:409]: Advertising start [12:38:13][D][lampsmartpro:396]: Advertising stop [12:38:37][D][lampsmartpro:200]: LampSmartProLight::on_pair called! [12:38:37][D][lampsmartpro:405]: Prepared packet: 02.01.02.1B.16.F0.08.10.80.71.11.1A.D7.B3.D0.95.70.62.FF.C7.CE.06.3D.C5.54.14.00.F1.BA.35.38 (31) [12:38:37][D][lampsmartpro:409]: Advertising start [12:38:37][D][lampsmartpro:396]: Advertising stop [12:39:10][D][lampsmartpro:200]: LampSmartProLight::on_pair called! [12:39:10][D][lampsmartpro:405]: Prepared packet: 02.01.02.1B.16.F0.08.10.80.C3.21.30.C9.3C.CA.FE.32.24.E5.E9.F8.3B.DF.3F.4F.99.F9.FC.41.E8.AA (31) [12:39:10][D][lampsmartpro:409]: Advertising start [12:39:10][D][lampsmartpro:396]: Advertising stop [12:39:10][I][ota:117]: Boot seems successful, resetting boot loop counter. [12:39:10][D][esp32.preferences:114]: Saving 1 preferences to flash... [12:39:10][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed

@flicker581
Copy link
Contributor

@Di1Ly please update from my repository and try 1b one more time. There was an mistake.

@Di1Ly
Copy link

Di1Ly commented Mar 6, 2024

@flicker581 Thank you for rapid reply. I have changed ESP32 board from ESP32-CAM to ESP32 NodeMCU and now I can succefuly pair and control lamp by V1a. It is works! I will try updated repo now and will give feedback.

@oxcid3
Copy link

oxcid3 commented Mar 7, 2024

To everyone who's been involved so far.
THANK YOU SO MUCH!

Can confirm that my light now works with @flicker581 's V1b variant.

For those still struggling, ensure to review the example code as I wasn't setting the 'Variant' attribute and that's what allowed mine to work.

https://github.com/flicker581/esphome-lampsmart/blob/main/example_lampsmart_pro_light.yaml

This is game changing. Thanks so much again.

@cekosss
Copy link

cekosss commented Mar 15, 2024

I can confirm @oxcid3 last post!

V1b variant works really great on my Lamp too!! Unbelievable work!!! @flicker581
Thanks a lot!!

@aronsky
Copy link
Owner

aronsky commented Mar 17, 2024

Thanks for everyone's work on the issue. Please note that I pushed a refactored the structure of the repo. I left the lampsmart_pro_light folder for backwards compatibility for now, but for future development, I created the ble_adv_light component, that should be used for all lights that are controlled by BLE advertisements. Currently, it supports lights controlled by LampSmart Pro, and lights controlled by ZhiJia (I ran into that app with a LED driver from Ali Express).

I believe that with this new structure, it should be easier to extend the code to support different kinds of messages. It's still not perfectly generalized, but please see the way the new ZhiJia light is implemented - the code in zhijia_light.cpp is largely unaware of the actual advertisement content, and that data is provided by the get_adv_data function in a different file (it would probably make sense to put it as a pure virtual method into BleAdvLight class). So, the idea is - that if you want to add support for different packet generation algorithms for LampSmart Pro, just refactor the LampSmart Pro in a similar manner, and use the configuration to choose the implementation of get_adv_data to use.

I should probably write a better guide for contributing, but not sure I'll find the time - for now, feel free to open PRs and we'll discuss changes as we go.

@yacko1975
Copy link

After reading through this decoding the ble code was something that needed to happen when I was decoding the fan data I had on a similar app, so I wrote a page to do this work for you

@maxotkin
Copy link

maxotkin commented Jul 20, 2024

I was able to use the nRF Connect app on my phone to intercept the signal from the tablet on which the LampSmart Pro was installed. I was able to clone the on and off signals, now I can turn the lamp on and off via the phone's nRF Connect.
Here is the signal to turn off UUIDs:
0x08F0, 0x8030, 0x14B8, 0x27E1, 0xF4DB, 0xC195, 0x7D65, 0x9FA4, 0xF667,0x50B6, 0x8BB8, 0x2B53, 0x68E9
Here are the inclusion UUIDs:
0x08F0, 0x8030, 0x33B8, 0x27E1, 0xF4DB, 0xC195, 0x7C65, 0x9FA4, 0xF667, 0xD8B6, 0x8B9E, 0x2B53, 0xDA2F
I downloaded logs from nRF Connect based on the shutdown signal:
2024-07-20 02:14:52,923 -54 0x0201020503AABB1234
2024-07-20 02:14:52,799 -63 0x0201020503AABB1234
2024-07-20 02:14:52,713 -63 0x0201021B0377F8B65F2B5E00FC31515046920824CB15FC0764F492E58DEEEE
2024-07-20 02:14:52,599 -64 0x0201021B0377F8B65F2B5E00FC31515046920824CB15FC0764F492E58DEEEE
2024-07-20 02:14:52,512 -64 0x0201011B03F0083080B8F7E127DBF495C1657DA49F67F6B630348B532B38A2
2024-07-20 02:14:52,396 -59 0x0201011B03F0083080B8F7E127DBF495C1657DA49F67F6B630348B532B38A2
2024-07-20 02:14:52,322 -61 0x0201011B0377F8B65F2B5E00FC31515046920824CB15FC0764F492E58DEEEE
2024-07-20 02:14:52,200 -60 0x0201011B0377F8B65F2B5E00FC31515046920824CB15FC0764F492E58DEEEE
2024-07-20 02:14:52,109 -64 0x0201011B03F0083080B8F7E127DBF495C1657DA49F67F6B630348B532B38A2
2024-07-20 02:14:51,996 -59 0x0201011B03F0083080B8F7E127DBF495C1657DA49F67F6B630348B532B38A2
2024-07-20 02:14:51,792 -68 0x0201011B0377F8B65F2B5E00FC31515046920824CB15FC0764F492E58DEEEE
2024-07-20 02:14:51,707 -54 0x0201011B03F0083080B8F7E127DBF495C1657DA49F67F6B630348B532B38A2
2024-07-20 02:14:51,588 -61 0x0201011B03F0083080B8F7E127DBF495C1657DA49F67F6B630348B532B38A2
2024-07-20 02:14:51,496 -57 0x0201011B0377F8B65F2B5E00FC31515046920824CB15FC0764F492E58DEEEE
2024-07-20 02:14:51,293 -53 0x0201011B03F0083080B8F7E127DBF495C1657DA49F67F6B630348B532B38A2
2024-07-20 02:14:51,156 -51 0x0201011B03F0083080B8F7E127DBF495C1657DA49F67F6B630348B532B38A2
2024-07-20 02:14:51,096 -51 0x0201011B0377F8B65F2B5E00FC31515046920824CB15FC0764F492E58DEEEE
2024-07-20 02:14:50,946 -53 0x0201011B0377F8B65F2B5E00FC31515046920824CB15FC0764F492E58DEEEE
2024-07-20 02:14:50,884 -51 0x0201011B03F0083080B8F7E127DBF495C1657DA49F67F6B630348B532B38A2
2024-07-20 02:14:50,750 -55 0x0201011B03F0083080B8F7E127DBF495C1657DA49F67F6B630348B532B38A2
2024-07-20 02:14:50,667 -52 0x0201021B0377F8B65F2B5E00FC31515046920824CB15FC0764F492E58DEEEE
2024-07-20 02:14:50,551 -51 0x0201021B0377F8B65F2B5E00FC31515046920824CB15FC0764F492E58DEEEE

I compared the time and signal strength and can say that UUIDs: 0x08F0, 0x8030, 0x33B8, 0x27E1, 0xF4DB, 0xC195, 0x7C65, 0x9FA4, 0xF667, 0xD8B6, 0x8B9E, 0x2B53, 0xDA2F
Equals:
0x0201011B03F0083080B8F7E127DBF495C1657DA49F67F6B630348B532B38A2
But I don’t understand how to compare them to each other.
I did not find such types of signal from flicker581
I tried editing the library in the V2 and V3 version of the switch, but nothing worked.
Please help!
I spent several days setting it up, but nothing worked, two days down the drain!

@NicoIIT
Copy link
Contributor

NicoIIT commented Aug 19, 2024

@maxotkin , you can checkout this fork.
Newly added features:

From your previously logged messages I would say the following would do the job without pairing if you have not changed anything:

ble_adv_controller:
  - id: my_controller_id
    encoding: lampsmart_pro
    variant: v3
    forced_id: 0xB4555A3F
light:
  - platform: ble_adv_controller
    ble_adv_controller_id: my_controller_id
    name: My Light

If you want to test I am available for support!

@maxotkin
Copy link

maxotkin commented Aug 20, 2024

@maxotkin, вы можете оформить заказ на этот форк. Недавно добавленные функции:

Исходя из ваших ранее зарегистрированных сообщений, я бы сказал, что следующее выполнит работу без сопряжения, если вы ничего не изменили:

ble_adv_controller:
 - id: my_controller_id
    кодировка: lampsmart_pro
    вариант: v3
    forced_id: 0xB4555A3F
light:
 - платформа: ble_adv_controller
    ble_adv_controller_id: my_controller_id
    имя: Мой свет

Если вы хотите протестировать, я доступен для поддержки!

@NicoIIT You are a genius! Thanks! It's working! The lamp turns on and off! It changes brightness and color! That's just the colors white and yellow have changed places

@NicoIIT
Copy link
Contributor

NicoIIT commented Aug 20, 2024

@maxotkin , the cold / warm can be reversed, see the doc.

ble_adv_controller:
  - id: my_controller_id
    encoding: lampsmart_pro
    variant: v3
    forced_id: 0xB4555A3F
    reversed: true
light:
  - platform: ble_adv_controller
    ble_adv_controller_id: my_controller_id
    name: My Light

@maxotkin
Copy link

@NicoIIT , I have already managed to find and deal with this problem! Thank you so much again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests