ble_monitor icon indicating copy to clipboard operation
ble_monitor copied to clipboard

[Bug]: Yeelight dimmer YLKG08YL’s state cannot be detected.

Open micturkey opened this issue 1 year ago • 5 comments

What happened?

Hi, I have three yeelight dimmer which are two YLKG07YLs and one YLKG08YL. The problem is that I can configure the YLKG07YLs and they work, but after my configuration (use miiocli to get ble token and put it into ble monitor’s settings), YLKG08YL doesn’t work. I can neither see the state nor the rssi in homeassistant, they are all “unknown”.

Something strange is that in YLKG07YL it says “Xiaomi (MiBeacon V3 encrypted)” but in YLKG08YL it says “ Xiaomi (MiBeacon V5 encrypted)”.

Sensor type

YLKG08YL

Relevant log output

No response

micturkey avatar Jul 22 '22 09:07 micturkey

hmm, BLE monitor assumes MiBeacon V3 encrypted for both, with the "short" 24 byte encryption key. It might be that Xiaomi/Yeelight has done a firmware update on the YLKG08YL, so they use the new encryption format with the "long" 32 byte encryption key.

We can probably find out by using the report unknown option for the specific sensor. Check this page how you can collect the ble data. https://custom-components.github.io/ble_monitor/sensor_request.

You can probably find the long 32 character encryption key with Xiaomi Cloud token extractor https://custom-components.github.io/ble_monitor/faq#my-sensors-ble-advertisements-are-encrypted-how-can-i-get-the-key

Note: V3 = 24 bytes encryption key V5 = 32 byte encryption key

Ernst79 avatar Jul 22 '22 09:07 Ernst79

hmm, BLE monitor assumes MiBeacon V3 encrypted for both, with the "short" 24 byte encryption key. It might be that Xiaomi/Yeelight has done a firmware update on the YLKG08YL, so they use the new encryption format with the "long" 32 byte encryption key.

We can probably find out by using the report unknown option for the specific sensor. Check this page how you can collect the ble data. https://custom-components.github.io/ble_monitor/sensor_request.

You can probably find the long 32 character encryption key with Xiaomi Cloud token extractor https://custom-components.github.io/ble_monitor/faq#my-sensors-ble-advertisements-are-encrypted-how-can-i-get-the-key

Note: V3 = 24 bytes encryption key V5 = 32 byte encryption key

Hi, logs said these:

Logger: custom_components.ble_monitor.ble_parser.xiaomi Source: custom_components/ble_monitor/ble_parser/xiaomi.py:1006 Integration: Passive BLE monitor (documentation, issues) First occurred: 16:31:24 (1 occurrences) Last logged: 16:31:24 Encryption key should be 16 bytes (32 characters) long

2022-07-23 16:31:24 ERROR (Thread-4) [custom_components.ble_monitor.ble_parser.xiaomi] Encryption key should be 16 bytes (32 characters) long 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:24 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID 102d416ae833: service data: [b'\x15\x16\x95\xfeHP\xb6\x03\xa2\x8a\x15\i \xea\x06\x00\x00\xa6xx\xca']manufacturer specific data: []local name: UUID16: None,UUID128: None 2022-07-23 16:31:26 ERROR (Thread-4) [homeassistant] Error doing job: Fatal error: protocol.data_received() call failed. Traceback (most recent call last): File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 868, in _read_ready__data_received self._protocol.data_received(data) File "/usr/local/lib/python3.10/site-packages/aioblescan/aioblescan.py", line 1855, in data_received self.process(packet) File "/config/custom_components/ble_monitor/init.py", line 662, in process_hci_events sensor_msg, tracker_msg = self.ble_parser.parse_raw_data(data) File "/config/custom_components/ble_monitor/ble_parser/init.py", line 135, in parse_raw_data complete_local_name = adstruct[2:].decode("utf-8") UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf8 in position 0: invalid start byte 2022-07-23 16:32:05 ERROR (Thread-4) [homeassistant] Error doing job: Fatal error: protocol.data_received() call failed. Traceback (most recent call last): File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 868, in _read_ready__data_received self._protocol.data_received(data) File "/usr/local/lib/python3.10/site-packages/aioblescan/aioblescan.py", line 1855, in data_received self.process(packet) File "/config/custom_components/ble_monitor/init.py", line 662, in process_hci_events sensor_msg, tracker_msg = self.ble_parser.parse_raw_data(data) File "/config/custom_components/ble_monitor/ble_parser/init.py", line 135, in parse_raw_data complete_local_name = adstruct[2:].decode("utf-8") UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf8 in position 0: invalid start byte

It seems that it is really encrypted by 32 character key. But since I don't have any android devices, I will try get_beacon_key python script later. ahhhhh, I suddenly found that bluepy does not work on macOS :(. Maybe the best way for me is to find an android devices...

micturkey avatar Jul 23 '22 08:07 micturkey

You might get the key with xiaomi cloud token extractor, if it is added in MiHome. It gets the key from the cloud and works in windows

Ernst79 avatar Jul 23 '22 09:07 Ernst79

You might get the key with xiaomi cloud token extractor, if it is added in MiHome. It gets the key from the cloud and works in windows

Yes... but this dimmer cannot be directly added to mihome, can it? That means I have to find an android device to use modified mihome to add it 🤣

micturkey avatar Jul 23 '22 10:07 micturkey

You’re probably right, but perhaps they have changed MiHome support too with the new firmware. Worth to try

Ernst79 avatar Jul 23 '22 11:07 Ernst79

any progress? i'm unable to get even the YLKG07YL to properly work, I only see RSSI even with encryption key I got through Token Extractor.

Stooovie avatar Oct 24 '23 20:10 Stooovie