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.16k stars 29.83k forks source link

Tuya Integration failing with Invalid authentication #38724

Closed stonesbg closed 3 years ago

stonesbg commented 4 years ago

The problem

I am having an issue getting the Tuya integration to work. I can’t seem to get the integration to accept my credentials.

I enter in my username, password, country code (353 - Ireland) and select tuya as app option and I just get “Invalid authentication”. I can’t see anything in the logs that might hint at the cause. I am successfully able to log into the Tuya portal as well as the phone app.

Additionally i have changed my password to be easier as that was one of the suggestions on the forums https://community.home-assistant.io/t/tuya-integration-setup-failure-invalid-authentication/216592

Environment

Problem-relevant configuration.yaml

Not using settings from configuration.yaml just the UI portal for configuration

Traceback/Error logs

Not seeing any failure in logs even when switch to debug

Additional information

probot-home-assistant[bot] commented 4 years ago

Hey there @ollo69, mind taking a look at this issue as its been labeled with an integration (tuya) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

ollo69 commented 4 years ago

Are you sure that you create your Tuya account using the mobile app "Tuya" and that credential used in HA match 100% credential used in the app?

stonesbg commented 4 years ago

I am not 100% sure i created the account on mobile but i have uninstalled it and reset it up using the credentials i have in 1Password. Additionally i created a SmartLife account from mobile with different password and it gives the same result "Invalid authentication". The only thing that i can think of that might be causing and issue is that the country code for Ireland is 353 didn't know if 3 integer country codes might have this issue.

Is there any logging that I could turn on that might point me to a cause?

loons1k commented 4 years ago

@ollo69 I have the same problem. No manipulation helps. Tell me, does the integration with tuya work for you on 113.3? My country code is 7

ollo69 commented 4 years ago

At this moment I'm using tuya_custom, but authentication phase is the same and for me work properly. What is important is that the country_code match with the country that you use in Tuya or SmartLive app registration. Did you check HA log for error details?

loons1k commented 4 years ago

@ollo69 I have now installed tuya custom on my ha 113.3 and restarted it (installed in synology docker). In tuyasmart app, logged in with my account, successful attempt. In the application settings, I once again checked my country (Russia), which means the code 7. Then I went to the HA settings, chose the integration, found tuya in the search, entered the login (mail in gmail) and password from the application, country code 7, application tuyasmart. I receive an invalid authorization. Trying tuya_costum, the same error. I can give my login and password for you to check, if I change the password successfully later.

ollo69 commented 4 years ago

Ok, I can test for you, send me your login credential to aolivero@gmail.com. In many case docker can cause issues, can you try in a non docker installation?

1000mmr commented 4 years ago

I have same problem...113.3 on docker installation , country_code 39 , app SmartLife....

loons1k commented 4 years ago

@ollo69 i sent you data

loons1k commented 4 years ago

how is progress? 3 wifi relays based on realtek to gather dust without work) if it was esp, I would have asked for it in tasmoto long ago

ollo69 commented 4 years ago

Need some time to add log and check error cause. What I can confirm is that login fail also here using your credential...

loons1k commented 4 years ago

maybe the solution is to use a working country code? what is yours?

ollo69 commented 4 years ago

You can try, my is 39

loons1k commented 4 years ago

works with country code 39! verified

ollo69 commented 4 years ago

Good news, now change your password...

metalloid14 commented 4 years ago

Hi all. I've created a Tuya account last week using the IOS app and configured a brand new power strip. In the app, all is working, I can operate all 3 power sockets and the USB ports. Then I tried to add the Tuya integration on HA. Didn't work, always an authentication problem, but I was sure the info was right. So I headed to tuya.com on my browser. Tried to authenticate with my account, didn't work... Hmm. So, created a new one but using the exact same credentials I created on the app the day before. The account was then created, but I found out this is a different one than of the app account, this one is for developers (iot.tuya.com), to create and produce new products using Tuya. But, funny enough, I tried again to install the integration on HA and, using the exact same credentials as a few minutes before, voilá, it worked... Well, not really. because on the integration no entities are showing, but in the app I'm still capable of managing my power sockets... Any thoughts? What did I do wrong? BTW, my country code is 351 (Portugal).

usma0118 commented 4 years ago

I am facing similar issue with Smart life account.

draktheas commented 4 years ago

Same here, neither smartlife nor tuya accounts work. Both work in mobile apps with same login information. Nothing in the logs to indicate an issue. United State Country code (1). More than happy to share my credentials with whomever is looking at the issue just as someone did last time this stopped working.

Update: I wasn't using a gmail account, but was using a yahoo.com email account. I created an account on a free email service and registered with the Smart Life app with that email, used the same email in the Tuya integration and it started working. So yahoo accounts may not work either.

stonesbg commented 4 years ago

FYI i did set up a brand new account (non Gmail) and things work so whatever a Gmail account does differently to cause the issue. Just in case you happened to use a gmail account

zyc commented 3 years ago

You must try setup a mobile phone number first and after use this as the username.

To setup that go to: Me / More Services / Mobile Notification (or SMS notification) on Smart Life App or Tuya App.

