home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.9k stars 30.12k forks source link

Tuya requires regular revalidation after 2024.2.1 update #110713

Closed rleatherb closed 3 months ago

rleatherb commented 7 months ago

The problem

After installing version 2024.2.1 of Home Assistant, where the Tuya account setup changed, I successfully validated my account via SmartLife and all was fine. However, on two separate occasions since then, Home Assistant has disconnected from Tuya. There was no apparent warning, but Tuya devices just didn't work from Home Assistant. On restarting Home Assistant (but not before), on each occasion there was a system message that I needed to revalidate my account, which I did using the QR code. Once revalidated all Tuya devices worked again.

Revalidating my Tuya account every week is simply unworkable. The QR code method means I cannot do this when out of the office as you need a display for the QR code and your phone to input this into SmartLife. Between the connection failing and revalidation no automations involving Tuya devices work, which is unacceptable. The "old" Tuya authentication method worked without issue prior to the latest release.

Am I the only one finding this?

What version of Home Assistant Core has the issue?

core-2024.2.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Tuya

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 7 months ago

Hey there @tuya, @zlinoliver, @frenck, mind taking a look at this issue as it has been labeled with an integration (tuya) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `tuya` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign tuya` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


tuya documentation tuya source (message by IssueLinks)

rleatherb commented 7 months ago

It happened again today. WhatsApp Image 2024-02-17 at 07 45 14_05e30d1e

Home Assistant appeared to be locked up and I couldn't connect. After restarting it seems that all Tuya devices had stopped responding some time before I needed to restart.

The first time I tried I also got the following error, which persisted until I restarted Home Assistant again, after which I finally managed to reauthenticate successfully. 2024-02-17 07 48 56

HaraldGithub commented 7 months ago

Same here after update from 2024.2.1 to 2024.2.2

But it happened only once after update. After the next restart of HA, there was no new authentication required.

ancjsd commented 7 months ago

This is occurring frequently for me on restarting Home Assistant.

gmhall506 commented 7 months ago

All my Tuya lights say “Entity not available.”

rleatherb commented 7 months ago

All my Tuya lights say “Entity not available.”

If you don't have a "reauthenticate integration" showing under settings, it might appear after restarting Home Assistant. Not a solution, but might get your Tuya integration working again

matthewbarr commented 7 months ago

I just had this happen. I will say.. this is reinforcing my desire to avoid all wifi devices, and I just ordered 2 tuya zigbee smart plugs instead.

syersjr commented 7 months ago

I am also having this problem, Tuya authentication required - I have the Tuya app, my Tuya developers account seems fine. I have spent hours trying to get the Tuya QR code to get accepted by the Tuya app, Tried everything showing QR code on my iPad, changing my DNS servers back to 8.8.8.8 (Google) - I can't get past the Home Assistant Tuya QR code, keep getting the QR code has expired, please refresh and try again. I would like to be able to skip the QR code and enter my Tuya User Code directly into the Home Assistant Tuya integration.

jorenmartijn commented 7 months ago

I have had this happen a few times too on my new HA install on TrueNAS Scale. It's the only integration that has these problems and it's annoying to have to reload the integration (twice) each time to get it to function properly again. Maybe I should figure out how to do a local control instead. But I'd rather the integration just worked properly instead. Hope you guys can figure it out. Thanks. :)

Jmphiphi85 commented 7 months ago

I have similar problem, Yesterday After update

dvinciguerra commented 7 months ago

When I update my Home Assistant, the Tuya integration notify that I need to reconfigure.

Then, I tried to reconfigure, but the QR Code doesn't load properly.

To try solve the problem, I opened browser devtool at network tab and proceed to generate QR Code until the rendering error.

Next, I get the response payload and find by an auth token.

When I found, I copied the token and generate the QR Code using a secure app.

I opened the smart life app and scan QR Code generated.

Now I'm about 2 days with my integration running stable again. =)

gmhall506 commented 7 months ago

A couple of things that stumped me.

1) I have both the Smart Life app and The Tuya app. The auth code is different on each.

2) Also, when the browser shows the QR code, on a the mobile app you need to back up two screens, choose the scan icon from the top right, scan the code and click submit back on home assistant.

On Mon, Feb 19, 2024 at 8:07 PM Daniel Vinciguerra @.***> wrote:

When I update my Home Assistant, the Tuya integration notify that I need to reconfigure.

Then, I tried to reconfigure, but the QR Code doesn't load properly.

To try solve the problem, I opened browser devtool at network tab and proceed to generate QR Code until the rendering error.

Next, I get the response payload and find by an auth token.

When I found, I copied the token and generate the QR Code using a secure app.

I opened the smart life app and scan QR Code generated.

Now I'm about 2 days with my integration running stable again. =)

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/110713#issuecomment-1953297055, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASG7BXVXZKLQCXLPCCICXKDYUPSLFAVCNFSM6AAAAABDLZPIBWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJTGI4TOMBVGU . You are receiving this because you commented.Message ID: @.***>

esotere commented 7 months ago

Any updates on this issue? Been having the same problem since the 2024.2 update, So far the only lasting solution is downgrading the update to 2024.1.~ otherwise one would have to keep reloading the integration or restart HA continuously in order for some automations to work.

I have attempted ALL the steps and/or solutions suggested. Yes, my automations seem to work at first, and yes the states and entities are available but then for some reason they just cease to work. For instance after reloading the integration the motion sensors turn on the lights as expected, however, when the sensor is cleared the lights remain on indefinitely until I manually turn them off or reload the integration or restart my instance.

Any assistance or suggestion will be much appreciated.

Edit** Note: This is neither a configuration nor authentication issue.

AriaRobav commented 7 months ago

I am also having this problem (Tuya authentication required every reboot) also after updating to 2024.2.2 version.

sjc073 commented 7 months ago

This is happening to me too. Every time I update HA I get the following notification. Authentication expired for “username”

Core - 2024.2.5 Supervisor - 2024.02.0 Operating System - 12.0 Frontend - 20240207.1

AlainPeccable commented 7 months ago

Same here since last update, prior to that it was working fine. Core: 2024.2.5 Supervisor: 2024.02.1 Operating System: 12.0 Interface utilisateur: 20240207.1

1) if no immediate action you need to restart again as QR expire and there is no way to regenerate a new one. 2) you need to be using 2 devices as from a mobile phone only you can't reauthenticate.

n00b12345 commented 7 months ago

Facing the same issue sadly.

Mukh-Samum commented 6 months ago

I've been facing the same problem since the last update: each HASS reboot needs the Tuya integration to be reauthenticated via QR.

JDBalogh commented 6 months ago

According to https://github.com/tuya/tuya-smart-life : "This project has now officially been integrated into the Home Assistant official project core repository, corresponding to version 2024.2." AKA: No more Tuya "Authenticate" needed - just use Home Assistant to discover and add these devices.

andreasbuff commented 5 months ago

Same problem here!? Yes, Tuya authentication moved to Home Assistant. I 2 deleted whole Tuya integration and installed and authenticated from within the Home Assistant App. BUT after some days, an error Message is poping up, saying "Authentication has expired 1 Month (or so) ago! Need to reauthenticate Tuya?????
I am running two separate HA Instances with 2 separate Smart Life (Tuya, different users) Integrations. Two HWs (identical configuration), same OS- and HA-Levels, but only 1 (one) is showing this error? The other is working fine.. Please help! Thanks

oopiicaa commented 4 months ago

Happened to me today also - my virtual instance for HA was unresponsive, clogging up my CPU. Had to restart the virtual machine. Never happened before.

Core 2024.5.3 Supervisor 2024.05.1 Operating System 12.3

spanzetta commented 4 months ago

Same issue here.. Running HA OS on RPI PI3A+ Any way to fix it?

spanzetta commented 4 months ago

Solved by "forcing" a submit in HA without reading the QRcode in SmarLife app.. then the QRcode is renewed and the reauthentication on SmartLife app did work..

anderconsu commented 4 months ago

Same here

spanzetta commented 3 months ago

It is now happening quite frequently.. Almost every week.. Why?

Nebneb commented 3 months ago

Same issue here, now happening every day 😢 Here's the log chunk:

2024-06-09 09:23:26.431 ERROR (SyncWorker_0) [tuya_sharing] net work error = network error:(1010) token is expired
2024-06-09 09:23:26.497 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry <my_email_address> for smartlife
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/smartlife/__init__.py", line 69, in async_setup_entry
    await hass.async_add_executor_job(smart_life_manager.report_version, __version__, smart_life_version, sharing_sdk)
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tuya_sharing/manager.py", line 69, in report_version
    self.user_repository.user_version_report(ha_version, integration_version, sdk_version)
  File "/usr/local/lib/python3.12/site-packages/tuya_sharing/user.py", line 46, in user_version_report
    self.api.post("/v1.0/m/life/home-assistant/qrcode/versions", None, {
  File "/usr/local/lib/python3.12/site-packages/tuya_sharing/customerapi.py", line 192, in post
    return self.__request("POST", path, params, body)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tuya_sharing/customerapi.py", line 121, in __request
    raise Exception(f"network error:({ret['code']}) {ret['msg']}")
Exception: network error:(-9999999) sign invalid
ajcorrea commented 3 months ago

Same issue here, now happening every day 😢 Here's the log chunk:

2024-06-09 09:23:26.431 ERROR (SyncWorker_0) [tuya_sharing] net work error = network error:(1010) token is expired
2024-06-09 09:23:26.497 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry <my_email_address> for smartlife
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/smartlife/__init__.py", line 69, in async_setup_entry
    await hass.async_add_executor_job(smart_life_manager.report_version, __version__, smart_life_version, sharing_sdk)
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tuya_sharing/manager.py", line 69, in report_version
    self.user_repository.user_version_report(ha_version, integration_version, sdk_version)
  File "/usr/local/lib/python3.12/site-packages/tuya_sharing/user.py", line 46, in user_version_report
    self.api.post("/v1.0/m/life/home-assistant/qrcode/versions", None, {
  File "/usr/local/lib/python3.12/site-packages/tuya_sharing/customerapi.py", line 192, in post
    return self.__request("POST", path, params, body)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/tuya_sharing/customerapi.py", line 121, in __request
    raise Exception(f"network error:({ret['code']}) {ret['msg']}")
Exception: network error:(-9999999) sign invalid

Same error here;;;

Core 2024.6.1 Supervisor 2024.06.0 Frontend 20240605.0

DareVanReed commented 3 months ago

seeing the same here: "net work error = network error:(1010) token is expired"

ajcorrea commented 3 months ago

Solved it doing this:

DareVanReed commented 3 months ago

I had to delete the entire integration, and re add it. Thankfully all the device names stayed the same 👍

JDBalogh commented 3 months ago

I had to delete the entire integration, and re add it. Thankfully all the device names stayed the same 👍

Same here. Took about 5 minutes for all 89 lights to re-appear in HA. That was over a month ago, and no issues since.

DR-PLANTECHSTEIN commented 3 months ago

Same issue - had to delete and readd, but then they disappeared again a week later.

jd3073 commented 3 months ago

I deleted both Tuya and Smartlife integrations, deleting any CustomComponent folders and restarted HA. Nothing coming up to restore or find those entities. How did others get them to come up with HA ? My only recourse was to restore a backup before deleting everything - which works because it has Smartlife and Tuya add on integrations, which stop working after every restart or HA update.

btreinders commented 3 months ago

Tuya works for me after removing and adding it again but Smartlife fails to load at every reboot still.

TheBigDaddyT commented 3 months ago

Same problem here. I can delete "delete" in the integration and then click add hub and everything works for a while but then stops working.

In the logs I can see this:

net work error = network error:(1010) token is expired

And then:

_Error setting up entry xxxxxx.xxxxx@gmail.com for smartlife Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/smartlife/init.py", line 69, in async_setup_entry await hass.async_add_executor_job(smart_life_manager.report_version, version, smart_life_version, sharing_sdk) File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tuya_sharing/manager.py", line 69, in report_version self.user_repository.user_version_report(ha_version, integration_version, sdk_version) File "/usr/local/lib/python3.12/site-packages/tuya_sharing/user.py", line 46, in user_version_report self.api.post("/v1.0/m/life/home-assistant/qrcode/versions", None, { File "/usr/local/lib/python3.12/site-packages/tuya_sharing/customerapi.py", line 192, in post return self.__request("POST", path, params, body) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/tuya_sharing/customerapi.py", line 121, in _request raise Exception(f"network error:({ret['code']}) {ret['msg']}") Exception: network error:(-9999999) sign invalid

puterboy commented 3 months ago

My Tuya device worked for almost 2 months, then it disconnected and needed the QR code re-validated.

Is this going to be fixed?

kriger1965 commented 3 months ago

Since 5 hours ago aldo happened to me. All my 77 tuya devices are unavailable. I tried to reauthenticate with the scan of the ocr-code, what works fine. But after a view second the persistent notification appears again... And my tuya items are gone again

kriger1965 commented 3 months ago

Do anyone have a solution for this issue?

rleatherb commented 3 months ago

This morning I updated to HA core 2024.6.4 from 2024.5.5 and had the worst reauthentication issues I've seen so far. Reauthentication worked, but literally within seconds it was needed again. After going through this cycle multiple times I reverted to a backup made just before the update and that seems to have stopped the constant reauthentication loop for now.

pkejval commented 3 months ago

I have same issue with Tuya integration. I reauthenticate it with scanning QR code in Tuya app but in few hours I have to reauthenticate it again.

Gothicaria commented 3 months ago

Happening to me with smart life integration on every reboot

malanleroux commented 3 months ago

Yeah I have gotten this Tuya issue 3 times already today... image

As a note, do not restart HA as this will raise the re-auth issue again (Every time)

cmgestevao commented 3 months ago

I already tried several times today and still asks to re-authenticate... After re-autehentication a few seconds later it asks to re-authenticate again...

2024-06-28 17_31_58-Configuração – Home Assistant

gitTerracide commented 3 months ago

Solved by "forcing" a submit in HA without reading the QRcode in SmarLife app.. then the QRcode is renewed and the reauthentication on SmartLife app did work..

Thank you. Smartlife was saying QR expired all the time. Tried clicking submit in HA like you stated. It threw an error but then when I scanned again with smartlife it worked - even with the big red error in Home Assistant. Ok then!

None the less, thank you!

image

GeoffMorg commented 3 months ago

Solved by "forcing" a submit in HA without reading the QRcode in SmarLife app.. then the QRcode is renewed and the reauthentication on SmartLife app did work..

This problem started again for me two days ago and the above fixed it, thanks. In case you aren't clear what is meant, just press Submit on the HA QR code screen and it will fail, and produce a new, working QR code for you to scan. After which it all works well.

I just hope I remember that workaround next time this happens and don't waste another few hours trying to fix something which takes seconds when you know how!!!

Maetzi87 commented 3 months ago

Cant get my integration to work, tried everything mentioned above. Always says, authentification failed a few seconds after I successfully authentificated. Please help!

Edit for those who face the same issue: a normal restart of homeassistant didnt help, but a system-restart helped for now...

Nebneb commented 3 months ago

I confirm it happens every single time I restart HA, after an update or not.

Then I can only delete the Smartlife integration and re-add it, otherwise it doesn't work. When I re-add it, I need to activate it again with user code and QR-code, so I can't do it on a single device (to flash the QR-code).

Keeping the default names in my scenes and script helps, but when I re-add it, I need to reassign every device to a room.

Is there any plan for fixing this issue for good?

vandrivergit commented 3 months ago

same here, always says authentication failed a few seconds after I successfully authenticated. hoping it will get fixed soon.

0000Max0000 commented 3 months ago

Same here since 2 days now. Unable to use the devices in HASS.

0000Max0000 commented 3 months ago

Seems to work now for some minutes ... so I hope it will keep working. What I did:

  1. Removed the Tuya integration.
  2. Restart HASS.
  3. Removed the Smartlife app from my mobile phone.
  4. Restarted my phone.
  5. Installed the Smartlife app again.
  6. Installed the Tuya integration
  7. Authenticate with the QR code.

I'm not going to reboot HASS atm to see if it keeps working.