nimroddolev / akuvox

Home Assistant integration to add Akuvox SmartPlus door cameras, door open relay buttons and temporary keys
MIT License
13 stars 1 forks source link

SMS send error #26

Open dxh000130 opened 5 months ago

dxh000130 commented 5 months ago

System Health details

System Information

version core-2024.1.2
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.11.6
os_name Linux
os_version 6.1.63-haos-raspi
arch aarch64
timezone Pacific/Auckland
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4972 Installed Version | 1.33.0 Stage | running Available Repositories | 1451 Downloaded Repositories | 10 HACS Data | ok
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 11.3 -- | -- update_channel | stable supervisor_version | supervisor-2023.12.0 agent_version | 1.6.0 docker_version | 24.0.7 disk_total | 115.2 GB disk_used | 8.3 GB healthy | true supported | true board | rpi5-64 supervisor_api | ok version_api | ok installed_addons | VLC (0.3.0), Advanced SSH & Web Terminal (17.0.2), File editor (5.7.0), Music Assistant BETA (2.0.0b82), go2rtc (1.8.5), Nginx Proxy Manager (1.0.1)
Dashboards dashboards | 2 -- | -- resources | 2 views | 6 mode | storage
Recorder oldest_recorder_run | 2024年1月8日 23:15 -- | -- current_recorder_run | 2024年1月16日 15:50 estimated_db_size | 1215.38 MiB database_engine | sqlite database_version | 3.41.2
Spotify api_endpoint_reachable | ok -- | --

Checklist

Describe the issue

image "stored_data" is none in line 545 at api.py

Reproduction steps

  1. add the integration 2.SMS Verification (Recommended) 3.after input area and phone ...

Debug logs

