hsakoh/switchbot-mqtt

API rejects commands due to non-matching region

Closed this issue · 7 comments

I am located in the UK (Switchbot region 'eu-central-1'). I can connect and download the device data but commands fail as the API is expecting the region to match 'us-east-1'.

Here is the error message from the API
{"statusCode":190,"body":{},"message":"Functions from 'us-east-1' are not reachable in this region ('eu-central-1')"}

The add-on does not differentiate between regions when calling the API, so it seems to be an internal issue with the SwitchBotAPI.
Recent changes, such as adding new regions, may have confused API's internal routing.

I recommend raising an issue in the following repository:
https://github.com/OpenWonderLabs/SwitchBotAPI

Got it. I'm glad there doesn't seem to be a major issue.

I'll consider ways to suppress the occurrence of this misleading log when I have some time and reflect this in future updates.

Is issue #31 still occurring?

Yes. There's been no response on the issue and e.g. using the add-on's command test button to set the volume on my S10 vacuum it gives result:

{"statusCode":190,"body":{},"message":"Functions from 'us-east-1' are not reachable in this region ('eu-central-1')"}

Is there a way I can masquerade as an American?

Oops, sorry, I intended to write the previous comment in response to issue #36.

The API isn't fixed yet? That's unfortunate.
It would be great if we could directly request the servers for each region behind api.switch-bot.com, but at this point, we haven't been able to identify the servers for each region.
It seems that the botRegion is determined when the account is created, but I haven't figured out a way to force it to the us region.

The 'blocked' message might be coming from Amazon's server itself rather than something in SwitchBot's code. This might explain why it's not a quick fix.

`$ nslookup api.switch-bot.com
Server: 192.168.2.50
Address: 192.168.2.50#53

Non-authoritative answer:
api.switch-bot.com canonical name = d-vsp5hvxzf2.execute-api.us-east-1.amazonaws.com.
Name: d-vsp5hvxzf2.execute-api.us-east-1.amazonaws.com
Address: 44.207.121.227
Name: d-vsp5hvxzf2.execute-api.us-east-1.amazonaws.com
Address: 54.86.213.91
Name: d-vsp5hvxzf2.execute-api.us-east-1.amazonaws.com
Address: 35.153.252.16`

The endpoint api.switch-bot.com is the only one using the AWS API Gateway's edge-optimized API endpoint.
It seems that other domains are switched within the app based on the botRegion.
For reference, here is a list of the various domains:

AP US EU
WonderLabsAPI https://yivk7fys5c.execute-api.ap-northeast-1.amazonaws.com https://l9ren7efdj.execute-api.us-east-1.amazonaws.com https://nt40radyx2.execute-api.eu-central-1.amazonaws.com
appMarket https://8hepwbwsoj.execute-api.us-east-1.amazonaws.com https://8hepwbwsoj.execute-api.us-east-1.amazonaws.com https://8hepwbwsoj.execute-api.us-east-1.amazonaws.com
limitUserOperation https://9cali86zne.execute-api.us-east-1.amazonaws.com https://9cali86zne.execute-api.us-east-1.amazonaws.com https://9cali86zne.execute-api.us-east-1.amazonaws.com
openApiV1 https://j5qyzxpnnj.execute-api.ap-northeast-1.amazonaws.com https://vxhewp40e8.execute-api.us-east-1.amazonaws.com https://65t4c2sxn9.execute-api.eu-central-1.amazonaws.com
publish https://publish.api.switchbot.net https://publish.api.switchbot.net https://publish.api.switchbot.net
account https://account.api.switchbot.net https://account.api.switchbot.net https://account.api.switchbot.net
mqttBroker mqtts://a2alhn2dfztqv9-ats.iot.ap-northeast-1.amazonaws.com:8883 mqtts://a2alhn2dfztqv9-ats.iot.us-east-1.amazonaws.com:8883 mqtts://a2alhn2dfztqv9-ats.iot.eu-central-1.amazonaws.com:8883
userCore https://s5objsz9pd.execute-api.ap-northeast-1.amazonaws.com https://fejlvu0ghd.execute-api.us-east-1.amazonaws.com https://24p21uyba7.execute-api.eu-central-1.amazonaws.com
scene https://hf72w6hc45.execute-api.ap-northeast-1.amazonaws.com https://4k0nk4gb8b.execute-api.us-east-1.amazonaws.com https://37qjo78362.execute-api.eu-central-1.amazonaws.com
tuyaSignaling https://45fn3nnx0l.execute-api.ap-northeast-1.amazonaws.com https://avkxa6hntj.execute-api.us-east-1.amazonaws.com https://g5eobh9p2i.execute-api.eu-central-1.amazonaws.com
command https://u1ae2sry2d.execute-api.ap-northeast-1.amazonaws.com https://6oi8p0504l.execute-api.us-east-1.amazonaws.com https://0su3pc7nwh.execute-api.eu-central-1.amazonaws.com
userGroup https://z3zef3pal1.execute-api.ap-northeast-1.amazonaws.com https://rh3axc6yo6.execute-api.us-east-1.amazonaws.com https://uu7j7hlff7.execute-api.eu-central-1.amazonaws.com
camKvsApi https://6u3tnlw7uk.execute-api.ap-northeast-1.amazonaws.com https://igkqjo8693.execute-api.us-east-1.amazonaws.com https://gow66fktvk.execute-api.eu-central-1.amazonaws.com
sweeperOriginApi https://uc59vnu8l1.execute-api.ap-northeast-1.amazonaws.com https://lonvwnxxn7.execute-api.us-east-1.amazonaws.com https://srm4tliwlb.execute-api.eu-central-1.amazonaws.com
deviceApi https://u1ae2sry2d.execute-api.ap-northeast-1.amazonaws.com https://6oi8p0504l.execute-api.us-east-1.amazonaws.com https://0su3pc7nwh.execute-api.eu-central-1.amazonaws.com
deviceApiBeta https://u1ae2sry2d.execute-api.ap-northeast-1.amazonaws.com https://6oi8p0504l.execute-api.us-east-1.amazonaws.com https://0su3pc7nwh.execute-api.eu-central-1.amazonaws.com
msgCenter https://u9i6uo6nk8.execute-api.ap-northeast-1.amazonaws.com/prod https://vfe17awnia.execute-api.us-east-1.amazonaws.com/prod https://jjrxksisq8.execute-api.eu-central-1.amazonaws.com/prod
wonderlabs https://wonderlabs.ap.api.switchbot.net https://wonderlabs.us.api.switchbot.net https://wonderlabs.eu.api.switchbot.net
pay https://pay.api.switchbot.net https://pay.api.switchbot.net https://pay.api.switchbot.net