HowTo - Ledvance SMART+ Plug Wifi in Home Assistant (Solution)

Hello guys, I tried these instructions but at the point of tracing the emulated app stops working and i get the error: “Failed to attach: process with pid 9632 either refused to load frida-agent, or terminated during injection”
Did I maybe download the wrong akp? The “newer” Links was still working and I got the file “com-ldvsmartwifi-smart-4.apk”
Any ideas?

EDIT: I just checked in the emultor that the app seems to be verison 1.2.0 and not 1.0.0 as claimed in the beginning. I found online the version 1.1.0 but that did not work eihter.
So maybe someone can provide the actual 1.0.0 version of the apk?

please read my hints in my solution, there is the link to the 1.0.0 Version. try the Steps and read my solution for several steps, then you will have success.

Just wanna add how I resolved it:
type: adb shell
type: ps -e | grep frida-server
output: root 12483 1 57724 4112 poll_schedule_timeout e8889b39 S frida-server
type: kill -9 12483
type: exit
go back to step 15
in step 18 when the frida server wont stat, i typed “exit” and then again

frida-trace -U --decorate -j *!*encodeString*/isu -F

then it worked saying “Instrumenting…”

1 Like

after the command: 'adb shell “/data/local/tmp/frida-server &” ’ i get the error: ‘/data/local/tmp/frida-server: not executable: 32-bit ELF file’ any solution ?
I’m on the Mac. everything else is working
fixed: used frida-server-15.1.14-android-arm64

Always get Started tracing 0 functions :frowning:

Ah, @mastergizmo presented a solution here

Dear @Keules,

Thank you for the excellent tutorial!

These are my very first steps with HA. But I’ve managed to get the IDs and connect the plugs to HA. Only as a simple switch though, without energy consumption monitoring. I’ve made a few guesses how to integrate ledvance.yaml to configuration.yaml, but all unsuccessful. I do something wrong, as it breaks the configuration.yaml.
Could anyone please share a hint how to import ledvance.yaml? Thank you in advance.

EDIT: If I manage to enable energy monitoring, then the switch breaks. HA wouldn’t allow to use ID 1 for both: binary_sensor and switch.

Hello @Keules and gang.

This really is an excellent tutorial but there are so many variables including knowledge that this should be turned into some sort of utility and integration. Ledvance is soooo much more inexpensive and locally available that it would just make sense for someone SMART+ to do this.

I am having problems getting the ADB to stay up on my machine for whatever reason which is what I think is generally my problem. Should I reinstall the development platform?

Appreciate any help or assistance.

Frank

Hi all,

at first, thank you for the great tutorial.
I’m new to HA and was happy to find a way to add my Ledvance Wifi Plugs.
BUT i got stuck on the part were i have to trace.

PS D:\> frida-trace -U --decorate -j *!*encodeString*/isu -F
No frontmost application on Android Emulator 5554

I always get this message. One strange thing, on step 15 everytime i try the last command i get this message

generic_x86_arm:/ # /data/local/tmp/frida-server &
[1] 9856
generic_x86_arm:/ # /system/bin/sh: /data/local/tmp/frida-server: can't execute: Is a directory

Maybe this is my issue?

To be sure i have checked the app version of ledvance and it is 1.2.0
I used the URL here from this post. Name is the same but it will install 1.2.0 instead of 1.0.0

Another possible source for the issue?

I also tried to use another frida server version like told by jjuuzzii. Also no chance.

Has some one else any ideas?

Regards
Umbra

Hi @UmbraLamia,

I have the same problem exactly. I am also interested in a solution.

@Flag Appreciate any advice.

Any chance to create a custom integration?

Frank

Hi @Flag, @UmbraLamia, @Keules;

I finally got mine working. I’ve attached a what I did.

frida-server-15.0.17-android-x86.xz
com-ldvsmartwifi-smart-4.apk

Python13.10.2
Win10 64
Android Studio Bumblebee | 2021.1.1
Build #AI-211.7628.21.2111.8092744, built on January 19, 2022

These commands really need to execute. If they don’t, try rebooting your computer:

C:\Users\fspat\Downloads\Frida>adb root
restarting adbd as root

C:\Users\fspat\Downloads\Frida>adb push frida-server /data/local/tmp/
frida-server: 1 file pushed, 0 skipped. 113.2 MB/s (46351796 bytes in 0.390s)

C:\Users\fspat\Downloads\Frida>adb shell “chmod 755 /data/local/tmp/frida-server”

C:\Users\fspat\Downloads\Frida>adb shell “/data/local/tmp/frida-server &”
(waited 10 seconds or so)
^C
C:\Users\fspat\Downloads>adb install com-ldvsmartwifi-smart-4.apk
Performing Streamed Install
Success

C:\Users\fspat\Downloads>frida-trace -U --decorate -j *!encodeString/isu -F
Instrumenting…
MMKV.encodeString: Auto-generated handler at “C:\Users\fspat\Downloads\handlers\com.tuya.smart.mmkv.MMKV\encodeString.js”
ByteString.encodeString: Auto-generated handler at “C:\Users\fspat\Downloads\handlers\okio.ByteString\encodeString.js”
Started tracing 2 functions. Press Ctrl+C to stop.

This is when the “blob” or “bloob” or long string gets returned. Copy and paste into a text editor and look for the localkey(s).

Good luck and thanks for all the previous work. Without which, I would have never gotten this completed! :slight_smile:

Frank

Hi @fspatt ,
thank you for your advice but it has not worked for me.
One thing i noticed, i could update PowerShell to a newer Version.
OOB it used WindowsPowerShell in Version 5.1 and now i’m using PowerShell 7.2.
Other point is, i’m on Win11 x64.

Here what happens for me:

PS C:\Users\andre> cd d:
PS D:\> adb root
adbd is already running as root
PS D:\> adb push frida-server /data/local/tmp/
frida-server\: 1 file pushed, 0 skipped. 272.8 MB/s (46351796 bytes in 0.162s)
PS D:\> adb shell chmod 755 /data/local/tmp/frida-server
PS D:\> adb shell /data/local/tmp/frida-server &

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
1      Job1            BackgroundJob   Running       True            localhost            Microsoft.PowerShell.Man…

PS D:\> adb install com-ldvsmartwifi-smart-4.apk
Performing Streamed Install
Success
PS D:\> frida-trace -U --decorate -j '*!*encodeString*/isu' -F
No frontmost application on Android Emulator 5554
PS D:\>

With the newer Version of PowerShell i don’t have an error after the shell command with the &.
Iritating is, that while pasting the shell command, the " are removed. Is this correct?

But i have stil lthe error: No frontmost application on Android Emulator 5554

On another different is, i have a newer Version of Android Studio:


Android Studio Bumblebee | 2021.1.1 Patch 1
Build #AI-211.7628.21.2111.8139111, built on February 1, 2022
Runtime version: 11.0.11+9-b60-7590822 amd64
VM: OpenJDK 64-Bit Server VM by Oracle Corporation
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 24
Registry: external.system.auto.import.disabled=true


Any other suggestions?

Regards
Umbra

Hi - after you issued the “adb shell /data/local/tmp/frida-server &” command, I had to issue a ^C in order to get the command prompt back.

Yes, I used the trace command without quotes.

Which version of Frida server are you running? I was only able to get this to work with this version frida-server-15.0.17-android-x86.xz.

Hi Frank,
as you see in my log i got the command back after the display of this “table”.
Frida server is the same version. I also tried to update the frida tools itself.

Hi @Keules,
Im pretty new to HA. Just got ledvance integraded and would like to have the consumption too.
Could you explain how you imported the ledvance.yaml into your config?
When I integrate it in /packages I get the error: expected a dictionary for dictionary value @ data['packages']['ledvance']
When I integrate it separately I dont know which component I have to use.

Do you have a Win10 machine you could try? That’s the only real difference I see.

No. Not one with enough power.
There is just one very old notebook from my son.
Could try to setup a virtual machine.

Or maybe any other idea how to get the needes IDs?

Hi,

i am stuck at the last command on step 15.

PS D:\Frida> adb shell “/data/local/tmp/frida-server &”
/system/bin/sh: /data/local/tmp/frida-server: No such file or directory

can you help me ? i have root because after typing adb shell i get following message.

PS D:\Frida> adb shell
emulator64_x86_64_arm64:/ # su

thanks in advance.

Hi - where is your Frida-server loaded?

Hi sorry for the late reply.

i started the terminal from the same location where i extracted the Frida server. do you meant that or how can i find the frida server location ?