Tuya Official Home Assistant Integration on Github now!

My region in the Tuya Smart App is set to Australia. My devices show up in the “Europe” availability zone in the Tuya IoT platform. I have no linked devices show up under the “America” availability zone.

It would be great if someone could provide some simple clarity on what needs to match and why it is failing. The lack of useful debug on either end makes this frustrating, neither the Home Assistant logs, or the Tuya IoT platform provide debug that lets me see what is being presented and why it is failing.

Sorry, my bad, should select “Europe” instead of “America” as the availability zone in the could project’s setting if your Tuya Smart App account region is set to Australia. Here is the simple clarity:

  • Availability Zone: means the cloud server’s base location, for only Tuya cloud project only provide “China”, “Europe”, “India”, “America”, “Western Europe” and “Eastern America”.

  • Region: means your Tuya Smart / Smart Life app account’s location, normally it’s the country name you select when you create the app account. So the “Region” and “Availability Zone” are different concept, they have corresponding relation, which is not clear now. For example, “Region Australia” correspond to “Europe” Availability zone.

  • “Region” and “Country Code” fields in the Tuya credential of integration setting
    The “Region” should be the same as the “Region” in Tuya Smart/Smart Life app account
    The “County Code” should be your region’s country code. You can check the correct country code using this website: https://countrycode.org

Hi @bitsnbytes , please check my reply of explaining “Availability Zone” and “Region”. for you case, could you help to check if your cloud project is created after May 25th, 2021?

@zlinoliver This does not work. I submitted a support request to Tuya with these details

Hi where is the information about the API available? is it somewhere documented what API’s are necessary?

Would an invalid region or country code cause an “invalid authentication” error?
I’m just wondering if I should spend more time investigating that, or if the problem is elsewhere.

From the “How to Use Tuya Home Assistant Integration” posted above, there is a link to a “Tuya IoT Platform Configuration Guide Using Smart Home PaaS” page which is at

If I understand it correctly, 5 API products are selected/activated by default, but you need to also add the “Device status notification” API. If you didn’t do it during the project creating using the wizard, you can add it manually to your project.

Not that it made any difference to me though, still getting the “Invalid authentication” no matter what.

Hi @bitsnbytes for invalid authentication issue, tuya have updated the FAQ, please check https://developer.tuya.com/en/docs/iot/Home_Assistant_Integration?id=Kamcjcbvk2mu8

Unfortunately it doesn’t help as it doesn’t really provide anything new that I haven’t already tried.

To sum up:

My Tuya IoT project was created after may 25 2021.

I have linked my devices via Smart Life. I can verify this both on the Tuya IoT project page and in my Smart life app.

My Smart life credentials are correct. I even changed the password in the app just to make sure I really use the one that is working in the app.

My region (Sweden) is not listed in the table in the FAQ but I’ve tried all of the regions in the dropdown menu (e.g. Europe, WesternEurope) and Country code 46. In the IoT project I first had only Europe as availability zone but I’ve also added all of the other ones as shown in example in the FAQ.
It makes no difference.

I have copied the Access ID and Access Token from the Tuya IoT project.

I selected Smart Life as the Mobile App.

Still, “Invalid authentication” no matter what.
In HA I then tried to add the old inofficial Tuya integration. I added my Smart Life credentials, selected Smart Life as Mobile app, added 46 as country code. It was successful. So my credentials are obviously correct. I don’t really know what else to try.

1 Like

The updated FAQ doesn’t provide any additional information apart from the Availability Zone matrix which as I mentioned I worked out myself by browsing each zone until I found my devices. It does not change the auth error. Your instructions also still incorrectly advise people that the “Region” setting should match the Tuya Smart application region setting which is NOT correct. You can only select from the fixed Availability Zones. Which again many of us have worked out but none of this fixes the actual problem which cause “Invalid Authentication” :weary:

Yes, the instructions are still pretty confusing, e.g. field name “country code” but the instructions talk about “the country”. When talking about a country in this context you usually mean a country name as a string. The fact that you must manually lookup the country code is not very obvious.

And the word “region” sometimes seems to mean a region/zone while sometimes it means a country (e.g. “select the region” from the app when the app only contains a country name).

And the instructions says “The table header “Registered Region of Tuya Smart/Smart Life” is the one used for the Region field”. Not really, as that table column contains countries, while the “Region” field in HA is a hardcoded list of regions (availability zones).

