tuya / tuya-home-assistant

Home Assistant integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, maintained by the Home Assistant Community and Tuya Developer Team.
MIT License
875 stars 206 forks source link

Invalid authentication - skill id failed #619

Open ScndWave opened 2 years ago

ScndWave commented 2 years ago

Authetication is not work.

tried all founded way, new iot project, different country codes etc.

always end up ”invalid authentication” and in log file has: This error originated from a custom integration.

Logger: custom_components.tuya_v2.config_flow Source: custom_components/tuya_v2/config_flow.py:139 Integration: Tuya v2 (documentation) First occurred: 7:03:27 PM (7 occurrences) Last logged: 9:56:03 PM

Login failed: {'code': 2406, 'msg': 'skill id invalid', 'success': False, 't': 1634838065447}

Devices is available on cloud project. Using latest hassio and fresh tuya v2

PshemoSK commented 2 years ago

I have exactly this same issue. First integration (newy sreated Tuya project, newer integrated etc.). Tried few time last days with different settings.

Log:

Logger: custom_components.tuya_v2.config_flow Source: custom_components/tuya_v2/config_flow.py:139 Integration: Tuya v2 (documentation) First occurred: 2:38:26 PM (1 occurrences) Last logged: 2:38:26 PM

Login failed: {'code': 2406, 'msg': 'skill id invalid', 'success': False, 't': 1634906306752}

System info:

Country code: 48

Version | core-2021.10.6 Installation Type | Home Assistant OS Development | false Supervisor | true Docker | true User | root Virtual Environment | false Python Version | 3.9.7 Operating System Family | Linux Operating System Version | 5.10.17-v8 CPU Architecture | aarch64

werdnum commented 2 years ago

To be clear, this error is documented in the documentation, but the documentation states that it should only happen with Tuya Cloud projects created before May 2021 - it's happening for me with a completely freshly created project.

Some Googling (e.g. here) indicates that this may be restricted to users who've selected certain countries (e.g., Australia) on their Tuya account.

clienthax commented 2 years ago

To be clear, this error is documented in the documentation, but the documentation states that it should only happen with Tuya Cloud projects created before May 2021 - it's happening for me with a completely freshly created project.

Some Googling (e.g. here) indicates that this may be restricted to users who've selected certain countries (e.g., Australia) on their Tuya account.

I ran into it when having only one DC selected, just select them all and see if it resolves

werdnum commented 2 years ago

That did not help.

On Sun, Oct 24, 2021 at 12:20 PM clienthax @.***> wrote:

To be clear, this error is documented in the documentation, but the documentation states that it should only happen with Tuya Cloud projects created before May 2021 - it's happening for me with a completely freshly created project.

Some Googling (e.g. here https://www.reddit.com/r/homeassistant/comments/qdd3sx/tuya_integration_login_error_2406_skill_id_invalid/) indicates that this may be restricted to users who've selected certain countries (e.g., Australia) on their Tuya account.

I ran into it when having only one DC selected, just select them all and see if it resolves

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tuya/tuya-home-assistant/issues/619#issuecomment-950242325, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACCFXUK6YQIXRMRM54VJVLUINNOLANCNFSM5GO3QVVQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- — Andrew Garrett

ScndWave commented 2 years ago

Same. Didn’t help even all DC’s selected. Or that cloud project was freshly made few days ago. What is confirmed combination of countrys to work?

i have now: Tuya smart app user: Finland Iot.tuya.com cloud project data center: Central Europe Iot.tuya user country: finland

hassio integration country code : 358 (Finland country code)

taxx commented 2 years ago

Having the same problems for Sweden (46).

Managed to get it to work by editing this file: config\custom_components\tuya_v2\config_flow.py

Replaced the value of TUYA_ENDPOINT_OTHER to the Europe endpoint found in fromconst.py. (Or here below)

TUYA_ENDPOINTS = {
    "America": "https://openapi.tuyaus.com",
    "China": "https://openapi.tuyacn.com",
    "Europe": "https://openapi.tuyaeu.com",
    "India": "https://openapi.tuyain.com",
    "Eastern America": "https://openapi-ueaz.tuyaus.com",
    "Western Europe": "https://openapi-weaz.tuyaeu.com",
}

Changes in config_flow.py to use the "Europe" endpoint.

TUYA_ENDPOINT_OTHER = "https://openapi.tuyaeu.com"
#TUYA_ENDPOINT_OTHER = "https://openapi.tuyaus.com" #old

There are some logic to switch endpoint based on China or not. Guessing that works well for US or China but not for EU? But I am no Python expert.

            if user_input[CONF_COUNTRY_CODE] in COUNTRY_CODE_CHINA:
                api.endpoint = TUYA_ENDPOINT_BASE
            else:
                api.endpoint = TUYA_ENDPOINT_OTHER

Anyway, hope it help someone! Now I am off to automate some more awesome stuff :-)

