mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Use Tuya endpoints values from upstream library (#57537)
This commit is contained in:
parent
c943677675
commit
f82af47f6a
@ -1,6 +1,8 @@
|
||||
"""Constants for the Tuya integration."""
|
||||
from dataclasses import dataclass
|
||||
|
||||
from tuya_iot import TuyaCloudOpenAPIEndpoint
|
||||
|
||||
DOMAIN = "tuya"
|
||||
|
||||
CONF_AUTH_TYPE = "auth_type"
|
||||
@ -31,13 +33,6 @@ TUYA_HA_SIGNAL_UPDATE_ENTITY = "tuya_entry_update"
|
||||
TUYA_SMART_APP = "tuyaSmart"
|
||||
SMARTLIFE_APP = "smartlife"
|
||||
|
||||
ENDPOINT_AMERICA = "https://openapi.tuyaus.com"
|
||||
ENDPOINT_CHINA = "https://openapi.tuyacn.com"
|
||||
ENDPOINT_EASTERN_AMERICA = "https://openapi-ueaz.tuyaus.com"
|
||||
ENDPOINT_EUROPE = "https://openapi.tuyaeu.com"
|
||||
ENDPOINT_INDIA = "https://openapi.tuyain.com"
|
||||
ENDPOINT_WESTERN_EUROPE = "https://openapi-weaz.tuyaeu.com"
|
||||
|
||||
PLATFORMS = ["climate", "fan", "light", "scene", "switch"]
|
||||
|
||||
|
||||
@ -47,7 +42,7 @@ class Country:
|
||||
|
||||
name: str
|
||||
country_code: str
|
||||
endpoint: str = ENDPOINT_AMERICA
|
||||
endpoint: str = TuyaCloudOpenAPIEndpoint.AMERICA
|
||||
|
||||
|
||||
# https://developer.tuya.com/en/docs/iot/oem-app-data-center-distributed?id=Kafi0ku9l07qb#title-4-China%20Data%20Center
|
||||
@ -61,18 +56,18 @@ TUYA_COUNTRIES = [
|
||||
Country("Anguilla", "1-264"),
|
||||
Country("Antarctica", "672"),
|
||||
Country("Antigua and Barbuda", "1-268"),
|
||||
Country("Argentina", "54", ENDPOINT_EUROPE),
|
||||
Country("Argentina", "54", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Armenia", "374"),
|
||||
Country("Aruba", "297"),
|
||||
Country("Australia", "61"),
|
||||
Country("Austria", "43", ENDPOINT_EUROPE),
|
||||
Country("Austria", "43", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Azerbaijan", "994"),
|
||||
Country("Bahamas", "1-242"),
|
||||
Country("Bahrain", "973"),
|
||||
Country("Bangladesh", "880"),
|
||||
Country("Barbados", "1-246"),
|
||||
Country("Belarus", "375"),
|
||||
Country("Belgium", "32", ENDPOINT_EUROPE),
|
||||
Country("Belgium", "32", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Belize", "501"),
|
||||
Country("Benin", "229"),
|
||||
Country("Bermuda", "1-441"),
|
||||
@ -80,7 +75,7 @@ TUYA_COUNTRIES = [
|
||||
Country("Bolivia", "591"),
|
||||
Country("Bosnia and Herzegovina", "387"),
|
||||
Country("Botswana", "267"),
|
||||
Country("Brazil", "55", ENDPOINT_EUROPE),
|
||||
Country("Brazil", "55", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("British Indian Ocean Territory", "246"),
|
||||
Country("British Virgin Islands", "1-284"),
|
||||
Country("Brunei", "673"),
|
||||
@ -89,26 +84,26 @@ TUYA_COUNTRIES = [
|
||||
Country("Burundi", "257"),
|
||||
Country("Cambodia", "855"),
|
||||
Country("Cameroon", "237"),
|
||||
Country("Canada", "1", ENDPOINT_AMERICA),
|
||||
Country("Canada", "1", TuyaCloudOpenAPIEndpoint.AMERICA),
|
||||
Country("Cape Verde", "238"),
|
||||
Country("Cayman Islands", "1-345"),
|
||||
Country("Central African Republic", "236"),
|
||||
Country("Chad", "235"),
|
||||
Country("Chile", "56"),
|
||||
Country("China", "86", ENDPOINT_CHINA),
|
||||
Country("China", "86", TuyaCloudOpenAPIEndpoint.CHINA),
|
||||
Country("Christmas Island", "61"),
|
||||
Country("Cocos Islands", "61"),
|
||||
Country("Colombia", "57"),
|
||||
Country("Comoros", "269"),
|
||||
Country("Cook Islands", "682"),
|
||||
Country("Costa Rica", "506"),
|
||||
Country("Croatia", "385", ENDPOINT_EUROPE),
|
||||
Country("Croatia", "385", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Cuba", "53"),
|
||||
Country("Curacao", "599"),
|
||||
Country("Cyprus", "357", ENDPOINT_EUROPE),
|
||||
Country("Czech Republic", "420", ENDPOINT_EUROPE),
|
||||
Country("Cyprus", "357", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Czech Republic", "420", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Democratic Republic of the Congo", "243"),
|
||||
Country("Denmark", "45", ENDPOINT_EUROPE),
|
||||
Country("Denmark", "45", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Djibouti", "253"),
|
||||
Country("Dominica", "1-767"),
|
||||
Country("Dominican Republic", "1-809"),
|
||||
@ -118,21 +113,21 @@ TUYA_COUNTRIES = [
|
||||
Country("El Salvador", "503"),
|
||||
Country("Equatorial Guinea", "240"),
|
||||
Country("Eritrea", "291"),
|
||||
Country("Estonia", "372", ENDPOINT_EUROPE),
|
||||
Country("Estonia", "372", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Ethiopia", "251"),
|
||||
Country("Falkland Islands", "500"),
|
||||
Country("Faroe Islands", "298"),
|
||||
Country("Fiji", "679"),
|
||||
Country("Finland", "358", ENDPOINT_EUROPE),
|
||||
Country("France", "33", ENDPOINT_EUROPE),
|
||||
Country("Finland", "358", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("France", "33", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("French Polynesia", "689"),
|
||||
Country("Gabon", "241"),
|
||||
Country("Gambia", "220"),
|
||||
Country("Georgia", "995"),
|
||||
Country("Germany", "49", ENDPOINT_EUROPE),
|
||||
Country("Germany", "49", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Ghana", "233"),
|
||||
Country("Gibraltar", "350"),
|
||||
Country("Greece", "30", ENDPOINT_EUROPE),
|
||||
Country("Greece", "30", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Greenland", "299"),
|
||||
Country("Grenada", "1-473"),
|
||||
Country("Guam", "1-671"),
|
||||
@ -144,19 +139,19 @@ TUYA_COUNTRIES = [
|
||||
Country("Haiti", "509"),
|
||||
Country("Honduras", "504"),
|
||||
Country("Hong Kong", "852"),
|
||||
Country("Hungary", "36", ENDPOINT_EUROPE),
|
||||
Country("Iceland", "354", ENDPOINT_EUROPE),
|
||||
Country("India", "91", ENDPOINT_INDIA),
|
||||
Country("Hungary", "36", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Iceland", "354", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("India", "91", TuyaCloudOpenAPIEndpoint.INDIA),
|
||||
Country("Indonesia", "62"),
|
||||
Country("Iran", "98"),
|
||||
Country("Iraq", "964"),
|
||||
Country("Ireland", "353", ENDPOINT_EUROPE),
|
||||
Country("Ireland", "353", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Isle of Man", "44-1624"),
|
||||
Country("Israel", "972"),
|
||||
Country("Italy", "39", ENDPOINT_EUROPE),
|
||||
Country("Italy", "39", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Ivory Coast", "225"),
|
||||
Country("Jamaica", "1-876"),
|
||||
Country("Japan", "81", ENDPOINT_EUROPE),
|
||||
Country("Japan", "81", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Jersey", "44-1534"),
|
||||
Country("Jordan", "962"),
|
||||
Country("Kazakhstan", "7"),
|
||||
@ -166,14 +161,14 @@ TUYA_COUNTRIES = [
|
||||
Country("Kuwait", "965"),
|
||||
Country("Kyrgyzstan", "996"),
|
||||
Country("Laos", "856"),
|
||||
Country("Latvia", "371", ENDPOINT_EUROPE),
|
||||
Country("Latvia", "371", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Lebanon", "961"),
|
||||
Country("Lesotho", "266"),
|
||||
Country("Liberia", "231"),
|
||||
Country("Libya", "218"),
|
||||
Country("Liechtenstein", "423", ENDPOINT_EUROPE),
|
||||
Country("Lithuania", "370", ENDPOINT_EUROPE),
|
||||
Country("Luxembourg", "352", ENDPOINT_EUROPE),
|
||||
Country("Liechtenstein", "423", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Lithuania", "370", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Luxembourg", "352", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Macau", "853"),
|
||||
Country("Macedonia", "389"),
|
||||
Country("Madagascar", "261"),
|
||||
@ -181,7 +176,7 @@ TUYA_COUNTRIES = [
|
||||
Country("Malaysia", "60"),
|
||||
Country("Maldives", "960"),
|
||||
Country("Mali", "223"),
|
||||
Country("Malta", "356", ENDPOINT_EUROPE),
|
||||
Country("Malta", "356", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Marshall Islands", "692"),
|
||||
Country("Mauritania", "222"),
|
||||
Country("Mauritius", "230"),
|
||||
@ -199,7 +194,7 @@ TUYA_COUNTRIES = [
|
||||
Country("Namibia", "264"),
|
||||
Country("Nauru", "674"),
|
||||
Country("Nepal", "977"),
|
||||
Country("Netherlands", "31", ENDPOINT_EUROPE),
|
||||
Country("Netherlands", "31", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Netherlands Antilles", "599"),
|
||||
Country("New Caledonia", "687"),
|
||||
Country("New Zealand", "64"),
|
||||
@ -220,14 +215,14 @@ TUYA_COUNTRIES = [
|
||||
Country("Peru", "51"),
|
||||
Country("Philippines", "63"),
|
||||
Country("Pitcairn", "64"),
|
||||
Country("Poland", "48", ENDPOINT_EUROPE),
|
||||
Country("Portugal", "351", ENDPOINT_EUROPE),
|
||||
Country("Poland", "48", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Portugal", "351", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Puerto Rico", "1-787, 1-939"),
|
||||
Country("Qatar", "974"),
|
||||
Country("Republic of the Congo", "242"),
|
||||
Country("Reunion", "262"),
|
||||
Country("Romania", "40", ENDPOINT_EUROPE),
|
||||
Country("Russia", "7", ENDPOINT_EUROPE),
|
||||
Country("Romania", "40", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Russia", "7", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Rwanda", "250"),
|
||||
Country("Saint Barthelemy", "590"),
|
||||
Country("Saint Helena", "290"),
|
||||
@ -246,20 +241,20 @@ TUYA_COUNTRIES = [
|
||||
Country("Sierra Leone", "232"),
|
||||
Country("Singapore", "65"),
|
||||
Country("Sint Maarten", "1-721"),
|
||||
Country("Slovakia", "421", ENDPOINT_EUROPE),
|
||||
Country("Slovenia", "386", ENDPOINT_EUROPE),
|
||||
Country("Slovakia", "421", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Slovenia", "386", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Solomon Islands", "677"),
|
||||
Country("Somalia", "252"),
|
||||
Country("South Africa", "27"),
|
||||
Country("South Korea", "82"),
|
||||
Country("South Sudan", "211"),
|
||||
Country("Spain", "34", ENDPOINT_EUROPE),
|
||||
Country("Spain", "34", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Sri Lanka", "94"),
|
||||
Country("Sudan", "249"),
|
||||
Country("Suriname", "597"),
|
||||
Country("Svalbard and Jan Mayen", "47", ENDPOINT_EUROPE),
|
||||
Country("Svalbard and Jan Mayen", "47", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Swaziland", "268"),
|
||||
Country("Sweden", "46", ENDPOINT_EUROPE),
|
||||
Country("Sweden", "46", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("Switzerland", "41"),
|
||||
Country("Syria", "963"),
|
||||
Country("Taiwan", "886"),
|
||||
@ -279,8 +274,8 @@ TUYA_COUNTRIES = [
|
||||
Country("Uganda", "256"),
|
||||
Country("Ukraine", "380"),
|
||||
Country("United Arab Emirates", "971"),
|
||||
Country("United Kingdom", "44", ENDPOINT_EUROPE),
|
||||
Country("United States", "1", ENDPOINT_AMERICA),
|
||||
Country("United Kingdom", "44", TuyaCloudOpenAPIEndpoint.EUROPE),
|
||||
Country("United States", "1", TuyaCloudOpenAPIEndpoint.AMERICA),
|
||||
Country("Uruguay", "598"),
|
||||
Country("Uzbekistan", "998"),
|
||||
Country("Vanuatu", "678"),
|
||||
|
@ -5,6 +5,7 @@ from typing import Any
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
from tuya_iot import TuyaCloudOpenAPIEndpoint
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.components.tuya.const import (
|
||||
@ -17,7 +18,6 @@ from homeassistant.components.tuya.const import (
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
DOMAIN,
|
||||
ENDPOINT_INDIA,
|
||||
SMARTLIFE_APP,
|
||||
TUYA_COUNTRIES,
|
||||
TUYA_SMART_APP,
|
||||
@ -32,7 +32,7 @@ MOCK_ACCESS_ID = "myAccessId"
|
||||
MOCK_ACCESS_SECRET = "myAccessSecret"
|
||||
MOCK_USERNAME = "myUsername"
|
||||
MOCK_PASSWORD = "myPassword"
|
||||
MOCK_ENDPOINT = ENDPOINT_INDIA
|
||||
MOCK_ENDPOINT = TuyaCloudOpenAPIEndpoint.INDIA
|
||||
|
||||
TUYA_INPUT_DATA = {
|
||||
CONF_COUNTRY_CODE: MOCK_COUNTRY,
|
||||
|
Loading…
x
Reference in New Issue
Block a user