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

SAIC-iSmart-API repository for Home Assistant OS (HASS.IO)
MIT License
59 stars 7 forks source link

Idiot's guide #87

Closed Euan-p closed 6 months ago

Euan-p commented 6 months ago

whenever I start the addon, it fails a few seconds later with the following error message in the log. I'm new to HA and haven't managed to get the addon working at all yet, presumable because of this. anyone know what ive done wrong and how to stop this from happening?

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.12/site-packages/gmqtt/mqtt/handler.py", line 217, in _handle_exception_in_future
    if future.exception():
       ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/gmqtt/client.py", line 255, in reconnect
    async def reconnect(self, delay=False):
asyncio.exceptions.CancelledError
2024-04-30 22:13:44,846 [  INFO  ] [CONNECTION MADE] - gmqtt.mqtt.protocol
2024-04-30 22:13:44,851 [WARNING ] [CONNACK] 0x5 - gmqtt
2024-04-30 22:13:44,853 [  INFO  ] [CONN CLOSE NORMALLY] - gmqtt.mqtt.protocol
Traceback (most recent call last):
  File "/usr/src/app/./mqtt_gateway.py", line 883, in <module>
    asyncio.run(mqtt_gateway.run(), debug=debug_log_enabled())
  File "/usr/local/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/src/app/./mqtt_gateway.py", line 424, in run
    await self.publisher.connect()
  File "/usr/src/app/publisher/mqtt_publisher.py", line 86, in connect
    await self.client.connect(host=self.host, port=self.port, version=gmqtt.constants.MQTTv311, ssl=ssl_context)
  File "/usr/local/lib/python3.12/site-packages/gmqtt/client.py", line 235, in connect
    raise self._error
gmqtt.mqtt.handler.MQTTConnectError: code 5 (Connection Refused: not authorised)
2024-04-30 22:13:44,931 [ ERROR  ] Task was destroyed but it is pending!
task: <Task pending name='Task-9' coro=<Client.reconnect() done, defined at /usr/local/lib/python3.12/site-packages/gmqtt/client.py:255> wait_for=<Future pending cb=[Task.task_wakeup()]>> - asyncio
2024-04-30 22:13:45,007 [ 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
nanomad commented 6 months ago

The error says

gmqtt.mqtt.handler.MQTTConnectError: code 5 (Connection Refused: not authorised)

Looks like you are using incorrect credentials to connect to your MQTT broker. If you are using the mosquitto add on make sure you've created a user for the SAIC MQTT Gateway and that correct credentials have been supplied

Euan-p commented 6 months ago

Thanks for the help, I've fixed that and now it is running the startup process further, but is crashing when it tries to login to the API because the "call return code is not acceptable". Also, the wiki says auto discovery show kick in, but I've broken that as well. Any advice on either of these?

nanomad commented 6 months ago

What do you use as a login method in the mg app? Phone numbers or email?

Make sure your password only contains alphanumeric characters, no symbols. Uppercase letters are ok as well

Il Gio 2 Mag 2024, 19:33 flying-panda-44 @.***> ha scritto:

Thanks for the help, I've fixed that and now it is running the startup process further, but is crashing when it tries to login to the API because the "call return code is not acceptable". Also, the wiki says auto discovery show kick in, but I've broken that as well. Any advice on either of these?

— Reply to this email directly, view it on GitHub https://github.com/SAIC-iSmart-API/saic-home-assistant-addon/issues/87#issuecomment-2091130848, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIT3RVA3IJDXNJW4YOQBB3ZAJ2GFAVCNFSM6AAAAABHBCETRCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJRGEZTAOBUHA . You are receiving this because you commented.Message ID: @.*** com>

Euan-p commented 6 months ago

I've been using a phone number to login, and my password is completely alphanumeric.

however, i did find this in the logs. Does it mean I need to add a country code into my config, because it's not marked as required. If so, is it just the country or the whole phone number. 2024-05-02** 17:57:31,315 [ ERROR ] API call return code is not acceptable: 1000020: {"code":1000020,"message":"The country code not exist !"}.

nanomad commented 6 months ago

It's not required since it's needed only for phone numbers. It's for example 39 for italy. You should remove it from your phone number and specify that in that var

Euan-p commented 6 months ago

Thanks so much! I know thsi was probably really frustrating for you to sit through, but I've got the integration working now. Thanks again