Hello everyone,
I post here because lot of people having trouble with their YLKG07YL dimmer, and I was like you, been nuts to have beacon_key or adding it in home assistant… take me hours of digging to fix it !
Here what i’ve test, done, and check
First of all, recover the MAC adresse of the device with phone app for me “A4:C1:38:35:4F:62”
Be carefull, pressing the pariring button during 20s will change this MAC address
After that use the method 5 from Passive BLE integration FAQ :
5. get_beacon_key python script
Passively monitors BLE messages from Xiaomi Mijia BLE MiBeacon, Qingping, ATC, Xiaomi Scale, Kegtron and Thermoplus sensors .
In my case :
wget https://raw.githubusercontent.com/custom-components/ble_monitor/master/custom_components/ble_monitor/ble_parser/get_beacon_key.py
apt-get install python3-pip libglib2.0-dev
pip3 install bleak asyncio
python3 get_beacon_key.py <A4:C1:38:35:4F:62> <950>
Be sure to use a relevant linux, bluetooth and python configuration
If you can’t connect to your device or if it’s say “Disconnected!”, try this before launching the script :
hciconfig hci0 up
After that you will have something like this :
notifyData: ‘ce6b3f6f42adc97421cf015f’
cipheredRes: ‘00a486f5ff013ed04322f4e4’
randomToken: ‘00a486f5ff013ed04322f4e4’
Successful authentication!
beaconKey: ‘acec46f9b751b694e8167d02’
firmware_version: '2.0.0_0004
Now you have you beacon_key, you can configure the BLE device to HASS on configuration.yaml
But cherry on the cake you have to add eight f
to the end of the encryption_key
ble_monitor:
discovery: true
devices:
- mac: 'A4:C1:38:35:4F:62'
name: 'dimmer_yeelight'
encryption_key: 'acec46f9b751b694e8167d02ffffffff'
reset_timer: 1
opened 07:27PM - 29 Aug 22 UTC
new sensor
### Sensor Description
yeelight dimmer YLKG07YL / YLKG08YL model YLYKQ-0004
…
### Additional information
I ordered a yeelight dimmer on aliexpress on batteries YLKG07YL / YLKG08YL
The seller sent some new version
On the body of the inscription YLYKQ-0004
![2022-08-29 20-55-16](https://user-images.githubusercontent.com/74769766/187266063-e7a5ecc0-1f6d-4474-9c25-69d815ac868a.JPG)
![image](https://user-images.githubusercontent.com/74769766/187266143-770bf332-ab60-466c-9c24-fae807451dba.png)
![2022-08-29 20-55-07](https://user-images.githubusercontent.com/74769766/187266191-61c5dac9-4caf-4424-bb4a-e2bcfbba1daf.JPG)
![2022-08-29 20-55-23](https://user-images.githubusercontent.com/74769766/187266213-8563cb8b-5917-48de-949d-cbe28b940b8a.JPG)
I don't have a yeelight lamp, I just needed a dimmer.
When paired with BLE Monitor, it is defined as YLKG07YL / YLKG08YL but there is no data:
```
2022-08-29 22:07:08.868 INFO (MainThread) [custom_components.ble_monitor] Attention! Option report_unknown is enabled for Xiaomi sensors, be ready for a huge output
2022-08-29 22:07:36.418 INFO (Thread-2) [custom_components.ble_monitor.ble_parser.xiaomi] MiVer: 3, DevID: 0x3b6 : YLKG07YL/YLKG08YL,
FnCnt: 44, Not bound, Old version certification, Capability: 0xd, No encryption, Object data: 0200020110,
UNKNOWN dataobject in payload! Adv: 141695fe7030b6032c60f06a412d100d0200020110
```
Method for obtaining a key by a script:
```
root@debian11:/home/mark# python3 get_beacon_key.py 10:2d:41:6a:f0:60 950
Activate pairing on your '10:2D:41:6A:F0:60' device, then press Enter:
Connection in progress...
Successful connection!
Authentication in progress...
Traceback (most recent call last):
File "/home/mark/get_beacon_key.py", line 159, in <module>
main(sys.argv)
File "/home/mark/get_beacon_key.py", line 155, in main
get_beacon_key(mac, product_id)
File "/home/mark/get_beacon_key.py", line 113, in get_beacon_key
peripheral.writeCharacteristic(HANDLE_AUTH_INIT, MI_KEY1, "true")
File "/usr/local/lib/python3.9/dist-packages/bluepy/btle.py", line 543, in writeCharacteristic
return self._getResp('wr')
File "/usr/local/lib/python3.9/dist-packages/bluepy/btle.py", line 407, in _getResp
resp = self._waitResp(wantType + ['ntfy', 'ind'], timeout)
File "/usr/local/lib/python3.9/dist-packages/bluepy/btle.py", line 368, in _waitResp
raise BTLEGattError("Bluetooth command failed", resp)
bluepy.btle.BTLEGattError: Bluetooth command failed (code: 3, error: Attribute can't be written)
root@debian11:/home/mark# python3 get_beacon_key.py 10:2d:41:6a:f0:60 339
Activate pairing on your '10:2D:41:6A:F0:60' device, then press Enter:
Connection in progress...
Successful connection!
Authentication in progress...
Traceback (most recent call last):
File "/home/mark/get_beacon_key.py", line 159, in <module>
main(sys.argv)
File "/home/mark/get_beacon_key.py", line 155, in main
get_beacon_key(mac, product_id)
File "/home/mark/get_beacon_key.py", line 113, in get_beacon_key
peripheral.writeCharacteristic(HANDLE_AUTH_INIT, MI_KEY1, "true")
File "/usr/local/lib/python3.9/dist-packages/bluepy/btle.py", line 543, in writeCharacteristic
return self._getResp('wr')
File "/usr/local/lib/python3.9/dist-packages/bluepy/btle.py", line 407, in _getResp
resp = self._waitResp(wantType + ['ntfy', 'ind'], timeout)
File "/usr/local/lib/python3.9/dist-packages/bluepy/btle.py", line 368, in _waitResp
raise BTLEGattError("Bluetooth command failed", resp)
bluepy.btle.BTLEGattError: Bluetooth command failed (code: 3, error: Attribute can't be written)
```
Method for obtaining a key through a modified mihome (dimmer):
The device finds, loads the plugin, but then an error will appear.
There is nothing in the log folder.
Windows 10 sees the device as: yeelink.remote.seesaw
Is there any way to search for a key without a lamp and add support?
I will collect any information / dumps
[dump.txt](https://github.com/custom-components/ble_monitor/files/9447437/dump.txt)
### BLE advertisements
_No response_
Hope it will help ! Thanks to [frickeo]