Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HA helper function is failing to retrieve URL #98702

Closed
exceldatei opened this issue Aug 20, 2023 · 13 comments
Closed

HA helper function is failing to retrieve URL #98702

exceldatei opened this issue Aug 20, 2023 · 13 comments
Labels

Comments

@exceldatei
Copy link

The problem

Cant integrate Tado Camera Controller. Always throws back an integration error.

2023-08-20 12:36:09.457 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry 192.168.1.150 for tapo_control
Traceback (most recent call last):
File “/usr/local/lib/python3.11/site-packages/yarl/_url.py”, line 191, in new
port = val.port
^^^^^^^^
File “/usr/local/lib/python3.11/urllib/parse.py”, line 182, in port
raise ValueError(f"Port could not be cast to integer value as {port!r}")
ValueError: Port could not be cast to integer value as ‘local’

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/config_entries.py”, line 388, in async_setup
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/config/custom_components/tapo_control/init.py”, line 186, in async_setup_entry
if isUsingHTTPS(hass):
^^^^^^^^^^^^^^^^^^
File “/config/custom_components/tapo_control/utils.py”, line 46, in isUsingHTTPS
base_url = get_url(hass, prefer_external=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/helpers/network.py”, line 145, in get_url
return _get_internal_url(
^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/helpers/network.py”, line 221, in _get_internal_url
internal_url = yarl.URL(hass.config.internal_url)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/yarl/_url.py”, line 193, in new
raise ValueError(

3a99c2a09a5200842b0c89b0a1cb7c1e7f983726
1e478aeee8b478e4478bc47e5cb17edb3c2b4441

What version of Home Assistant Core has the issue?

2023.8.3

What was the last working version of Home Assistant Core?

2023.8.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Tapo: Cameras Control

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@joostlek
Copy link
Member

This is an issue in a custom component thus I am going to close this.

Apparently the port passed into this transformation function is "local" which isn't a port, thus it raises an error.

@joostlek joostlek closed this as not planned Won't fix, can't repro, duplicate, stale Aug 20, 2023
@exceldatei
Copy link
Author

Ok, thanks for the reply. The developer answered this to me:

"Report this to Home Assistant github issues. This is not this integration issue, HA helper function is failing to retrieve URL for your HA instance."

@joostlek
Copy link
Member

The problem lies in ValueError: Port could not be cast to integer value as ‘local’.

@JurajNyiri
Copy link

JurajNyiri commented Aug 20, 2023

@joostlek I am the custom integration developer. It is passing the hass object (provided by HA) into the HA helper function (see screenshots) or here. How is this a custom integration issue? Integration is not touching internal HA link set by the user in any way.

HA needs to handle this case internally because it looks like it can be misconfigured in a way this exception is not caught, disregarding the origin of the error.

@joostlek
Copy link
Member

Maybe I closed this too fast, but let's try to figure out what might cause this.

We need to figure out what hass.config.internal_url says. Are you able to maybe add a log Line to the custom component to check what's in it?

To me this sounds like a configuration issue but I'm willing to help figure out.

@joostlek joostlek reopened this Aug 20, 2023
@JurajNyiri
Copy link

@joostlek thank you!

@exceldatei please download this branch manually: https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/tree/debug_isUsingHTTPS, mainly the custom_components/tapo_control/utils.py - you can copy the content of the file from the link, replace it in your HA and restart. I added the logs required there.

Screenshot 2023-08-20 at 15 35 19

You should then see something like this in your logs, probably "None" logs will be something else on your machine.

Screenshot 2023-08-20 at 15 32 53

@joostlek
Copy link
Member

Oh thanks for creating the branch :)

@exceldatei
Copy link
Author

@JurajNyiri Thank you! I tried it out and copied it into utils.py but after restart its the same. I see the logs as you said but the integration is still not working.

2023-08-20 21:11:49.789 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Fire Tablet' for fully_kiosk integration not ready yet: Cannot connect to host 192.168.1.103:2323 ssl:False [Connect call failed ('192.168.1.103', 2323)]; Retrying in background
2023-08-20 21:11:50.118 CRITICAL (MainThread) [custom_components.tapo_control] isUsingHTTPS
2023-08-20 21:11:50.122 CRITICAL (MainThread) [custom_components.tapo_control] http://192.168.1.120:local
2023-08-20 21:11:50.124 CRITICAL (MainThread) [custom_components.tapo_control] None
2023-08-20 21:11:50.125 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry 192.168.1.150 for tapo_control

@JurajNyiri
Copy link

JurajNyiri commented Aug 20, 2023

@exceldatei do you see http://192.168.1.120:local under Settings - System - Network - Home Assistant URL? What do you see there? Could you tell us more about your ENV setup, how are you running HA, have you added this URL there manually etc?

@joostlek
Copy link
Member

I am really wondering how he ended up in this situation

@exceldatei
Copy link
Author

HA is set up on a RP4.
Yes, I see http://192.168.1.120:local

Indeed I wrote it manually once. Just tried to set it to automatically and it works now.
I am not that familiar with the deeper coding stuff as I just started into home assistant.
But it seems that it was just because the manual setting of the local IP

@joostlek
Copy link
Member

Right, I will check in a moment if we actually validate this address before storing it to avoid stuff like this in the future

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@issue-triage-workflows issue-triage-workflows bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 25, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants