SAIC-iSmart-API/saic-home-assistant-addon

Error 1000020, message: The country code not exist !

Closed this issue · 13 comments

Hi,

Since few days add-on is not starting in home assistant.
Version used : 0.5.2.
SAIR_REST_URI : https://gateway-mg-eu.soimt.com/api.app/v1/

Error :

2024-01-29 22:45:03,072 [ ERROR ] API call return code is not acceptable: 1000020: {"code":1000020,"message":"The country code not exist !"}. Headers: Headers({'date': 'Mon, 29 Jan 2024 21:45:03 GMT', 'content-type': 'application/x-www-form-urlencoded', 'content-length': '57', 'connection': 'keep-alive', 'x-content-type-options': 'nosniff', 'x-xss-protection': '1; mode=block', 'cache-control': 'no-cache, no-store, max-age=0, must-revalidate', 'pragma': 'no-cache', 'expires': '0', 'x-frame-options': 'DENY', 'app-content-encrypted': '1', 'original-content-type': 'application/x-www-form-urlencoded', 'app-send-date': '1706564703059', 'app-verification-string': 'fadd4f5aa7075074ece924b3343dd7c8a12e9d36ad5d0cedcf444536015ac1bf'}) - saic_ismart_client_ng.api.base 2024-01-29 22:45:03,072 [ ERROR ] MqttGateway crashed due to SaicApiException - __main__ Traceback (most recent call last): File "/usr/src/app/./mqtt_gateway.py", line 322, in run login_response_message = await self.saic_api.login() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/saic_ismart_client_ng/api/base.py", line 71, in login result = await self.deserialize(req, response, LoginResp) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/saic_ismart_client_ng/api/base.py", line 176, in deserialize raise se File "/usr/local/lib/python3.12/site-packages/saic_ismart_client_ng/api/base.py", line 166, in deserialize raise SaicApiException(error_message, return_code=return_code) saic_ismart_client_ng.exceptions.SaicApiException: return code: 1000020, message: The country code not exist ! return code: 1000020, message: The country code not exist ! 2024-01-29 22:45:03,114 [ ERROR ] Task was destroyed but it is pending! task: <Task pending name='Task-1' coro=<Client._resend_qos_messages() running at /usr/local/lib/python3.12/site-packages/gmqtt/client.py:176>> - asyncio sys:1: RuntimeWarning: coroutine 'Client._resend_qos_messages' was never awaited

Could you please help ?

Thanks

From which country do you try to connect to the gateway?

France

Please set the log-level to DEBUG and post it here without your vin or email.