dboczek commented 3 years ago

You must try setup a mobile phone number first and after use this as the username.

To setup that go to: Me / More Services / Mobile Notification (or SMS notification) on Smart Life App or Tuya App. I don't even see even such option...

I think I know the workaround for the issue. I also have an account on gmail. Usually when I use it it contains dots before @ i.e. xxx.yyy.zzz@gmail.com. You can create an account like that in the Tuya/Smart Life app but in the Home Assistant integration login with such email fails.

As gmail will deliver e-mails with or without dots to the same account I've created new account on Tuya app without dots like xxxyyyzzz@gmail.com. And I was able to successfully authenticate in Home Assistant Tuya integration.

monarch0111 commented 3 years ago

You must try setup a mobile phone number first and after use this as the username. To setup that go to: Me / More Services / Mobile Notification (or SMS notification) on Smart Life App or Tuya App. I don't even see even such option...

I think I know the workaround for the issue. I also have an account on gmail. Usually when I use it it contains dots before @ i.e. xxx.yyy.zzz@gmail.com. You can create an account like that in the Tuya/Smart Life app but in the Home Assistant integration login with such email fails.

As gmail will deliver e-mails with or without dots to the same account I've created new account on Tuya app without dots like xxxyyyzzz@gmail.com. And I was able to successfully authenticate in Home Assistant Tuya integration.

Thanks! The issue is correctly with "dots" in email. Removing it works fine.

tomjmul commented 3 years ago

I don't have dots in my email and it doesn't work

hakusaro commented 3 years ago

You must try setup a mobile phone number first and after use this as the username.

This is true if you create an account using Sign in with Apple too. Just putting it here so that people can find it on Google.

broyuken commented 3 years ago

Tried with my yahoo mail and with my phone number and neither worked.

marioingemann commented 3 years ago

Ok so it took me quite some time to figure this out, here's what solved it for me.

In Sweden where I am the app Nedis SmartLife (by NEDIS) is promoted as the app to use. By coincidence I found that there is another app called Smart Life (by Tuya Inc.) which is the app you have to register and use for the integration in Home Assistant to work.

image

Steps I did to resolve my issue

  1. Downloaded Smart Life by Tuya Inc. from Google Play Store
  2. Registered new account using my email (gmail in my case) (I did not login with my google account SSO)
  3. Reset my light and connected it to the app
  4. Added the Tuya integration through the HA GUI, entered my email as username and password I set. (including special characters). Set my country code (46) and chose "Smart Life" as platform.

Worked right away.

So my theory is that "Nedis SmartLife" is not the same as "Smart Life" referred to in the Home Assistant Tuya integration setup.

I hope this can help others like myself who searched and searched for a solution. If others can confirm this is correct then the documentation should be updated to help new users.

Mamabox22 commented 3 years ago

Hello, have the same Problem using a fresh install of HA 0.118.5. Nothing is done yet.

Have an Smart Life account like misei[...]97@gmail.com With an simple password.

Used the integration with tuya. Got my Country code (mine is 49 - Germany) Getting the same error messages, hope someone will help me out :)

Edit1: After add sms notification in SmartLife app i can use my phone number as username. In smartlife, it show my username like this : 49-01XXXXXXXX. In HA, i use 01XXXXXXXX and 49 as country code and it still doesnt work..

Edit2: It was possible in the mobile App. Im not asking why and how, it just works.

Siddharha commented 3 years ago

It must be due to the network. turn off VPN and firewall. and try to log in from the home assistant mobile app for Tuya Smart Life. the issue will be fixed.

bentasker commented 3 years ago

I had the same issue - Invalid authentication.

After resetting password (to double check), same issue.

But, when I manually put the config into configuration.yaml rather than adding via integrations/GUI, it worked fine and my devices are showing up. Country code in my case is 44

Course, at startup I now get a notification that putting it into configuration.yaml is deprecated...

spencerbutler commented 3 years ago

I had the same issue as everyone else here, "invalid authentication". I tried all the same methods and tricks as everyone else. I was able to resolve my issue by registering with a gmail (forwarded) account.

Initial Attempt:

Debug

The account name I found when I registered with oath was gg-<22 digits>. I tried this in my configuration.yaml to no avail.

Solution

I also de-linked tuya from my google home beforehand, for good measure. At least this journey found tuya-convert

cheers and good luck!

baqpl commented 3 years ago

I'm copying the post I posted on Home Assistant forum, I did not get any response there.

After installing HA from image on RPi3 I was pleasantly surprised that Tuya integration was working. Then I wanted to add my IP Camera and it turned out I didn’t have an option of installing add-ons to edit YAML files. I took the memory card, checked files on my PC, the files were not there. When I got my SD card back in to RPi3 and started the system, suddenly I could install add-ons and edit yaml. I managed to add my Dahua NVR feeds in, but then I discovered that all my Tuya devices and weather forecast stopped working. The message I get is: Aborted Failed to connect

I also tried to add Tuya via YAML, no success:

tuya: username: xxxxx password: xxxxxx country_code: 48 platform: smart_life

