|
| 1 | +COUNTRIES = [ |
| 2 | + {"country_code": "AF", "phone_code": "93", "tuya_region": "EU"}, |
| 3 | + {"country_code": "AL", "phone_code": "355", "tuya_region": "EU"}, |
| 4 | + {"country_code": "DZ", "phone_code": "213", "tuya_region": "EU"}, |
| 5 | + {"country_code": "AO", "phone_code": "244", "tuya_region": "EU"}, |
| 6 | + {"country_code": "AR", "phone_code": "54", "tuya_region": "AZ"}, |
| 7 | + {"country_code": "AM", "phone_code": "374", "tuya_region": "EU"}, |
| 8 | + {"country_code": "AU", "phone_code": "61", "tuya_region": "AZ"}, |
| 9 | + {"country_code": "AT", "phone_code": "43", "tuya_region": "EU"}, |
| 10 | + {"country_code": "AZ", "phone_code": "994", "tuya_region": "EU"}, |
| 11 | + {"country_code": "BH", "phone_code": "973", "tuya_region": "EU"}, |
| 12 | + {"country_code": "BD", "phone_code": "880", "tuya_region": "EU"}, |
| 13 | + {"country_code": "BY", "phone_code": "375", "tuya_region": "EU"}, |
| 14 | + {"country_code": "BE", "phone_code": "32", "tuya_region": "EU"}, |
| 15 | + {"country_code": "BZ", "phone_code": "501", "tuya_region": "EU"}, |
| 16 | + {"country_code": "BJ", "phone_code": "229", "tuya_region": "EU"}, |
| 17 | + {"country_code": "BT", "phone_code": "975", "tuya_region": "EU"}, |
| 18 | + {"country_code": "BO", "phone_code": "591", "tuya_region": "AZ"}, |
| 19 | + {"country_code": "BA", "phone_code": "387", "tuya_region": "EU"}, |
| 20 | + {"country_code": "BW", "phone_code": "267", "tuya_region": "EU"}, |
| 21 | + {"country_code": "BR", "phone_code": "55", "tuya_region": "AZ"}, |
| 22 | + {"country_code": "VG", "phone_code": "1284", "tuya_region": "EU"}, |
| 23 | + {"country_code": "BN", "phone_code": "673", "tuya_region": "EU"}, |
| 24 | + {"country_code": "BG", "phone_code": "359", "tuya_region": "EU"}, |
| 25 | + {"country_code": "BF", "phone_code": "226", "tuya_region": "EU"}, |
| 26 | + {"country_code": "BI", "phone_code": "257", "tuya_region": "EU"}, |
| 27 | + {"country_code": "KH", "phone_code": "855", "tuya_region": "EU"}, |
| 28 | + {"country_code": "CM", "phone_code": "237", "tuya_region": "EU"}, |
| 29 | + {"country_code": "US", "phone_code": "1", "tuya_region": "AZ"}, |
| 30 | + {"country_code": "CA", "phone_code": "1", "tuya_region": "AZ"}, |
| 31 | + {"country_code": "CV", "phone_code": "238", "tuya_region": "EU"}, |
| 32 | + {"country_code": "KY", "phone_code": "1345", "tuya_region": "EU"}, |
| 33 | + {"country_code": "CF", "phone_code": "236", "tuya_region": "EU"}, |
| 34 | + {"country_code": "TD", "phone_code": "235", "tuya_region": "EU"}, |
| 35 | + {"country_code": "CL", "phone_code": "56", "tuya_region": "AZ"}, |
| 36 | + {"country_code": "CN", "phone_code": "86", "tuya_region": "AY"}, |
| 37 | + {"country_code": "CO", "phone_code": "57", "tuya_region": "AZ"}, |
| 38 | + {"country_code": "KM", "phone_code": "269", "tuya_region": "EU"}, |
| 39 | + {"country_code": "CG", "phone_code": "242", "tuya_region": "EU"}, |
| 40 | + {"country_code": "CD", "phone_code": "243", "tuya_region": "EU"}, |
| 41 | + {"country_code": "CR", "phone_code": "506", "tuya_region": "EU"}, |
| 42 | + {"country_code": "HR", "phone_code": "385", "tuya_region": "EU"}, |
| 43 | + {"country_code": "CY", "phone_code": "357", "tuya_region": "EU"}, |
| 44 | + {"country_code": "CZ", "phone_code": "420", "tuya_region": "EU"}, |
| 45 | + {"country_code": "DK", "phone_code": "45", "tuya_region": "EU"}, |
| 46 | + {"country_code": "DJ", "phone_code": "253", "tuya_region": "EU"}, |
| 47 | + {"country_code": "DO", "phone_code": "1809", "tuya_region": "EU"}, |
| 48 | + {"country_code": "DO", "phone_code": "1829", "tuya_region": "EU"}, |
| 49 | + {"country_code": "DO", "phone_code": "1849", "tuya_region": "EU"}, |
| 50 | + {"country_code": "EC", "phone_code": "593", "tuya_region": "AZ"}, |
| 51 | + {"country_code": "EG", "phone_code": "20", "tuya_region": "EU"}, |
| 52 | + {"country_code": "SV", "phone_code": "503", "tuya_region": "EU"}, |
| 53 | + {"country_code": "GQ", "phone_code": "240", "tuya_region": "EU"}, |
| 54 | + {"country_code": "ER", "phone_code": "291", "tuya_region": "EU"}, |
| 55 | + {"country_code": "EE", "phone_code": "372", "tuya_region": "EU"}, |
| 56 | + {"country_code": "ET", "phone_code": "251", "tuya_region": "EU"}, |
| 57 | + {"country_code": "FJ", "phone_code": "679", "tuya_region": "EU"}, |
| 58 | + {"country_code": "FI", "phone_code": "358", "tuya_region": "EU"}, |
| 59 | + {"country_code": "FR", "phone_code": "33", "tuya_region": "EU"}, |
| 60 | + {"country_code": "GA", "phone_code": "241", "tuya_region": "EU"}, |
| 61 | + {"country_code": "GM", "phone_code": "220", "tuya_region": "EU"}, |
| 62 | + {"country_code": "GE", "phone_code": "995", "tuya_region": "EU"}, |
| 63 | + {"country_code": "DE", "phone_code": "49", "tuya_region": "EU"}, |
| 64 | + {"country_code": "GH", "phone_code": "233", "tuya_region": "EU"}, |
| 65 | + {"country_code": "GR", "phone_code": "30", "tuya_region": "EU"}, |
| 66 | + {"country_code": "GL", "phone_code": "299", "tuya_region": "EU"}, |
| 67 | + {"country_code": "GT", "phone_code": "502", "tuya_region": "AZ"}, |
| 68 | + {"country_code": "GN", "phone_code": "224", "tuya_region": "EU"}, |
| 69 | + {"country_code": "GY", "phone_code": "592", "tuya_region": "EU"}, |
| 70 | + {"country_code": "HT", "phone_code": "509", "tuya_region": "EU"}, |
| 71 | + {"country_code": "HN", "phone_code": "504", "tuya_region": "EU"}, |
| 72 | + {"country_code": "HK", "phone_code": "852", "tuya_region": "AZ"}, |
| 73 | + {"country_code": "HU", "phone_code": "36", "tuya_region": "EU"}, |
| 74 | + {"country_code": "IS", "phone_code": "354", "tuya_region": "EU"}, |
| 75 | + {"country_code": "IN", "phone_code": "91", "tuya_region": "IN"}, |
| 76 | + {"country_code": "ID", "phone_code": "62", "tuya_region": "AZ"}, |
| 77 | + {"country_code": "IR", "phone_code": "98", "tuya_region": "EU"}, |
| 78 | + {"country_code": "IQ", "phone_code": "964", "tuya_region": "EU"}, |
| 79 | + {"country_code": "IE", "phone_code": "353", "tuya_region": "EU"}, |
| 80 | + {"country_code": "IM", "phone_code": "44", "tuya_region": "EU"}, |
| 81 | + {"country_code": "IL", "phone_code": "972", "tuya_region": "EU"}, |
| 82 | + {"country_code": "IT", "phone_code": "39", "tuya_region": "AZ"}, |
| 83 | + {"country_code": "CI", "phone_code": "225", "tuya_region": "EU"}, |
| 84 | + {"country_code": "JM", "phone_code": "1876", "tuya_region": "EU"}, |
| 85 | + {"country_code": "JP", "phone_code": "81", "tuya_region": "AZ"}, |
| 86 | + {"country_code": "JO", "phone_code": "962", "tuya_region": "EU"}, |
| 87 | + {"country_code": "KZ", "phone_code": "7", "tuya_region": "EU"}, |
| 88 | + {"country_code": "KE", "phone_code": "254", "tuya_region": "EU"}, |
| 89 | + {"country_code": "KR", "phone_code": "82", "tuya_region": "AZ"}, |
| 90 | + {"country_code": "KW", "phone_code": "965", "tuya_region": "EU"}, |
| 91 | + {"country_code": "KG", "phone_code": "996", "tuya_region": "EU"}, |
| 92 | + {"country_code": "LA", "phone_code": "856", "tuya_region": "EU"}, |
| 93 | + {"country_code": "LV", "phone_code": "371", "tuya_region": "EU"}, |
| 94 | + {"country_code": "LB", "phone_code": "961", "tuya_region": "EU"}, |
| 95 | + {"country_code": "LS", "phone_code": "266", "tuya_region": "EU"}, |
| 96 | + {"country_code": "LR", "phone_code": "231", "tuya_region": "EU"}, |
| 97 | + {"country_code": "LY", "phone_code": "218", "tuya_region": "EU"}, |
| 98 | + {"country_code": "LT", "phone_code": "370", "tuya_region": "EU"}, |
| 99 | + {"country_code": "LU", "phone_code": "352", "tuya_region": "EU"}, |
| 100 | + {"country_code": "MO", "phone_code": "853", "tuya_region": "AZ"}, |
| 101 | + {"country_code": "MK", "phone_code": "389", "tuya_region": "EU"}, |
| 102 | + {"country_code": "MG", "phone_code": "261", "tuya_region": "EU"}, |
| 103 | + {"country_code": "MW", "phone_code": "265", "tuya_region": "EU"}, |
| 104 | + {"country_code": "MY", "phone_code": "60", "tuya_region": "AZ"}, |
| 105 | + {"country_code": "MV", "phone_code": "960", "tuya_region": "EU"}, |
| 106 | + {"country_code": "ML", "phone_code": "223", "tuya_region": "EU"}, |
| 107 | + {"country_code": "MT", "phone_code": "356", "tuya_region": "EU"}, |
| 108 | + {"country_code": "MR", "phone_code": "222", "tuya_region": "EU"}, |
| 109 | + {"country_code": "MU", "phone_code": "230", "tuya_region": "EU"}, |
| 110 | + {"country_code": "MX", "phone_code": "52", "tuya_region": "AZ"}, |
| 111 | + {"country_code": "MD", "phone_code": "373", "tuya_region": "EU"}, |
| 112 | + {"country_code": "MC", "phone_code": "377", "tuya_region": "EU"}, |
| 113 | + {"country_code": "MN", "phone_code": "976", "tuya_region": "EU"}, |
| 114 | + {"country_code": "ME", "phone_code": "382", "tuya_region": "EU"}, |
| 115 | + {"country_code": "MA", "phone_code": "212", "tuya_region": "EU"}, |
| 116 | + {"country_code": "MZ", "phone_code": "258", "tuya_region": "EU"}, |
| 117 | + {"country_code": "MM", "phone_code": "95", "tuya_region": "AZ"}, |
| 118 | + {"country_code": "NA", "phone_code": "264", "tuya_region": "EU"}, |
| 119 | + {"country_code": "NP", "phone_code": "977", "tuya_region": "EU"}, |
| 120 | + {"country_code": "NL", "phone_code": "31", "tuya_region": "EU"}, |
| 121 | + {"country_code": "NZ", "phone_code": "64", "tuya_region": "AZ"}, |
| 122 | + {"country_code": "NI", "phone_code": "505", "tuya_region": "AZ"}, |
| 123 | + {"country_code": "NE", "phone_code": "227", "tuya_region": "EU"}, |
| 124 | + {"country_code": "NG", "phone_code": "234", "tuya_region": "EU"}, |
| 125 | + {"country_code": "KP", "phone_code": "850", "tuya_region": "EU"}, |
| 126 | + {"country_code": "NO", "phone_code": "47", "tuya_region": "EU"}, |
| 127 | + {"country_code": "OM", "phone_code": "968", "tuya_region": "EU"}, |
| 128 | + {"country_code": "PK", "phone_code": "92", "tuya_region": "EU"}, |
| 129 | + {"country_code": "PA", "phone_code": "507", "tuya_region": "EU"}, |
| 130 | + {"country_code": "PY", "phone_code": "595", "tuya_region": "AZ"}, |
| 131 | + {"country_code": "PE", "phone_code": "51", "tuya_region": "AZ"}, |
| 132 | + {"country_code": "PH", "phone_code": "63", "tuya_region": "AZ"}, |
| 133 | + {"country_code": "PL", "phone_code": "48", "tuya_region": "EU"}, |
| 134 | + {"country_code": "PF", "phone_code": "689", "tuya_region": "EU"}, |
| 135 | + {"country_code": "PT", "phone_code": "351", "tuya_region": "EU"}, |
| 136 | + {"country_code": "PR", "phone_code": "1787", "tuya_region": "AZ"}, |
| 137 | + {"country_code": "QA", "phone_code": "974", "tuya_region": "EU"}, |
| 138 | + {"country_code": "RE", "phone_code": "262", "tuya_region": "EU"}, |
| 139 | + {"country_code": "RO", "phone_code": "40", "tuya_region": "EU"}, |
| 140 | + {"country_code": "RU", "phone_code": "7", "tuya_region": "EU"}, |
| 141 | + {"country_code": "RW", "phone_code": "250", "tuya_region": "EU"}, |
| 142 | + {"country_code": "SM", "phone_code": "378", "tuya_region": "EU"}, |
| 143 | + {"country_code": "SA", "phone_code": "966", "tuya_region": "EU"}, |
| 144 | + {"country_code": "SN", "phone_code": "221", "tuya_region": "EU"}, |
| 145 | + {"country_code": "RS", "phone_code": "381", "tuya_region": "EU"}, |
| 146 | + {"country_code": "SL", "phone_code": "232", "tuya_region": "EU"}, |
| 147 | + {"country_code": "SG", "phone_code": "65", "tuya_region": "EU"}, |
| 148 | + {"country_code": "SK", "phone_code": "421", "tuya_region": "EU"}, |
| 149 | + {"country_code": "SI", "phone_code": "386", "tuya_region": "EU"}, |
| 150 | + {"country_code": "SO", "phone_code": "252", "tuya_region": "EU"}, |
| 151 | + {"country_code": "ZA", "phone_code": "27", "tuya_region": "EU"}, |
| 152 | + {"country_code": "ES", "phone_code": "34", "tuya_region": "EU"}, |
| 153 | + {"country_code": "LK", "phone_code": "94", "tuya_region": "EU"}, |
| 154 | + {"country_code": "SD", "phone_code": "249", "tuya_region": "EU"}, |
| 155 | + {"country_code": "SR", "phone_code": "597", "tuya_region": "AZ"}, |
| 156 | + {"country_code": "SZ", "phone_code": "268", "tuya_region": "EU"}, |
| 157 | + {"country_code": "SE", "phone_code": "46", "tuya_region": "EU"}, |
| 158 | + {"country_code": "CH", "phone_code": "41", "tuya_region": "EU"}, |
| 159 | + {"country_code": "SY", "phone_code": "963", "tuya_region": "EU"}, |
| 160 | + {"country_code": "TW", "phone_code": "886", "tuya_region": "AZ"}, |
| 161 | + {"country_code": "TJ", "phone_code": "992", "tuya_region": "EU"}, |
| 162 | + {"country_code": "TZ", "phone_code": "255", "tuya_region": "EU"}, |
| 163 | + {"country_code": "TH", "phone_code": "66", "tuya_region": "AZ"}, |
| 164 | + {"country_code": "TG", "phone_code": "228", "tuya_region": "EU"}, |
| 165 | + {"country_code": "TO", "phone_code": "676", "tuya_region": "EU"}, |
| 166 | + {"country_code": "TT", "phone_code": "1868", "tuya_region": "EU"}, |
| 167 | + {"country_code": "TN", "phone_code": "216", "tuya_region": "EU"}, |
| 168 | + {"country_code": "TR", "phone_code": "90", "tuya_region": "EU"}, |
| 169 | + {"country_code": "TM", "phone_code": "993", "tuya_region": "EU"}, |
| 170 | + {"country_code": "VI", "phone_code": "1340", "tuya_region": "EU"}, |
| 171 | + {"country_code": "UG", "phone_code": "256", "tuya_region": "EU"}, |
| 172 | + {"country_code": "UA", "phone_code": "380", "tuya_region": "EU"}, |
| 173 | + {"country_code": "AE", "phone_code": "971", "tuya_region": "EU"}, |
| 174 | + {"country_code": "GB", "phone_code": "44", "tuya_region": "EU"}, |
| 175 | + {"country_code": "UY", "phone_code": "598", "tuya_region": "AZ"}, |
| 176 | + {"country_code": "UZ", "phone_code": "998", "tuya_region": "EU"}, |
| 177 | + {"country_code": "VA", "phone_code": "379", "tuya_region": "EU"}, |
| 178 | + {"country_code": "VE", "phone_code": "58", "tuya_region": "AZ"}, |
| 179 | + {"country_code": "VN", "phone_code": "84", "tuya_region": "AZ"}, |
| 180 | + {"country_code": "YE", "phone_code": "967", "tuya_region": "EU"}, |
| 181 | + {"country_code": "ZR", "phone_code": "243", "tuya_region": "EU"}, |
| 182 | + {"country_code": "ZM", "phone_code": "260", "tuya_region": "EU"}, |
| 183 | + {"country_code": "ZW", "phone_code": "263", "tuya_region": "EU"}, |
| 184 | + {"country_code": "NCL", "phone_code": "687", "tuya_region": "EU"}, |
| 185 | + {"country_code": "MQ", "phone_code": "596", "tuya_region": "EU"}, |
| 186 | +] |
| 187 | + |
| 188 | + |
| 189 | +def get_region_by_country_code(country_code): |
| 190 | + country = next( |
| 191 | + (item for item in COUNTRIES if item["country_code"] == country_code), None |
| 192 | + ) |
| 193 | + |
| 194 | + if country is None: |
| 195 | + return "EU" |
| 196 | + |
| 197 | + return country["tuya_region"] |
| 198 | + |
| 199 | + |
| 200 | +def get_region_by_phone_code(phone_code): |
| 201 | + country = next( |
| 202 | + (item for item in COUNTRIES if item["phone_code"] == phone_code), None |
| 203 | + ) |
| 204 | + |
| 205 | + if country is None: |
| 206 | + return "EU" |
| 207 | + |
| 208 | + return country["tuya_region"] |
| 209 | + |
| 210 | + |
| 211 | +def get_phone_code_by_region(region): |
| 212 | + country = next((item for item in COUNTRIES if item["region"] == region), None) |
| 213 | + |
| 214 | + if country is None: |
| 215 | + return "44" |
| 216 | + |
| 217 | + return country["phone_code"] |
| 218 | + |
| 219 | + |
| 220 | +def get_phone_code_by_country_code(country_code): |
| 221 | + country = next( |
| 222 | + (item for item in COUNTRIES if item["country_code"] == country_code), None |
| 223 | + ) |
| 224 | + |
| 225 | + if country is None: |
| 226 | + return "44" |
| 227 | + |
| 228 | + return country["phone_code"] |
0 commit comments