nimroddolev / akuvox

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

SMS send error #26

Open dxh000130 opened 10 months ago

dxh000130 commented 10 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 9 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 8 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 8 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 8 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 8 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 8 months ago

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

nimroddolev commented 8 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 8 months ago

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

nimroddolev commented 8 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 8 months ago

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

nimroddolev commented 8 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 8 months ago

Thank you See below:

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

nimroddolev commented 8 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 8 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 7 months ago

Can also confirm Aussie mobile only works with 0.07 :)

romilbhardwaj commented 7 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 7 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 7 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 6 months 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

nimroddolev commented 4 months ago

Hi everyone. I just released a new beta, v0.2.0-beta2, which should address the issue of the missing SMS verification code when adding your SmartPlus account.

I'd like to ask you to please upgrade to the new version and let me know if you are now able to sign in via SMS verification.

To install the new beta version:

  1. Open the Akuvox SmartPlus repository in HACS
  2. Click on the button in the top right
  3. Select the ↻ Redownload option
  4. Enable the Show beta versions option (it may take a moment to update the list)
  5. Select version v0.2.0-beta2 from the updated version drop-down list
  6. Restart Home Assistant
nimroddolev commented 4 months ago

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.

Hi @namdgk. This issue is not related to the Akuvox SmartPlus integration but with the Home Assistant companion app for iOS.

There is another custom component, WebRTC Camera, which can fix this issue that you might want to check out.

SirNoble commented 4 months ago

Hi everyone. I just released a new beta, v0.2.0-beta2, which should address the issue of the missing SMS verification code when adding your SmartPlus account.

I'd like to ask you to please upgrade to the new version and let me know if you are now able to sign in via SMS verification.

To install the new beta version:

  1. Open the Akuvox SmartPlus repository in HACS
  2. Click on the button in the top right
  3. Select the ↻ Redownload option
  4. Enable the Show beta versions option (it may take a moment to update the list)
  5. Select version v0.2.0-beta2 from the updated version drop-down list
  6. Restart Home Assistant

Just tried this and unfortunately still having the same issue with using it via the app token method, when entering the tokens and press okay it gives the error "sign in failed please check the values entered and try again". Tested via the SMS method and that seems to be work fine.

Removed the 0 in front of the number Tried a few times to log out and get different tokens, however same issue.

nimroddolev commented 4 months ago

Could you please try deleting the integration and adding it again?

SirNoble commented 4 months ago

Could you please try deleting the integration and adding it again?

Sorry, same issue image

nimroddolev commented 4 months ago

Thanks for trying. I will take another look as to why it’s not working for you. Just to confirm: you are sure your auth_token and token values are correct? They get reset each time you log in via SMS verification.

SirNoble commented 4 months ago

That's correct, there are new values each time.

nimroddolev commented 4 months ago

The integration sets the regional subdomain used to communicate with Akuvox according to the list from this repo, so it's unclear to me why the SMS request fails.

I released a new beta, v0.2.0-beta3, which allows you to manually override the API regional subdomain used to communicate with Akuvox. You can try to use another subdomain/

robotsmarthomes commented 3 months ago

hey - i am struggling to get seperate token and auth token using MITM Proxy.

I am unable to login with mobile number which is listed on smart plus account.

I am using MITM Proxy on an Ipad. I can see a token, but it is the same in all. but im not seeing the "token and auth-token" in the "https://gate.aucloud.akuvox.com:8600/servers_list"

I also try to login using SMS method and it says number doesnt exist

Located in Australia

using version Beta V2.03

Thanks for your help on this integration, I will support you if i can get some assistance

robotsmarthomes commented 3 months ago

hey - i am struggling to get seperate token and auth token using MITM Proxy.

I am unable to login with mobile number which is listed on smart plus account.

I am using MITM Proxy on an Ipad. I can see a token, but it is the same in all. but im not seeing the "token and auth-token" in the "https://gate.aucloud.akuvox.com:8600/servers_list"

I also try to login using SMS method and it says number doesnt exist

Located in Australia

using version Beta V2.03

Thanks for your help on this integration, I will support you if i can get some assistance

I just downgraded to Beta 2.02 and then itallowed me to login via SMS. Just for reference. It also shows login token and auth tokens in the configuration, would I be able to logout and then use those tokens to log back in, or is the token value a one-off use

fkpp commented 1 month ago

@robotsmarthomes have you ever figured out the token retrieval issue? I was trying to grab it from mitmproxy but there is no POST request (anymore?) for the /servers_list endpoint. I can only see a GET request with no body in the request: image

I am stuck with getting the auth_token, I can just find the token value.

Thanks !