Tuya / Smart Life Switch do not update state

Hello all,

I’ve read everything I can but I have a strange behavior that I was not able to fix on my HA with Smart Life.

Smart Life lights and switches have been discovered correclty with the Tuya component (platform: smart_life). Lights work perfectly. Switch do not update state correctly in the UI (old and lovelace).

If I change the switch to ON from the UI, the switch actually goes on and the UI as well. OK. Unfortunately after few seconds, the UI goes back to OFF. Refreshing the page or reloading or Force_update in developer tools does not change anything. However, restarting the server set the status correctly!

If I switch on or off from the app, the status never change in HA, unless I restart HA every-time.

Is there something I am missing with the integration? I am not sure where to look at.
Any clue will be appreciated.

Thanks,
Torpi

1 Like

Excellent! For some reason I did not find this issue when I searched. Thank you for the reference. I guess I will have to wait for .4 release since I am currently on 0.98.3.

I did the changes in switch.py file myself, restarted the server and I can confirm that it solves the problem. There is a 15-20s latency but it is working correctly.

Again, thank you!

Hi, could you tell me how can I fix it manually? Where is the file to fix and what to change.
Thanks

1 Like

It is July 14th, 2020 and the issue still exists in the last version out the box of Home assistant. How do you fix this, it is very annoying to have to toggle twice to switch off and not knowing exactly if that action worked since the toggle comes always back to off.

Patch has been deployed to the PyPi API, but just need the dependency upgrade to be merged into the released version of HA. Hopefully soon. You can manually patch in your HA instance using the code from the Tuyaha GitHub release, but it’s a bit manual.

I have no clue how to do it, there is little to no documentation about it. I am using the last version of the virtual machine of Home Assistant and the OS looks extremely limited from what I saw quickly.
I would be happy to participate though.

I also noticed that once integrated to Home assistant, the Smart Life official app on the phone does not respond properly anymore. It is like Home Assistant locks the use of the attached devices for itself even though, it should just read the status and toggle actions, nothing more. For now, I have to remove it from Home Assistant due to this very annoying behavior as I nearly lost my mind while trying to troubleshoot something using the app only this morning!!

Hopefully will be in the next release. Might be better to just wait.

Hello guys, i’ve the same problem as all of you :frowning:
I did a test yesterday and it took more than half an hour for the state to be updated (whether i switch it on phisically or with smart life app)
What are the alternatives except tasmotizing the switches which will prevent them from working with smart life ?

Hi guys,
I have the same problem. Everything works fine except when I switch the state using the physical button on the device - The HA interface is not updated until anything from 10 to 55 min. later. All devices are updated to the newest firmware. HA is also the latest version. My Sonoff devices are working perfectly.
What can be done?

I have the same issue. Took a while before the device gets updated on HA 0.115.6 running of docker. I just got a 6 Smartlife switches, none has updated state in HA when turned on via button or google assistant. Did it ever work before? I am new to HA.

Hello guys, any update of this issue? I have similar problem. I have a Garage door opener works with Tuya/Smartlife, works with google/alexa, also integrated to HA, I can open and close the Garage door from HA UI. But when I operate the Garage door from the app or the remote the UI is never updated.
The whole point was to create some automation so that I am notified if my garage was opened unknowingly or if I left it open for long time etc. But can’t do anything. Any help would be great. Thanks…

Also interested in if there’s a fix. I have a three gang switch I setup in Smart Life, and it updates as expected in the app when using it or the physical switches themselves. However Home Assistant is not receiving the status updates at all. Very frustrating as I’m trying to use the controls to manage a ceiling fan and light for the room.

Have you tried using Local-Tuya? I use it for power consumption monitoring in conjunction with the regular Tuya integration but it could theoretically replace it and be more reliable:
https://github.com/rospogrigio/localtuya-homeassistant

I am so confused with getting this setup. I added localtuya from HACS, then connected my app via the instructions but I get to step 4 where I’m to use command line, and I’m honestly not familiar with using command line with HA. I tried using ‘Terminal & SSH’ with no luck. Is there someone who could explain or show some screenshots on how to go about running the tuya-cli wizard from the command line?

On my Mac I did the following:

  1. Download and install node js from https://nodejs.org/en/download/
  2. In a terminal window enter:
    sudo npm i @tuyapi/cli -g
  3. In terminal window enter:
    tuya-cli wizard
  4. It will prompt you for the API key from tuya.com (tuya.com, platform login, Cloud Development, under My Project click on your project and copy and paste in the (Access ID/Client ID)
  5. It will prompt you for the API secret from tuya (same steps as above but copy and paste in the Access Secret/Client Secret)
  6. It’ll ask you for a ‘virtual ID’ of a device currently registered in the app (open the app on your phone, tap on a device, tap on the pencil in the top right, tap device information, copy the virtual ID and paste it in to terminal)
  7. That will give you the name, id (also called device_id), and key (also called local_key) of all your devices which you then use when setting up local-tuya devices in HA (I prefer the Integrations GUI but you could use the configuration.yaml as they outline in Step 4 where you got stuck.

Getting stuck here
Untitled

Oh you’re on Windows

try without sudo
just:
npm i @tuyapi/cli -g

Thanks! I’m now at the part where it’s asking for the API key. Hopefully no more issues going forward.