Skip to content

Commit

Permalink
show the full name of region instead of code
Browse files Browse the repository at this point in the history
  • Loading branch information
xZetsubou committed Jun 7, 2024
1 parent 182de71 commit d95ae5e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 2 additions & 3 deletions custom_components/localtuya/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from homeassistant.core import callback

from .coordinator import pytuya, TuyaCloudApi
from .core.cloud_api import TUYA_ENDPOINTS
from .const import (
ATTR_UPDATED_AT,
CONF_ADD_DEVICE,
Expand Down Expand Up @@ -128,9 +129,7 @@ def _col_to_select(

CLOUD_CONFIGURE_SCHEMA = vol.Schema(
{
vol.Required(CONF_REGION, default="eu"): _col_to_select(
["eu", "we", "us", "ea", "cn", "in"]
),
vol.Required(CONF_REGION, default="eu"): _col_to_select(TUYA_ENDPOINTS),
vol.Optional(CONF_CLIENT_ID): cv.string,
vol.Optional(CONF_CLIENT_SECRET): cv.string,
vol.Optional(CONF_USER_ID): cv.string,
Expand Down
14 changes: 12 additions & 2 deletions custom_components/localtuya/core/cloud_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@

DEVICES_UPDATE_INTERVAL = 300

TUYA_ENDPOINTS = {
# Regions code
"Central Europe Data Center": "eu",
"China Data Center": "cn",
"Eastern America Data Center": "ea",
"India Data Center": "in",
"Western America Data Center": "us",
"Western Europe Data Center": "we",
}


# Signature algorithm.
def calc_sign(msg, key):
Expand Down Expand Up @@ -45,10 +55,10 @@ def __init__(self, hass, region_code, client_id, secret, user_id):

if region_code == "ea":
self._base_url = "https://openapi-ueaz.tuyaus.com"
elif region_code == "we":
elif region_code == "we":
self._base_url = "https://openapi-weaz.tuyaeu.com"
else:
self._base_url = f"https://openapi.tuya{region_code}.com"
self._base_url = f"https://openapi.tuya{region_code}.com"

self.device_list = {}
self.cached_device_list = {}
Expand Down

0 comments on commit d95ae5e

Please sign in to comment.