-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add more routes for trying to find the tuya region
- Loading branch information
1 parent
cdcad83
commit 2968d72
Showing
3 changed files
with
274 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
COUNTRIES = [ | ||
{"country_code": "AF", "phone_code": "93", "tuya_region": "EU"}, | ||
{"country_code": "AL", "phone_code": "355", "tuya_region": "EU"}, | ||
{"country_code": "DZ", "phone_code": "213", "tuya_region": "EU"}, | ||
{"country_code": "AO", "phone_code": "244", "tuya_region": "EU"}, | ||
{"country_code": "AR", "phone_code": "54", "tuya_region": "AZ"}, | ||
{"country_code": "AM", "phone_code": "374", "tuya_region": "EU"}, | ||
{"country_code": "AU", "phone_code": "61", "tuya_region": "AZ"}, | ||
{"country_code": "AT", "phone_code": "43", "tuya_region": "EU"}, | ||
{"country_code": "AZ", "phone_code": "994", "tuya_region": "EU"}, | ||
{"country_code": "BH", "phone_code": "973", "tuya_region": "EU"}, | ||
{"country_code": "BD", "phone_code": "880", "tuya_region": "EU"}, | ||
{"country_code": "BY", "phone_code": "375", "tuya_region": "EU"}, | ||
{"country_code": "BE", "phone_code": "32", "tuya_region": "EU"}, | ||
{"country_code": "BZ", "phone_code": "501", "tuya_region": "EU"}, | ||
{"country_code": "BJ", "phone_code": "229", "tuya_region": "EU"}, | ||
{"country_code": "BT", "phone_code": "975", "tuya_region": "EU"}, | ||
{"country_code": "BO", "phone_code": "591", "tuya_region": "AZ"}, | ||
{"country_code": "BA", "phone_code": "387", "tuya_region": "EU"}, | ||
{"country_code": "BW", "phone_code": "267", "tuya_region": "EU"}, | ||
{"country_code": "BR", "phone_code": "55", "tuya_region": "AZ"}, | ||
{"country_code": "VG", "phone_code": "1284", "tuya_region": "EU"}, | ||
{"country_code": "BN", "phone_code": "673", "tuya_region": "EU"}, | ||
{"country_code": "BG", "phone_code": "359", "tuya_region": "EU"}, | ||
{"country_code": "BF", "phone_code": "226", "tuya_region": "EU"}, | ||
{"country_code": "BI", "phone_code": "257", "tuya_region": "EU"}, | ||
{"country_code": "KH", "phone_code": "855", "tuya_region": "EU"}, | ||
{"country_code": "CM", "phone_code": "237", "tuya_region": "EU"}, | ||
{"country_code": "US", "phone_code": "1", "tuya_region": "AZ"}, | ||
{"country_code": "CA", "phone_code": "1", "tuya_region": "AZ"}, | ||
{"country_code": "CV", "phone_code": "238", "tuya_region": "EU"}, | ||
{"country_code": "KY", "phone_code": "1345", "tuya_region": "EU"}, | ||
{"country_code": "CF", "phone_code": "236", "tuya_region": "EU"}, | ||
{"country_code": "TD", "phone_code": "235", "tuya_region": "EU"}, | ||
{"country_code": "CL", "phone_code": "56", "tuya_region": "AZ"}, | ||
{"country_code": "CN", "phone_code": "86", "tuya_region": "AY"}, | ||
{"country_code": "CO", "phone_code": "57", "tuya_region": "AZ"}, | ||
{"country_code": "KM", "phone_code": "269", "tuya_region": "EU"}, | ||
{"country_code": "CG", "phone_code": "242", "tuya_region": "EU"}, | ||
{"country_code": "CD", "phone_code": "243", "tuya_region": "EU"}, | ||
{"country_code": "CR", "phone_code": "506", "tuya_region": "EU"}, | ||
{"country_code": "HR", "phone_code": "385", "tuya_region": "EU"}, | ||
{"country_code": "CY", "phone_code": "357", "tuya_region": "EU"}, | ||
{"country_code": "CZ", "phone_code": "420", "tuya_region": "EU"}, | ||
{"country_code": "DK", "phone_code": "45", "tuya_region": "EU"}, | ||
{"country_code": "DJ", "phone_code": "253", "tuya_region": "EU"}, | ||
{"country_code": "DO", "phone_code": "1809", "tuya_region": "EU"}, | ||
{"country_code": "DO", "phone_code": "1829", "tuya_region": "EU"}, | ||
{"country_code": "DO", "phone_code": "1849", "tuya_region": "EU"}, | ||
{"country_code": "EC", "phone_code": "593", "tuya_region": "AZ"}, | ||
{"country_code": "EG", "phone_code": "20", "tuya_region": "EU"}, | ||
{"country_code": "SV", "phone_code": "503", "tuya_region": "EU"}, | ||
{"country_code": "GQ", "phone_code": "240", "tuya_region": "EU"}, | ||
{"country_code": "ER", "phone_code": "291", "tuya_region": "EU"}, | ||
{"country_code": "EE", "phone_code": "372", "tuya_region": "EU"}, | ||
{"country_code": "ET", "phone_code": "251", "tuya_region": "EU"}, | ||
{"country_code": "FJ", "phone_code": "679", "tuya_region": "EU"}, | ||
{"country_code": "FI", "phone_code": "358", "tuya_region": "EU"}, | ||
{"country_code": "FR", "phone_code": "33", "tuya_region": "EU"}, | ||
{"country_code": "GA", "phone_code": "241", "tuya_region": "EU"}, | ||
{"country_code": "GM", "phone_code": "220", "tuya_region": "EU"}, | ||
{"country_code": "GE", "phone_code": "995", "tuya_region": "EU"}, | ||
{"country_code": "DE", "phone_code": "49", "tuya_region": "EU"}, | ||
{"country_code": "GH", "phone_code": "233", "tuya_region": "EU"}, | ||
{"country_code": "GR", "phone_code": "30", "tuya_region": "EU"}, | ||
{"country_code": "GL", "phone_code": "299", "tuya_region": "EU"}, | ||
{"country_code": "GT", "phone_code": "502", "tuya_region": "AZ"}, | ||
{"country_code": "GN", "phone_code": "224", "tuya_region": "EU"}, | ||
{"country_code": "GY", "phone_code": "592", "tuya_region": "EU"}, | ||
{"country_code": "HT", "phone_code": "509", "tuya_region": "EU"}, | ||
{"country_code": "HN", "phone_code": "504", "tuya_region": "EU"}, | ||
{"country_code": "HK", "phone_code": "852", "tuya_region": "AZ"}, | ||
{"country_code": "HU", "phone_code": "36", "tuya_region": "EU"}, | ||
{"country_code": "IS", "phone_code": "354", "tuya_region": "EU"}, | ||
{"country_code": "IN", "phone_code": "91", "tuya_region": "IN"}, | ||
{"country_code": "ID", "phone_code": "62", "tuya_region": "AZ"}, | ||
{"country_code": "IR", "phone_code": "98", "tuya_region": "EU"}, | ||
{"country_code": "IQ", "phone_code": "964", "tuya_region": "EU"}, | ||
{"country_code": "IE", "phone_code": "353", "tuya_region": "EU"}, | ||
{"country_code": "IM", "phone_code": "44", "tuya_region": "EU"}, | ||
{"country_code": "IL", "phone_code": "972", "tuya_region": "EU"}, | ||
{"country_code": "IT", "phone_code": "39", "tuya_region": "AZ"}, | ||
{"country_code": "CI", "phone_code": "225", "tuya_region": "EU"}, | ||
{"country_code": "JM", "phone_code": "1876", "tuya_region": "EU"}, | ||
{"country_code": "JP", "phone_code": "81", "tuya_region": "AZ"}, | ||
{"country_code": "JO", "phone_code": "962", "tuya_region": "EU"}, | ||
{"country_code": "KZ", "phone_code": "7", "tuya_region": "EU"}, | ||
{"country_code": "KE", "phone_code": "254", "tuya_region": "EU"}, | ||
{"country_code": "KR", "phone_code": "82", "tuya_region": "AZ"}, | ||
{"country_code": "KW", "phone_code": "965", "tuya_region": "EU"}, | ||
{"country_code": "KG", "phone_code": "996", "tuya_region": "EU"}, | ||
{"country_code": "LA", "phone_code": "856", "tuya_region": "EU"}, | ||
{"country_code": "LV", "phone_code": "371", "tuya_region": "EU"}, | ||
{"country_code": "LB", "phone_code": "961", "tuya_region": "EU"}, | ||
{"country_code": "LS", "phone_code": "266", "tuya_region": "EU"}, | ||
{"country_code": "LR", "phone_code": "231", "tuya_region": "EU"}, | ||
{"country_code": "LY", "phone_code": "218", "tuya_region": "EU"}, | ||
{"country_code": "LT", "phone_code": "370", "tuya_region": "EU"}, | ||
{"country_code": "LU", "phone_code": "352", "tuya_region": "EU"}, | ||
{"country_code": "MO", "phone_code": "853", "tuya_region": "AZ"}, | ||
{"country_code": "MK", "phone_code": "389", "tuya_region": "EU"}, | ||
{"country_code": "MG", "phone_code": "261", "tuya_region": "EU"}, | ||
{"country_code": "MW", "phone_code": "265", "tuya_region": "EU"}, | ||
{"country_code": "MY", "phone_code": "60", "tuya_region": "AZ"}, | ||
{"country_code": "MV", "phone_code": "960", "tuya_region": "EU"}, | ||
{"country_code": "ML", "phone_code": "223", "tuya_region": "EU"}, | ||
{"country_code": "MT", "phone_code": "356", "tuya_region": "EU"}, | ||
{"country_code": "MR", "phone_code": "222", "tuya_region": "EU"}, | ||
{"country_code": "MU", "phone_code": "230", "tuya_region": "EU"}, | ||
{"country_code": "MX", "phone_code": "52", "tuya_region": "AZ"}, | ||
{"country_code": "MD", "phone_code": "373", "tuya_region": "EU"}, | ||
{"country_code": "MC", "phone_code": "377", "tuya_region": "EU"}, | ||
{"country_code": "MN", "phone_code": "976", "tuya_region": "EU"}, | ||
{"country_code": "ME", "phone_code": "382", "tuya_region": "EU"}, | ||
{"country_code": "MA", "phone_code": "212", "tuya_region": "EU"}, | ||
{"country_code": "MZ", "phone_code": "258", "tuya_region": "EU"}, | ||
{"country_code": "MM", "phone_code": "95", "tuya_region": "AZ"}, | ||
{"country_code": "NA", "phone_code": "264", "tuya_region": "EU"}, | ||
{"country_code": "NP", "phone_code": "977", "tuya_region": "EU"}, | ||
{"country_code": "NL", "phone_code": "31", "tuya_region": "EU"}, | ||
{"country_code": "NZ", "phone_code": "64", "tuya_region": "AZ"}, | ||
{"country_code": "NI", "phone_code": "505", "tuya_region": "AZ"}, | ||
{"country_code": "NE", "phone_code": "227", "tuya_region": "EU"}, | ||
{"country_code": "NG", "phone_code": "234", "tuya_region": "EU"}, | ||
{"country_code": "KP", "phone_code": "850", "tuya_region": "EU"}, | ||
{"country_code": "NO", "phone_code": "47", "tuya_region": "EU"}, | ||
{"country_code": "OM", "phone_code": "968", "tuya_region": "EU"}, | ||
{"country_code": "PK", "phone_code": "92", "tuya_region": "EU"}, | ||
{"country_code": "PA", "phone_code": "507", "tuya_region": "EU"}, | ||
{"country_code": "PY", "phone_code": "595", "tuya_region": "AZ"}, | ||
{"country_code": "PE", "phone_code": "51", "tuya_region": "AZ"}, | ||
{"country_code": "PH", "phone_code": "63", "tuya_region": "AZ"}, | ||
{"country_code": "PL", "phone_code": "48", "tuya_region": "EU"}, | ||
{"country_code": "PF", "phone_code": "689", "tuya_region": "EU"}, | ||
{"country_code": "PT", "phone_code": "351", "tuya_region": "EU"}, | ||
{"country_code": "PR", "phone_code": "1787", "tuya_region": "AZ"}, | ||
{"country_code": "QA", "phone_code": "974", "tuya_region": "EU"}, | ||
{"country_code": "RE", "phone_code": "262", "tuya_region": "EU"}, | ||
{"country_code": "RO", "phone_code": "40", "tuya_region": "EU"}, | ||
{"country_code": "RU", "phone_code": "7", "tuya_region": "EU"}, | ||
{"country_code": "RW", "phone_code": "250", "tuya_region": "EU"}, | ||
{"country_code": "SM", "phone_code": "378", "tuya_region": "EU"}, | ||
{"country_code": "SA", "phone_code": "966", "tuya_region": "EU"}, | ||
{"country_code": "SN", "phone_code": "221", "tuya_region": "EU"}, | ||
{"country_code": "RS", "phone_code": "381", "tuya_region": "EU"}, | ||
{"country_code": "SL", "phone_code": "232", "tuya_region": "EU"}, | ||
{"country_code": "SG", "phone_code": "65", "tuya_region": "EU"}, | ||
{"country_code": "SK", "phone_code": "421", "tuya_region": "EU"}, | ||
{"country_code": "SI", "phone_code": "386", "tuya_region": "EU"}, | ||
{"country_code": "SO", "phone_code": "252", "tuya_region": "EU"}, | ||
{"country_code": "ZA", "phone_code": "27", "tuya_region": "EU"}, | ||
{"country_code": "ES", "phone_code": "34", "tuya_region": "EU"}, | ||
{"country_code": "LK", "phone_code": "94", "tuya_region": "EU"}, | ||
{"country_code": "SD", "phone_code": "249", "tuya_region": "EU"}, | ||
{"country_code": "SR", "phone_code": "597", "tuya_region": "AZ"}, | ||
{"country_code": "SZ", "phone_code": "268", "tuya_region": "EU"}, | ||
{"country_code": "SE", "phone_code": "46", "tuya_region": "EU"}, | ||
{"country_code": "CH", "phone_code": "41", "tuya_region": "EU"}, | ||
{"country_code": "SY", "phone_code": "963", "tuya_region": "EU"}, | ||
{"country_code": "TW", "phone_code": "886", "tuya_region": "AZ"}, | ||
{"country_code": "TJ", "phone_code": "992", "tuya_region": "EU"}, | ||
{"country_code": "TZ", "phone_code": "255", "tuya_region": "EU"}, | ||
{"country_code": "TH", "phone_code": "66", "tuya_region": "AZ"}, | ||
{"country_code": "TG", "phone_code": "228", "tuya_region": "EU"}, | ||
{"country_code": "TO", "phone_code": "676", "tuya_region": "EU"}, | ||
{"country_code": "TT", "phone_code": "1868", "tuya_region": "EU"}, | ||
{"country_code": "TN", "phone_code": "216", "tuya_region": "EU"}, | ||
{"country_code": "TR", "phone_code": "90", "tuya_region": "EU"}, | ||
{"country_code": "TM", "phone_code": "993", "tuya_region": "EU"}, | ||
{"country_code": "VI", "phone_code": "1340", "tuya_region": "EU"}, | ||
{"country_code": "UG", "phone_code": "256", "tuya_region": "EU"}, | ||
{"country_code": "UA", "phone_code": "380", "tuya_region": "EU"}, | ||
{"country_code": "AE", "phone_code": "971", "tuya_region": "EU"}, | ||
{"country_code": "GB", "phone_code": "44", "tuya_region": "EU"}, | ||
{"country_code": "UY", "phone_code": "598", "tuya_region": "AZ"}, | ||
{"country_code": "UZ", "phone_code": "998", "tuya_region": "EU"}, | ||
{"country_code": "VA", "phone_code": "379", "tuya_region": "EU"}, | ||
{"country_code": "VE", "phone_code": "58", "tuya_region": "AZ"}, | ||
{"country_code": "VN", "phone_code": "84", "tuya_region": "AZ"}, | ||
{"country_code": "YE", "phone_code": "967", "tuya_region": "EU"}, | ||
{"country_code": "ZR", "phone_code": "243", "tuya_region": "EU"}, | ||
{"country_code": "ZM", "phone_code": "260", "tuya_region": "EU"}, | ||
{"country_code": "ZW", "phone_code": "263", "tuya_region": "EU"}, | ||
{"country_code": "NCL", "phone_code": "687", "tuya_region": "EU"}, | ||
{"country_code": "MQ", "phone_code": "596", "tuya_region": "EU"}, | ||
] | ||
|
||
|
||
def get_region_by_country_code(country_code): | ||
country = next( | ||
(item for item in COUNTRIES if item["country_code"] == country_code), None | ||
) | ||
|
||
if country is None: | ||
return "EU" | ||
|
||
return country["tuya_region"] | ||
|
||
|
||
def get_region_by_phone_code(phone_code): | ||
country = next( | ||
(item for item in COUNTRIES if item["phone_code"] == phone_code), None | ||
) | ||
|
||
if country is None: | ||
return "EU" | ||
|
||
return country["tuya_region"] | ||
|
||
|
||
def get_phone_code_by_region(region): | ||
country = next((item for item in COUNTRIES if item["region"] == region), None) | ||
|
||
if country is None: | ||
return "44" | ||
|
||
return country["phone_code"] | ||
|
||
|
||
def get_phone_code_by_country_code(country_code): | ||
country = next( | ||
(item for item in COUNTRIES if item["country_code"] == country_code), None | ||
) | ||
|
||
if country is None: | ||
return "44" | ||
|
||
return country["phone_code"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters