Using GenyMotion to capture device id and device key
In place of a rooted phone, we can download GenyMotion (Android emulator) to grab the Tuya app's config file which contains our device id and key. This method came from a thread on Home Assistant Community forums: https://community.home-assistant.io/t/alternative-tuya-smart-outlet-setup/51830
I was able to follow this almost exactly to get what I needed but there were some pieces missing.
![]() |
| In Genymotion I used a nexus 5x |
I grabbed the Tuya Smart app from APKPure (https://apkpure.com/tuya-smart/com.tuya.smart) but when I dragged the apk onto my emulator I got an error about ARM binary not being able to run on my processor. After a bit of fumbling around I found guides that suggested I install an ARM Translation. I found an "ARM_Translation_Marshmallow.zip" that I was able to download and drag onto my emulator (just drag the zip) after confirming I wanted to flash, and prompting for reboot I was able to drag my Tuya Smart apk and install it without issue.
After logging into the Tuya Smart App I saw my devices as expected (hooray!). What followed was extremely simple. I used:
After grabbing the full directory I wrote a quick thing to get me the key and id I needed:
Future Andrew, after opening TuyaSmart in GenyMod, copy and paste:
Be on the lookout for resolution of: https://github.com/clach04/python-tuya/issues/29
adb pull ./data/data/com.tuya.smart ~/
My config lived in nearly the same location as OP on the Home Assistant Forums, at:
./data/data/com.tuya.smart/shared_prefs/preferences_global_keyRANDOMSTRING.xmlcat ~/com.tuya.smart/shared_prefs/*.xml | sed -e 's/"/"/g' | sed -e 's/.*home_data.*">{"/{"/g' -e 's/<\/string>.*//g' | grep -v "<" | jq '.deviceRespBeen[] | .name + " -- key: " + .localKey + " -- id: " + .key'Future Andrew, after opening TuyaSmart in GenyMod, copy and paste:
adb pull ./data/data/com.tuya.smart ~/; cat ~/com.tuya.smart/shared_prefs/*.xml | sed -e 's/"/"/g' | sed -e 's/.*home_data.*">{"/{"/g' -e 's/<\/string>.*//g' | grep -v "<" | jq '.deviceRespBeen[] | .name + " -- key: " + .localKey + " -- id: " + .key'; rm -rf com.tuya.smartBe on the lookout for resolution of: https://github.com/clach04/python-tuya/issues/29

No comments:
Post a Comment