werdnum commented 2 years ago

Thanks! I’ll try to do this, but I am using the ordinary integration, not the V2, so I’ll have to figure out the equivalent edit.

On Sun, 24 Oct 2021 at 21:42, taxx @.***> wrote:

Having the same problems for Sweden (46).

Managed to get it to work by editing this file: config\custom_components\tuya_v2\config_flow.py

Replaced the value of TUYA_ENDPOINT_OTHER to the Europe endpoint found in fromconst.py. (Or here below)

TUYA_ENDPOINTS = { "America": "https://openapi.tuyaus.com", "China": "https://openapi.tuyacn.com", "Europe": "https://openapi.tuyaeu.com", "India": "https://openapi.tuyain.com", "Eastern America": "https://openapi-ueaz.tuyaus.com", "Western Europe": "https://openapi-weaz.tuyaeu.com", }

Changes in config_flow.py to use the "Europe" endpoint.

TUYA_ENDPOINT_OTHER = "https://openapi.tuyaeu.com"#TUYA_ENDPOINT_OTHER = "https://openapi.tuyaus.com" #old

There are some logic to switch endpoint based on China or not. Guessing that works well for US or China but not for EU? But I am no Python expert.

        if user_input[CONF_COUNTRY_CODE] in COUNTRY_CODE_CHINA:
            api.endpoint = TUYA_ENDPOINT_BASE
        else:
            api.endpoint = TUYA_ENDPOINT_OTHER

Anyway, hope it help someone! Now I am off to automate some more awesome stuff :-)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tuya/tuya-home-assistant/issues/619#issuecomment-950300757, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACCFXSF2V6HPR34FB3DQ5DUIPPJBANCNFSM5GO3QVVQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- — Andrew Garrett

ScndWave commented 2 years ago

Thanks @taxx it works!

taxx commented 2 years ago

I just realized that the code for this integration is now in home assistant! https://www.home-assistant.io/integrations/tuya/

Tested that on another instance of Home Assistant and it worked without any problems or adjustments.

More details here: https://github.com/tuya/tuya-home-assistant/blob/master/README.md#important-note

mazzy89 commented 2 years ago

The reason has been announced here https://github.com/tuya/tuya-home-assistant/issues/613#issuecomment-948646557 and indeed as stated by @taxx is an endpoint issue. maintainers recommend using the new one because this won't be supported despite the new one lacks of features.

srodighiero commented 2 years ago

If it can help, I fixed not only with taxx suggestion, but as well by revoking services and re-subscribe to them for the project on Iot platform.

zlinoliver commented 2 years ago

Hi! This has been fixed in the Home Assistant Core integration version. This fix will become available with Home Assistant Core 2021.11 - 3rd, November.

As we stop maintain it now, please help to create your github issues in the Home Assistant Core repository. And it's still maintained by the Tuya developer team and Home Assistant Team.

baylanger commented 2 years ago

I faced this same 2406 issue and I'm on Eastern Canada/US coast. Please see this comment , might help you figure it out.