diff --git a/custom_components/localtuya/cloud_api.py b/custom_components/localtuya/cloud_api.py index a0c512850..1297d1410 100644 --- a/custom_components/localtuya/cloud_api.py +++ b/custom_components/localtuya/cloud_api.py @@ -32,13 +32,20 @@ class TuyaCloudApi: def __init__(self, hass, region_code, client_id, secret, user_id): """Initialize the class.""" self._hass = hass - self._base_url = f"https://openapi.tuya{region_code}.com" self._client_id = client_id self._secret = secret self._user_id = user_id self._access_token = "" self.device_list = {} + if region_code == "ea": + self._base_url = "https://openapi-ueaz.tuyaus.com" + elif region_code == "we": + self._base_url = "https://openapi-weaz.tuyaeu.com" + else: + self._base_url = f"https://openapi.tuya{region_code}.com" + + def generate_payload(self, method, timestamp, url, headers, body=None): """Generate signed payload for requests.""" payload = self._client_id + self._access_token + timestamp diff --git a/custom_components/localtuya/config_flow.py b/custom_components/localtuya/config_flow.py index 5c87e2547..74faa1c4e 100644 --- a/custom_components/localtuya/config_flow.py +++ b/custom_components/localtuya/config_flow.py @@ -75,7 +75,7 @@ CLOUD_SETUP_SCHEMA = vol.Schema( { - vol.Required(CONF_REGION, default="eu"): vol.In(["eu", "us", "cn", "in"]), + vol.Required(CONF_REGION, default="eu"): vol.In(["eu", "we", "us", "ea", "cn", "in"]), vol.Optional(CONF_CLIENT_ID): cv.string, vol.Optional(CONF_CLIENT_SECRET): cv.string, vol.Optional(CONF_USER_ID): cv.string,