Step 1 Download & Install the latest version of Android Studio from here: https://developer.android.com/studio
(in my case 2020.3.1)
Step 2 On the first startup of Android Studio you have to complete the setup wizard:
![r/homeassistant - Guide on extract a local key from a Ledvance Bulb (for Local Tuya)](https://community-assets.home-assistant.io/original/3X/5/a/5a46f2a7b1dfe096c003444aa3d5677e84e5e87a.png)
![r/homeassistant - Guide on extract a local key from a Ledvance Bulb (for Local Tuya)](https://community-assets.home-assistant.io/original/3X/0/f/0feb835792622c2eec767fe43c3f78c4375ed54c.png)
Keep everything on default settings
![r/homeassistant - Guide on extract a local key from a Ledvance Bulb (for Local Tuya)](https://community-assets.home-assistant.io/original/3X/c/1/c11f693eb635507313c09b3dec2c42cfe7fe4be5.png)
Step 3 Open an empty folder (e.g. on your desktop)
![r/homeassistant - Guide on extract a local key from a Ledvance Bulb (for Local Tuya)](https://community-assets.home-assistant.io/original/3X/6/a/6a7311af48e678cb060488b7f9c30f9113055f4b.png)
![r/homeassistant - Guide on extract a local key from a Ledvance Bulb (for Local Tuya)](https://community-assets.home-assistant.io/original/3X/6/2/6222619c0a053ca52a9f8ef7b8fea549699751f5.jpeg)
Step 4 Open the AVD Manager and create a virtual device
![r/homeassistant - Guide on extract a local key from a Ledvance Bulb (for Local Tuya)](https://community-assets.home-assistant.io/original/3X/f/e/fec4566fb7dea3a879683229abf27712eb0204d3.png)
Step 5 Select a device without Play Store (important!!) E.g. Pixel 2 XL
![r/homeassistant - Guide on extract a local key from a Ledvance Bulb (for Local Tuya)](https://community-assets.home-assistant.io/original/3X/c/a/ca93581065af135e80a786996945a0ff1abed61e.png)
Step 6 Click on Download for the Pie system image (API Level 28, Android 9.0)
![r/homeassistant - Guide on extract a local key from a Ledvance Bulb (for Local Tuya)](https://community-assets.home-assistant.io/original/3X/7/b/7b3dddc14213a4df2ae908609cb91aa4f99f6f9a.png)
Step 7 Select the downloaded image and click next
Step 8 Now you can start the emulator (play button)
![r/homeassistant - Guide on extract a local key from a Ledvance Bulb (for Local Tuya)](https://community-assets.home-assistant.io/original/3X/f/c/fc5cf2a986b8e54723d8a7e4dbf36d9de281cce4.png)
![r/homeassistant - Guide on extract a local key from a Ledvance Bulb (for Local Tuya)](https://community-assets.home-assistant.io/original/3X/8/5/85a08a0cff90088e22efb69f03ef6d2d7cfa37e1.png)
Step 9 Download python 3.9.x
From here https://www.python.org/downloads/release/python-396/
If you are using Windows 10 64bit I would recommend the installer:
https://www.python.org/ftp/python/3.9.6/python-3.9.6-amd64.exe
Step 10 Run the installer and make sure you select “Add Python 3.9 to PATH”
![r/homeassistant - Guide on extract a local key from a Ledvance Bulb (for Local Tuya)](https://community-assets.home-assistant.io/original/3X/2/0/205346eb7ad7c13e8ace4239acdac1de6652f734.jpeg)
Step 11. Open powershell and install frida tools via pip:
pip install frida-tools
Step 12. Download frida-server from https://github.com/frida/frida/releases
(I used frida-server-15.0.17-android-x86.xz)
Step 13. Extract to a directory via 7zip, WinRAR,… and rename the file to frida-server
Step 14 Setup adb (you can follow this guide https://medium.com/androiddevelopers/help-adb-is-not-found-93e9ed8a67ee)
On Windows I just added C:\Users\[your username]\AppData\Local\Android\Sdk\platform-tools
to my PATH variable.
Step 15 Run the adb commands from the directory, where you have extraced frida-server
to:
adb root
adb push frida-server /data/local/tmp/
adb shell "chmod 755 /data/local/tmp/frida-server"
adb shell "/data/local/tmp/frida-server &"
(press CTRL+C, this will not stop the server)
Step 16 Download the ldvwifi apk that FrancYescO mentioned: https://m.allfreeapk.com/ledvance-smart-wifi,17068539/download.html.
EDIT: Link is broken now. You may want to look at hints here: https://community.home-assistant.io/t/howto-ledvance-smart-plug-wifi-in-home-assistant-solution/350280?u=flag
Step 17 Run from the same directory where you have downloaded com-ldvsmartwifi-smart-1.apk
:
adb install com-ldvsmartwifi-smart-1.apk
Step 18 At this point you have an emulated rooted device with frida-server and the old LEDVANCE SMART+ WiFi Apk installed. Now you can do the last steps that are mentioned by FrancYescO (no macos is needed):
login to the app on the android device, than on macos launch this command with the app in foreground frida-trace -U --decorate -j '*!*encodeString*/isu' -F
, refresh the list of device and you will get on the terminal a json-like blob, copy in a text editor and ctrl+f for localKey
(oviusly if you have more than one device you will get multiple keys, also if you configured any group in the app)
Hint for windows users: If the last command outputs Started tracing 0 functions. Press Ctrl+C to stop.
, you should try it in powershell or in cmd.exe without quotes (frida-trace -U --decorate -j *!*encodeString*/isu -F
). If it is sucessfull it should trace 2 functions.