2024-01-16 02:54:35.211 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 543, in _handle
resp = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 114, in impl
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 233, in auth_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware
response = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 149, in handle
result = await handler(request, **request.match_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 63, in with_admin
return await func(self, request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 177, in post
return await super().post(request, flow_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
result = await method(view, request, data, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
result = await self._flow_mgr.async_configure(flow_id, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 320, in async_configure
result = await self._async_handle_step(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 416, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/akuvox/config_flow.py", line 125, in async_step_sms_sign_in
request_sms_code = await self.akuvox_api_client.send_sms(country_code, phone_number, subdomain)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/akuvox/api.py", line 313, in send_sms
await self.async_init_api_data()
File "/config/custom_components/akuvox/api.py", line 274, in async_init_api_data
await self.start_polling_personal_door_log()
File "/config/custom_components/akuvox/api.py", line 546, in start_polling_personal_door_log
if "last_polling_time" in stored_data:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable

Diagnostics dump

No response

nimroddolev commented 5 months ago

Hi @dxh000130.

I have just released a new version, v0.1.1, which hopefully addresses your issue. Can you please upgrade to it and let me know if it now resolved?

SirNoble commented 3 months ago

Sorry, this issue is quite old however, I'm also getting the same issue @nimroddolev , when I enter my Australian phone number for SMS verification it says the "SMS code request failed. Check your phone number." The app token method displays a similar issue. Both the 0.1.1 and 0.20 beta produce the same issue.

Going back to 0.07 seems to continue to work.

nimroddolev commented 3 months ago

Hi @SirNoble, i'm sorry you've been having issues.

It would be helpful to be able to review the debug log messages for the issue:

  1. Turn on debug logging:

    service: logger.set_level
    data:
     custom_components.akuvox: debug
  2. Request a new sms verification code

  3. Check your log messages in Home Assistant: https://{YOUR_HOME_ASSISTANT_ADDRESS}:8123/config/logs?filter=akuvox and click LOAD FULL LOGS

  4. Post here your debug log messages

SirNoble commented 3 months ago

Thank you for looking into this! See below:

2024-03-18 22:28:53.429 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:28:57.784 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:29:02.079 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:29:06.330 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:29:10.664 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:29:14.262 DEBUG (MainThread) [custom_components.akuvox] 🌍 User will use the API from subdomain aucloud 2024-03-18 22:29:14.262 DEBUG (MainThread) [custom_components.akuvox] 📡 Fetching REST server data... 2024-03-18 22:29:14.267 WARNING (SyncWorker_9) [py.warnings] /usr/local/lib/python3.12/concurrent/futures/thread.py:94: RuntimeWarning: coroutine 'AkuvoxData.async_set_stored_data_for_key' was never awaited 2024-03-18 22:29:14.949 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:29:15.679 DEBUG (MainThread) [custom_components.akuvox] ✅ REST server data received successfully 2024-03-18 22:29:15.682 DEBUG (MainThread) [custom_components.akuvox] 📡 Requesting SMS code... 2024-03-18 22:29:16.867 WARNING (MainThread) [custom_components.akuvox] 🤨 Response: {'result': -1, 'message': "Mobile Number doesn't exist"} 2024-03-18 22:29:16.868 DEBUG (MainThread) [custom_components.akuvox] ❌ SMS code request unsuccessful 2024-03-18 22:29:19.336 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:29:23.644 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:29:28.058 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:29:32.401 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:29:36.715 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:29:41.029 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:29:45.582 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:29:50.041 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:29:54.335 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:29:58.599 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:30:02.862 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:30:07.142 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:30:11.538 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community"

Via the app token method: 2024-03-18 22:32:57.075 DEBUG (MainThread) [custom_components.akuvox] 📡 Fetching REST server data... 2024-03-18 22:32:57.076 WARNING (MainThread) [py.warnings] /usr/local/lib/python3.12/asyncio/base_events.py:1989: RuntimeWarning: coroutine 'AkuvoxData.async_set_stored_data_for_key' was never awaited 2024-03-18 22:32:58.126 DEBUG (MainThread) [custom_components.akuvox] ✅ REST server data received successfully 2024-03-18 22:32:58.129 DEBUG (MainThread) [custom_components.akuvox] 📡 Requesting server list... 2024-03-18 22:32:58.808 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community" 2024-03-18 22:32:59.179 WARNING (MainThread) [custom_components.akuvox] 🤨 Response: {'message': 'request is invalid', 'result': -1} 2024-03-18 22:32:59.179 ERROR (MainThread) [custom_components.akuvox] ❌ Unable to retrieve server list. 2024-03-18 22:33:03.305 DEBUG (MainThread) [custom_components.akuvox] Changing app type "single" <--> "community"

nimroddolev commented 3 months ago

No problem, I hope I can help. Which version of the integration are you running, and is this the entire log?

SirNoble commented 3 months ago

Thank you, yes is the entire log. Using V0.1.1

nimroddolev commented 3 months ago

Thank you. Have you tried entering your mobile number both with & without the leading zero at the start? I.e: 0455555555 and 4555555555

SirNoble commented 3 months ago

I have, has the same issue both methods of signing in.

nimroddolev commented 3 months ago

Very odd... I think perhaps the best way to understand the issue would be to use mitmproxy to get the actual API requests for:

  1. Requesting the sms verification code, and
  2. Logging in with the tokens

Are you able to connect your phone via mitmproxy and send the request & response data for these 2 requests? I can guide you through the process.

EDIT: my guess is that there might be something specific to the Australian servers.

SirNoble commented 3 months ago

Sure, happy to provide these if you could please guide me through what you require.

nimroddolev commented 3 months ago

Ok great, thank you.

  1. Install mitm from https://mitmproxy.org/
  2. Sign out of Akuvox and quit the app
  3. Connect your phone to mitm (see their documentation)
  4. Launch Aluvox and sign in via SMS
  5. In the results from mitm, click on the send_mobile_checkcode request
  6. Select the `Request tab and please send me a screenshot of the request parameters

Screenshot 2024-03-18 at 14 15 47

SirNoble commented 3 months ago

Thank you See below:

Edit: Phone number is showing, just been removed for obvious reasons. image

nimroddolev commented 3 months ago

Thank you for the screenshot, unfortunately everything looks ok from what I can tell - beside the fact that it's not working for you 😀

Could you please confirm for me which was the most recent version that worked for you? I will review the changes since that version to hopefully pinpoint the issue.

SirNoble commented 3 months ago

The latest version that worked was 0.07. which is when you added support for Australia.

Tried versions v0.1.1, v0.1.0, V,2.0-Beta1 and all have the same issue.

thestu90 commented 2 months ago

Can also confirm Aussie mobile only works with 0.07 :)

romilbhardwaj commented 2 months ago

Thanks for the great work @nimroddolev! Unfortunately I'm running into the same issue on US region - v0.0.7 is the last known version to work. Using later versions (commit 7c33d71) fails at auth token based login (same tokens work on v0.0.7):

image

HA version - 2024.4.3

HA debug logs

2024-04-25 23:39:24.074 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration akuvox which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-04-25 23:39:24.075 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-04-25 23:39:25.249 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'hacs' accesses hass.components.frontend. This is deprecated and will stop working in Home Assistant 2024.9, it should be updated to import functions used from frontend directly at custom_components/hacs/frontend.py, line 68: hass.components.frontend.async_register_built_in_panel(, please create a bug report at https://github.com/hacs/integration/issues
2024-04-25 23:39:50.882 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'akuvox' calls `async_run_job`, which is deprecated and will be removed in Home Assistant 2025.4; Please review https://developers.home-assistant.io/blog/2024/03/13/deprecate_add_run_job for replacement options at custom_components/akuvox/api.py, line 81: hass.async_run_job(self.async_set_stored_data_for_key, "wait_for_image_url", self.wait_for_image_url), please create a bug report at https://github.com/nimroddolev/akuvox/issues
2024-04-25 23:40:09.407 WARNING (MainThread) [py.warnings] /usr/local/lib/python3.12/asyncio/base_events.py:1989: RuntimeWarning: coroutine 'AkuvoxData.async_set_stored_data_for_key' was never awaited
handle = None # Needed to break cycles when an exception occurs.
2024-04-25 23:40:10.972 WARNING (MainThread) [custom_components.akuvox] 🤨 Response: {'message': 'request is invalid', 'result': -1}
2024-04-25 23:40:10.972 ERROR (MainThread) [custom_components.akuvox] ❌ Unable to retrieve server list.

Mitmproxy for servers_list call

mitmproxy screenshots of servers_list API call (anonymized):

image

Response:

{
  "datas": {
    "access_server": "54.241.249.251:8501",
    "access_server_ipv6": "[2600:1f1c:19d:ef11:c9d9:6958:e854:3df6]:8501",
    "pbx_server": "pbx1.ucloud.akuvox.com:5070",
    "pbx_server_ipv6": "[2600:1f1c:19d:ef00:ad66:e397:7c8c:66ca]:5070",
    "platform_ver": "6700",
    "rest_server": "ucloud.akuvox.com:8080",
    "rest_server_https": "ucloud.akuvox.com:8443",
    "rest_server_https_ipv6": "[2600:1f1c:19d:ef00:55a2:5f88:f6ba:1e8]:8443",
    "rest_server_ipv6": "[2600:1f1c:19d:ef00:55a2:5f88:f6ba:1e8]:8080",
    "smarthome_site": "ucloud.akubela.com",
    "vrtsp_server": "rtspsrv1.ucloud.akuvox.com:554",
    "vrtsp_server_ipv6": "[2600:1f1c:19d:ef11:ad10:2b7b:8bc5:505b]:554",
    "web_server": "ucloud.akuvox.com",
    "web_server_ipv6": "[2600:1f1c:19d:ef00:55a2:5f88:f6ba:1e8]"
  },
  "message": "success",
  "result": 0
}
romilbhardwaj commented 2 months ago

Quick update - I noticed that the requests were being sent to https://gate.subdomain.akuvox.com:8600/servers_list as defined in const.py: https://github.com/nimroddolev/akuvox/blob/7c33d71fe86d89e8f60292e6540ed20c00c3799f/custom_components/akuvox/const.py#L20-L21

However, my mitmproxy intercepts showed the queries were being sent to https://gate.ucloud.akuvox.com:8600/servers_list.

I changed REST_SERVER_ADDR = "gate.ucloud.akuvox.com" in const.py and login seems to be working now. These URLs are region specific (?) and perhaps not being set correctly for US/AU regions?

SirNoble commented 2 months ago

Quick update - I noticed that the requests were being sent to https://gate.subdomain.akuvox.com:8600/servers_list as defined in const.py:

https://github.com/nimroddolev/akuvox/blob/7c33d71fe86d89e8f60292e6540ed20c00c3799f/custom_components/akuvox/const.py#L20-L21

However, my mitmproxy intercepts showed the queries were being sent to https://gate.ucloud.akuvox.com:8600/servers_list.

I changed REST_SERVER_ADDR = "gate.ucloud.akuvox.com" in const.py and login seems to be working now. These URLs are region specific (?) and perhaps not being set correctly for US/AU regions?

Interesting, I'll give a try when I'm home.

EDIT: This worked for me too, so thank you!

namdgk commented 1 month ago

I got it working as well by changing the URL. The problem I have now is that the live camera feed shows up on the web version of HA but when I try to livestream the camera from the iOS HA app, I get an error. Anyone else have the same problem? I attached a picture below of what happens on iOS when I try to play the livestream. I’d really appreciate any help on this, thanks! IMG_1152