Alternative Tuya smart outlet setup

Did you managed to control the usb? Can you share your yaml code please?

This is brilliant thanks!

I couldn’t get the lights to turn on/off until I turned off the WiFi on my phone. With it off, it took about a minute before they started working. Whatever connection the app has to the server, it must take a minute to timeout once disconnected.
But, they work!
So, once again, thanks!

Hi,
I have Jinvoo installed on my phone so I tried with installing Jinvoo on Genymotion so I think above should change. But, I can’t even find the installation folder in the root. Data folder inside root seems to be empty when inspected through Amaze. Where on root could these files be located? Any help is appreciated!
Thank you,
Manjula

OK. Figured that out. No need of all this. Just follow this

Thanks for the guide, managed to extract the device id’s and local keys for 14 switches.

I didn’t have a file speciifically named ‘dev_data_storage.xml’, to extract the devid 's and localkey’s.
The xml file containing this information was in the same directory (shared_prefs) the xml file name started with ‘preferences_global’.

I’m assuming it should be, but is this significantly quicker or better than the current default tuya integration?

I’ve got about 9 light switches - everything works fine - I can use the app, google home, hass and (ick) fingers, to change. Only real issue is:

2018-12-07 15:13:27 WARNING (MainThread) [homeassistant.components.switch] Updating tuya switch took longer than the scheduled update interval 0:00:30
2018-12-07 15:47:00 WARNING (MainThread) [homeassistant.components.switch] Updating tuya switch took longer than the scheduled update interval 0:00:30
2018-12-07 15:48:02 WARNING (MainThread) [homeassistant.components.switch] Updating tuya switch took longer than the scheduled update interval 0:00:30
2018-12-07 15:49:04 WARNING (MainThread) [homeassistant.components.switch] Updating tuya switch took longer than the scheduled update interval 0:00:30
2018-12-07 15:50:05 WARNING (MainThread) [homeassistant.components.switch] Updating tuya switch took longer than the scheduled update interval 0:00:30

Some of which may be my congested 2.4ghz wifi. Or might be the volume of connections going to the tuya server(s) meaning they need to throw some hardware at it, given this seems to be the OEM smart system of choice…

1 Like

Is this in the “adb” directory? I can’t seem to find this anywhere.

It was in the “shared_prefs” folder. The xml file began with ‘preferences_global’ the complete file name had a string of numbers after it.
The file structure was the same as indicated in the OP.
./data/data/com.tuya.smartlife/shared_prefs/

Should it be located here:
PS C:\adb\platform-tools_r28.0.1-windows>
Am I in the right directory?

I think your looking on your PC, it’s found on the Android device
Did you install the smartlife app on your emulator or android device?
The directory your looking for is found on the android device or emulator after you have installed the smartlife app and signed into your app. You should be able to navigate to the folder on the android dev/emulator. ( if you followed step as described in step 1 or 2).
Then you need to work out the exact path of the xml file, thats contains the local keys and dev ids, on your android device/emulator.
Once you have found the correct file and path,then you can copy the file to your PC using adb in powershell (from your PC, as described in step 3).

How did you overcome the ARM build issue?

An error occured while deploying the file.
This probably means that the app contains ARM native code and your Genymotion

Figured this out. Had to install the arm translation (just dropped the zip on top of the running emulator to flash).

Also, I have my devices added through the Tuya Smart app, not Smart Life. Tuya Smart has nearly the same file location, mine being ./data/data/com.tuya.smart/shared_prefs and my file was named preferences_global_keySEEMINGLY_RANDOM_STRING.xml. I wrote a little bash thing to parse the file and give me my outputs. The command string below requires the jq command.

cat YOUR_XML_FILE.xml | sed -e 's/&quot;/"/g' | sed -e 's/.*home_data.*">{"/{"/g' -e 's/<\/string>.*//g' | grep -v "<" | jq '.deviceRespBeen[] | .name + " -- key: " + .localKey + " -- id: " + .key'

If successful, you should get an output like:

"Desk Lamp -- key: OBFUSCATED -- id: OBFUSCATED"
"Guest Lamp -- key: OBFUSCATED -- id: OBFUSCATED"
"Master Lamp -- key: OBFUSCATED -- id: OBFUSCATED"
"Master Lamp 2 -- key: OBFUSCATED -- id: OBFUSCATED"

you can then put the key and id as provided in your switches config.

1 Like

I had the ARM issue as well and found this article fixed it: https://pentester.land/tips-n-tricks/2018/10/19/installing-arm-android-apps-on-genymotion-devices.html

Hey, which component did you use to get yours to work? The one linked in the OP is gone now, and I’ve ben getting errors with another I’ve been trying.

1 Like

I’m also trying to find the proper tuya.py file :point_up_2:

Bump for the proper tuya.py. it really irks me that default integration requires outside internet connectivity

Linked here, let me know if that doesn’t work. @kikettas @varjo

One note: I have some devices that seem to respond poorly to being controlled/queried by the custom component, they will randomly crash after being controlled or queried and then the device stays off. I believe this is an issue with the firmware on the device, not a problem with the component.

I ended up having to use the custom component (I use it where I can cause it’s fast, and no internet connection is needed) AS WELL AS the official Tuya component for other devices. This will lead to a name conflict, so if you do this you need to name the custom component tuya_custom.py or something…

1 Like

Wonderful, thank you! Assuming no custom component works with Tuya bulbs yet? Local is definitely nice for responsiveness.

I ended up flashing Tasmota to both devices (both have the ESP8266 chip) :sweat_smile:. Thank you anyway @aneisch for sharing it!

Thanks for that. I’m getting errors that some dependencies couldn’t be loaded now.