Tuya / Smart Life Switch do not update state

Also had this problem, was driving me insane so started using LocalTuya and it worked a treat with instant switch states.

Like you, not familar with this whole terminal thing and really struggled to get my localKey. So I found a way to do it with Windows (see no reason it should not work for Mac?), Android and the Smart Life app. Suspect there may be versions of the Tuya app that work as well but I never tested this.

Here are the steps I took to get my localKey:

  1. Download an Andorid emulator, I used LDPlayer
  2. Within the emulator, use play store to download a file explorer which allows root access, I used Solid Explorer
  3. Download Smart Lie app v3.6.1 (This one definitley works, I tried various other versions without success) - Here is the one i used: https://www.apkmirror.com/apk/tuya-inc/smart-life-smart-living/smart-life-smart-living-3-6-1-release/smart-life-smart-living-3-6-1-android-apk-download/
  4. Login to your newly downloaded Smart Life v3.6.1 app as normal so you can see your Tuya devices and activate a couple.
  5. Go back to home screen and load the Solid Explorer app or your choosen file explorer app for Android (you will have enable root access before the next step)
  6. From Root, goto ‘data > data > com.tuya.smartlife > shared_pref’. Within this folder will be a file called preferences_glbal_keyeu123456789123ABCFGD.xml (the later part of the file name after keyeu is random).
  7. In this file you will find your localKey, you can copy this out into a text editor in windows and do a search for localKey.

Here is mine shown in Solid Explorer

I made my garage door working with this one “rospogrigio/localtuya”. Took a little while to understand what are the values to put during setup. Incase anyone is looking for:
I have selected switch from the dropdown list for my garage door opener(assuming you have your devide id and key, and came to the part where it asks for different values). I have just selected 1 in the ID field and leave rest blank. I can see the switch state changes almost immediately and not using cloud anymore. Cheers.
But still struggling with a light.

Hi,
I am also struggling with getting lights to work. issue is to get the ‘API secret from tuya’ - Virtual id is simple as its in the app. I still am not sure how to get the ’ API secret from tuya’.

I tried the solution given by @Swoosh but no luck as Tuya app given in his link doesn’t display the information anymore.

Edit - I was able to get the API Keys but I get the below error in LocalTuya (Initially yesterday Night the devices were visible in the dropdown - not sure what happened overnight as I never made any changes)

LocalTuya error

Restart HA to free the port. After the restart the discovered devices should show up again.

I did restart multiple times but no result - i keep getting the exact same error each and everytime.
haven’t got a clue on how to fix thi issue

Gents, you are very much beyond me…

I am a complete newbie to home automation. I bought an Alexa and several tuya(Smartlife) switches from Amazon. Most of the switches are working fine… but one of them is not keeping it’s state when toggled. I select it using the Smart Life app… the switch turns on. A second or two later the state in the software returns to off… but the switch itself stays on. I hit the button again, and the switch state in the software shows on for a second or two and the switches itself goes to off. So the switch itself is toggling… but the state isn’t being held correctly.

How does a newbie Alexa users fix this?

Thanks in advance for your patience with a newbie.
Mark

SmartLife tech support determined that 3 of the 4 switches I bought are bad. Returning everything and buying something else.