Any idea why the integration stopped working? Did it have anything to do with me enabling AddOns?

I also tried to change my Tuya email to non-gmail account (my personal domain), no luck here.

I also tried to set up a FRESH Tuya account and moved some devices there, still can't connect.

========================== PROBLEM SOLVED

The issue was with my Home Assistant not recognising HOSTS, I have updated DNS server address and it fixed Tuya and Garmin connectivity !

TheVodNet commented 3 years ago

The issue was with my Home Assistant not recognising HOSTS, I have updated DNS server address and it fixed Tuya and Garmin connectivity !

How did you change the DNS Address and what did you change it to?

jasimmk commented 3 years ago

Something I have checked on code base and figured out that the integration doesn’t use the correct region url based on the country.

If you are desperately trying to connect your devices and you don’t have time to wait for the patch, Delete existing account in another country, create an account in country "United States"

I have created a bug/feature at home assistant. https://github.com/home-assistant/core/issues/44922

animaster84 commented 3 years ago

@jasimmk same problem here with country "Italy" - country_code: 39 on Tuya app.

piffio commented 3 years ago

Hello, just to confirm that I have had the same issue with Spain / 34 and that creating a new account in the US region worked as a workaround

benavern commented 3 years ago

Hi! I can't connect my account from france (33) either. Will a fix be provided soon ? I don't want to create a new accound as everything is already completely configured and shared with other persons in my place ... :(

ItchyCalf commented 3 years ago

@ollo69 I'm having the exact same issue. Phone number isn't an option as it's not showing up in Smart Life, tried making a new, non-gmail account, doesn't work, new account with the app Tuya Smart didn't work, nothing here works.

tsrubar commented 3 years ago

Same problem, neither email or telephone number work as username. Country code 421. Login with email in android TuyaSmart app and tuya website work well. Edit: transfer to Smart Life app and creating account manually by my gmail address, not SSO worked.

ItchyCalf commented 3 years ago

Same problem, neither email or telephone number work as username. Country code 421. Login with email in android TuyaSmart app and tuya website work well. Edit: transfer to Smart Life app and creating account manually by my gmail address, not SSO worked.

Hello! I wasn't able to diagnose the issue but I suspected it was a network issue with my setup because I was getting a multicast error in my HA that I had never gotten before. I just switched the network that my HASSIO VM was connected to (though I have 3 distinct networks in my apartments, which I understand probably isn't common). Maybe try switching from the 5ghz to the 2.4ghz or vice versa?

bkirvas commented 3 years ago

Folks, I was fighting with the login issue for 3 days, and one of the comments has finally really helped - just try using an email WITHOUT dots. So, whoever recommended it - THANK YOU!

(e.g. first.last@gmail.com - doesn't work, firstlast@gmail.com works) And yes, you'll need another email, not just removing the dot from the existing one.

Here you can check the correct code for your country https://www.countrycode.org/

broyuken commented 3 years ago

you need a new tuya account, not a new gmail account. gmail doesn't care how many periods you add to it, the emails will still get to you.

first.last@gmail.com goes to the same inbox as firstlast@gmail.com goes to the same inbox as f.i.r.s.t.l.a.s.t@gmail.com

bkirvas commented 3 years ago

You're absolutely right. I didn't know that dots are ignored in the emails. So, true, all you need is to create a new Tuya account but use even an existing email without "."

MilesAheadToo commented 3 years ago

I've tried everything suggested on this thread:

In all cases I can login to the Tuya website with no problems.

These all fail authentication in the HA Integrations.

HELP!!!

nmajin commented 3 years ago

As a workaround, delete your Tuya account (takes about a week) and then register again WITHOUT your Google account. I confirmed that resolved the issue.

Aygotori commented 3 years ago

As a better workaround without delay;

This resolved the issue for me ;)

TristanK27 commented 3 years ago

In my case having the account linked to my google account was the problem. Create a new account using a google account, didn't work. Create a new account with an email address and password without linking it to anything else and it worked.

crus1313 commented 3 years ago

Fortunately I had no isuues with my GOSUND SP111. I aded my plug via the Smart Life app (by Tuya), then in Hassio, added the integration Tuya, and selected from the prompt which app I used (Smart Life for me, not Tuya), filled din the user/pass country code and BAM was there in Integrations. The problem is that it also have power monitor (current, power, voltage, consumption) that was not found as sensor, and also wifi signal strength.... any ideas how to add those too?

PS. I prefer to use the cloud feature too, as a backup in case HA fails :)

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

SirOrcrist commented 3 years ago

Same problem, tried all, nothing works for me...no integration with tuya and home assistant....thats bad considering how many devices are now under tuya. Sad this is closed without any solution.

Shynel commented 3 years ago

I had same error when intergrating HA with Tuya - what fixed for me was to registering my Tuya smart app in in Tuya IOT . I had changed password and tried again region to no success.

THis worked for me login to Tuya >cloud >Development> on the right side look for tab > Link my App - click on add and scan your barcode using your mobile app. After this is complete try intergation again with HA - the autenciation error was gone and was successfull .