2024-01-30 16:43:13,814 [ INFO ] [CONNECTION MADE] - gmqtt.mqtt.protocol
2024-01-30 16:43:13,816 [ DEBUG ] [CMD 0x20] b'\x00\x00' - gmqtt
2024-01-30 16:43:13,816 [ DEBUG ] [CONNACK] flags: 0x0, result: 0x0 - gmqtt
2024-01-30 16:43:13,816 [ INFO ] Connected to MQTT broker - mqtt_publisher
2024-01-30 16:43:13,817 [ DEBUG ] NEW ID: 1 - gmqtt.mqtt.utils
2024-01-30 16:43:13,817 [ INFO ] [SEND SUB] 1 [b'saic/33-XXX/vehicles/+/+/+/set'] - gmqtt.mqtt.package
2024-01-30 16:43:13,817 [ DEBUG ] NEW ID: 2 - gmqtt.mqtt.utils
2024-01-30 16:43:13,817 [ INFO ] [SEND SUB] 2 [b'saic/33-XXX/vehicles/+/+/+/+/set'] - gmqtt.mqtt.package
2024-01-30 16:43:13,817 [ DEBUG ] NEW ID: 3 - gmqtt.mqtt.utils
2024-01-30 16:43:13,817 [ INFO ] [SEND SUB] 3 [b'saic/33-XXX/vehicles/+/refresh/mode/set'] - gmqtt.mqtt.package
2024-01-30 16:43:13,817 [ DEBUG ] NEW ID: 4 - gmqtt.mqtt.utils
2024-01-30 16:43:13,817 [ INFO ] [SEND SUB] 4 [b'saic/33-XXX/vehicles/+/refresh/period/+/set'] - gmqtt.mqtt.package
2024-01-30 16:43:13,817 [ DEBUG ] Sending PUBLISH (q0), 'b'saic/_internal/lwt'', ... (6 bytes) - gmqtt.mqtt.package
2024-01-30 16:43:13,818 [ INFO ] Scheduler started - apscheduler.scheduler
2024-01-30 16:43:13,819 [ INFO ] Logging in to SAIC API - main
2024-01-30 16:43:13,819 [ DEBUG ] Sending PUBLISH (q0), 'b'saic/_internal/api/oauth/token/request'', ... (567 bytes) - gmqtt.mqtt.package
2024-01-30 16:43:13,825 [ DEBUG ] Looking for jobs to run - apscheduler.scheduler
2024-01-30 16:43:13,825 [ DEBUG ] No jobs; waiting until a job is added - apscheduler.scheduler
2024-01-30 16:43:13,826 [ DEBUG ] [CMD 0x90] b'\x00\x01\x00' - gmqtt
2024-01-30 16:43:13,826 [ INFO ] [SUBACK] 1 (0,) - gmqtt
2024-01-30 16:43:13,826 [ DEBUG ] FREE MID: 1 - gmqtt.mqtt.utils
2024-01-30 16:43:13,826 [ DEBUG ] [CMD 0x90] b'\x00\x02\x00' - gmqtt
2024-01-30 16:43:13,826 [ INFO ] [SUBACK] 2 (0,) - gmqtt
2024-01-30 16:43:13,826 [ DEBUG ] FREE MID: 2 - gmqtt.mqtt.utils
2024-01-30 16:43:13,826 [ DEBUG ] [CMD 0x90] b'\x00\x03\x00' - gmqtt
2024-01-30 16:43:13,826 [ INFO ] [SUBACK] 3 (0,) - gmqtt
2024-01-30 16:43:13,826 [ DEBUG ] FREE MID: 3 - gmqtt.mqtt.utils
2024-01-30 16:43:13,826 [ DEBUG ] [CMD 0x90] b'\x00\x04\x00' - gmqtt
2024-01-30 16:43:13,827 [ INFO ] [SUBACK] 4 (0,) - gmqtt
2024-01-30 16:43:13,827 [ DEBUG ] FREE MID: 4 - gmqtt.mqtt.utils
2024-01-30 16:43:13,965 [ DEBUG ] Sending PUBLISH (q0), 'b'saic/_internal/api/oauth/token/response'', ... (775 bytes) - gmqtt.mqtt.package
2024-01-30 16:43:13,966 [ ERROR ] API call return code is not acceptable: 1000020: {"code":1000020,"message":"The country code not exist !"}. Headers: Headers({'date': 'Tue, 30 Jan 2024 15:43:13 GMT', 'content-type': 'application/x-www-form-urlencoded', 'content-length': '57', 'connection': 'keep-alive', 'x-content-type-options': 'nosniff', 'x-xss-protection': '1; mode=block', 'cache-control': 'no-cache, no-store, max-age=0, must-revalidate', 'pragma': 'no-cache', 'expires': '0', 'x-frame-options': 'DENY', 'app-content-encrypted': '1', 'original-content-type': 'application/x-www-form-urlencoded', 'app-send-date': '1706629393949', 'app-verification-string': '3307ec7fce7c98ce937373ae0a11b0d23911c2d35bb6c5b042a5120fcd274c93'}) - saic_ismart_client_ng.api.base
2024-01-30 16:43:13,966 [ ERROR ] MqttGateway crashed due to SaicApiException - main
Traceback (most recent call last):
File "/usr/src/app/./mqtt_gateway.py", line 322, in run
login_response_message = await self.saic_api.login()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/saic_ismart_client_ng/api/base.py", line 71, in login
result = await self.deserialize(req, response, LoginResp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/saic_ismart_client_ng/api/base.py", line 176, in deserialize
raise se
File "/usr/local/lib/python3.12/site-packages/saic_ismart_client_ng/api/base.py", line 166, in deserialize
raise SaicApiException(error_message, return_code=return_code)
saic_ismart_client_ng.exceptions.SaicApiException: return code: 1000020, message: The country code not exist !
return code: 1000020, message: The country code not exist !
2024-01-30 16:43:14,005 [ ERROR ] Task was destroyed but it is pending!
task: <Task pending name='Task-1' coro=<Client._resend_qos_messages() running at /usr/local/lib/python3.12/site-packages/gmqtt/client.py:176>> - asyncio
sys:1: RuntimeWarning: coroutine 'Client._resend_qos_messages' was never awaited

Your problem is that you try to login with your phone number. It seems to work only with email as username (at the moment).

@nanomad: Do you know the right syntax to login with the phone number?

@Tonno87 I'll have to address that in the gateway config, the API already supports it

@Tonno87 I've pre-released 0.5.6 which should include the fix for this issue, is it possible to release a "beta" addon version?

The new env variable is called SAIC_PHONE_COUNTRY_CODE, this is what the setup should look like (I'm guessing as I don't have a phone number bound)

Given the following mobile phone number: (+39) 333 12332123

SAIC_PHONE_COUNTRY_CODE=39
SAIC_USER=33312332123
SAIC_PASSWORD=Whatever1234

No problem, i will create an addon and test it with my phone number.

Done:

Traceback (most recent call last):
  File "/usr/src/app/./mqtt_gateway.py", line 778, in <module>
    mqtt_gateway = MqttGateway(configuration)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/app/./mqtt_gateway.py", line 307, in __init__
    phone_country_code=None if username_is_email else self.configuration.phone_country_code,
                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Configuration' object has no attribute 'phone_country_code'. Did you mean: 'saic_phone_country_code'?

@Tonno87 should be fixed in 0.5.7

@nanomad Yes, it's fixed and works now.

@uek06: You can try it out by installing the new addon with the PreRelease Tag. Search for updates in the addon store and reload the page:
image

Cool, I'll remove the pre-release tag as it fixes the door locking as well

Thanks guys it works well with the prerelase tag addon !