It’s still unclear to me if this whole country/region confusion actually affects the authentication step though? And I wonder why we even have to enter this info, as we also have to give HA credentials to both the Tuya IoT project and and entire Mobile app. It seems like something it could easily extract by itself if needed.

I also think that it’s very, very bad practice to require you to enter cleartext passwords. The world has been moving away from this bad practice for many years and I wouldn’t expect a new integration in HA, which itself is supposed to care about privacy and security, to accept this behavior.

Anyway, I’ve tried to search all log files for any more details but I’m unable to find any. The message “Invalid authentication” isn’t really helpful. It could at least be able to tell if it’s the Access ID/Secret that is incorrect or of it’s the Mobile app account etc.

Did anyone actually get this to work?

I am located in Luxembourg and integration had worked for me, i quickly removed it because cover support doesn’t exist, which is essential for me.

On the other hand, i see the value here as this will be supported by Tuya itself and having sensor support is very crucial here

I will try again later on to see how things are moving.

Lucky you! All I wanted to do was to turn my air purifier on and off. But I found myself sitting here debugging network traffic and log files, trying to figure out some complicated country/zone/region puzzle that nobody really seems to understand, adding APIs to a shopping basket (??) on the Tuya IoT page, using a trial license that will sooner or later expire and likely cause problems. And using a brand new integration that requires me to give away my cleartext credentials to a 3rd party like it was 2005.

I appreciate the effort and I would have loved to contribute with beta testing but this is way too complex even if I had actually succeeded. I don’t like complex solutions to solve trivial problems.

I think I’ll just buy another $9 zwave or zigbee wallplug and be done in about 30 seconds.

2 Likes

It worked after I made completely new accounts, both for app and developer account. I deleted the old app account, but can’t delete my developer account as there is no option for that. I’ve emailed [email protected] asking for the deletion

Also, under the new accounts I was able to log in, but my portable AC is all kind of wrong. The entity shows the wrong temperature -17.8C, and I can’t send any commands. After Homeassistant restart, it fails to add the entity with this stack trace

File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 383, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 588, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 615, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 368, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 402, in _async_write_ha_state
    state = self._stringify_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 374, in _stringify_state
    state = self.state
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 176, in state
    return self.hvac_mode
  File "/config/custom_components/tuya_v2/climate.py", line 256, in hvac_mode
    return TUYA_HVAC_TO_HA[self.tuya_device.status.get(DPCODE_MODE)]
KeyError: '3'

I’ve found this bug on github AC shows incorrect temperature · Issue #15 · tuya/tuya-home-assistant · GitHub so I guess I’m waiting on this bugfix

Inspired by your success I created a new “Tuya Smart” account and moved a couple of devices to it (de-register/register). Then linked it to my existing Tuya IOT dev account. Was immediately able to complete the integration on Home Assistant, no auth issues. So the issue for me at least is definitely something to do with my TuyaSmart account. @zlinoliver FYI would be great if someone could work this out and fix or at the very least advise others.

I had some teething issues with this too but have it working now.
I had to create a new account in the Tuya app and Tuya dev account after I stuffed up initial config and selections. I’m in Australia, I used Western Europe on sign up because we aren’t listed and after config my devices were under Europe.
When creating the project select smart home PasS as development method, add Europe, America and China.
In the next window ‘configuration wizzard’ be sure to add device status notification API to the list of selected API products.
Here is the instructions that got this to work for me - https://youtu.be/Amc_fmYMQEo

installed the tuya v1.3 at the home assistant beta 7 but i got:
Invalid authentication

in the logging:
2021-06-30 17:39:33 INFO (SyncWorker_3) [custom_components.tuya_v2.config_flow] TuyaConfigFlow._try_login finish, response:, {‘code’: 2406, ‘msg’: ‘skill id invalid’, ‘success’: False, ‘t’: 1625074773050}

what did i missed? I can’t figure it out.
I use europe. and as country code 31 for the netherlands.

Some have recreated the dev project, some have recreated their app account, some just changed the app password. Roll the dice.

Frustrating. I recreated the dev project and that didn’t work. I decided to delete my smartlife account and iot.tuya account and start fresh and it still doesn’t work. I can see my devices in the device list and because I recreated my account, the account is active after May 25th. Not sure what else to do at this point.