core
core copied to clipboard
Nanoleaf unexpected error when trying to connect
The problem
I've moved my setup to my new home, since then I'm not able to connect my Nanoleaf Shapes to Home Assistant.
What version of Home Assistant Core has the issue?
core-2023.10.3
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
nanoleaf
Link to integration documentation on our website
https://www.home-assistant.io/integrations/nanoleaf/
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Logger: homeassistant.components.nanoleaf.config_flow
Source: components/nanoleaf/config_flow.py:165
Integration: nanoleaf (documentation, issues)
First occurred: 15:43:19 (3 occurrences)
Last logged: 15:43:23
Unknown error authorizing Nanoleaf
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 'a39d:124a:43d2:828a:f7ff:fe06:8684:16021'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 423, in _request
url = self._build_url(str_or_url)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 357, in _build_url
url = URL(str_or_url)
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/yarl/_url.py", line 193, in __new__
raise ValueError(
ValueError: Invalid URL: port can't be converted to integer
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/nanoleaf/config_flow.py", line 165, in async_step_link
await self.nanoleaf.authorize()
File "/usr/local/lib/python3.11/site-packages/aionanoleaf/nanoleaf.py", line 266, in authorize
resp = await self._session.post(f"{self._api_url}/new")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 425, in _request
raise InvalidURL(str_or_url) from e
aiohttp.client_exceptions.InvalidURL: http://fdd7:a39d:124a:43d2:828a:f7ff:fe06:8684:16021/api/v1/new
Additional information
Nanoleaf is discovered automatically, it just won't connect
Hey there @milanmeu, mind taking a look at this issue as it has been labeled with an integration (nanoleaf) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of nanoleaf can trigger bot actions by commenting:
@home-assistant closeCloses the issue.@home-assistant rename Awesome new titleRenames the issue.@home-assistant reopenReopen the issue.@home-assistant unassign nanoleafRemoves the current integration label and assignees on the issue, add the integration domain after the command.
(message by CodeOwnersMention)
nanoleaf documentation nanoleaf source (message by IssueLinks)
Looks like you're using IPv6. The IP address should be enclosed by square brackets in the request URL. This is not explicitly implemented in the integration nor the package. Are you manually adding the device and entering it's IP in the config flow, or are you setting up an automatically discovered device?
I've now tried adding it via IPv4 manually and it worked, thank you.
May I ask if an IPv6 implementation will be coming to the integration?
IPv6 should already work if you manually add the device and enclose its IP address within square brackets. The discovery component doesn't add the brackets so the IP breaks when the API port is added. The integration (or the aionanoleaf package) should automatically add the square brackets to the API requests when IPv6 is used. I added it to my list of issues to fix. However, feel free to open a pull request, if you know how to fix it.
Hey @milanmeu I am also having the same issue. I had my Nanoleaf working with HA fine till an update of the Nanoleaf app recently which required me re-add the device in the app. Which meant the HA integration also broke. So I'm trying to re-add it back in HA and getting "Unexpected error"
What version of Home Assistant Core has the issue? Core - 2024.1.2 Supervisor - 2023.12.0 Operating System - 11.4
What was the last working version of Home Assistant Core? No response
What type of installation are you running? Home Assistant OS
Integration causing the issue nanoleaf
Link to integration documentation on our website https://www.home-assistant.io/integrations/nanoleaf/
Diagnostics information No response
Example YAML snippet No response
Anything in the logs that might be useful for us?
Logger: homeassistant.components.nanoleaf.config_flow
Source: components/nanoleaf/config_flow.py:165
Integration: Nanoleaf (documentation, issues)
First occurred: 9:08:01 PM (40 occurrences)
Last logged: 10:00:30 PM
Unknown error authorizing Nanoleaf
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 'ca63:7e61:6142:828a:f7ff:fe07:74be:16021'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 445, in _request
url = self._build_url(str_or_url)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 372, in _build_url
url = URL(str_or_url)
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/yarl/_url.py", line 193, in __new__
raise ValueError(
ValueError: Invalid URL: port can't be converted to integer
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/nanoleaf/config_flow.py", line 165, in async_step_link
await self.nanoleaf.authorize()
File "/usr/local/lib/python3.11/site-packages/aionanoleaf/nanoleaf.py", line 266, in authorize
resp = await self._session.post(f"{self._api_url}/new")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 447, in _request
raise InvalidURL(str_or_url) from e
aiohttp.client_exceptions.InvalidURL: http://fda8:ca63:7e61:6142:828a:f7ff:fe07:74be:16021/api/v1/new
Just to add to above problem @milanmeu, my nanoleaf is auto-discovered by HA and follow the instructions to add it but then i get the "Unexpected Error".
I also tried adding it using the Nanoleaf's IP address manually with no luck, Any assistant is greatly appreciated.
Same here
I'm experiencing the same issue. Adding the device with square brackets around the IP does fix the issue, but for some reason the integration keeps removing these brackets. Any reasons you could think of that might cause this?
I can add it manually for with an ipv4 address, but it only works for a few minutes.
Im also having the same issue.. I was able to add a few of mine and then no more
Getting the same issue here. Try to add them via discovery and unknown error no matter what. Trying to add them via IP address seems to work a bit better and asks me to trigger a token, but when submitting I receive a blank box that doesn't let me add the lights.
Same issue here. When I configure it via IPv4/6, it shows a blank screen with only close buttons
Any workaround except HomeKit Controller?
Thx in advance
My Shapes controller started having trouble recently, due, I think to the same IPV6 issues in this thread. As with @owen2 I could re-add it manually via its IPV4 address it and worked for a while (minutes, sometimes hours) before dying again.
I enabled Debug logging and noticed this:
2024-04-19 17:18:08.488 DEBUG (MainThread) [homeassistant.components.nanoleaf] Finished fetching Shapes XXXX data in 0.012 seconds (success: True)
2024-04-19 17:19:07.737 DEBUG (MainThread) [homeassistant.components.nanoleaf] Finished fetching Shapes XXXX data in 0.020 seconds (success: True)
2024-04-19 17:20:07.740 DEBUG (MainThread) [homeassistant.components.nanoleaf] Finished fetching Shapes XXXX data in 0.023 seconds (success: True)
2024-04-19 17:21:07.732 DEBUG (MainThread) [homeassistant.components.nanoleaf] Finished fetching Shapes XXXX data in 0.016 seconds (success: True)
2024-04-19 17:21:43.192 DEBUG (MainThread) [homeassistant.components.nanoleaf.config_flow] Zeroconf discovered: ZeroconfServiceInfo(ip_address=ZeroconfIPv6Address('xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx'), ip_addresses=[ZeroconfIPv6Address('xxxx:xxxx:xxxx:xxxx:828a:xxxx:xxxx:xxxx'), ZeroconfIPv6Address('xxxx::xxxx:xxxx:xxxx:xxxx%3')], port=6517, hostname='Shapes-XXXX.local.', type='_nanoleafms._tcp.local.', name='Shapes XXXX._nanoleafms._tcp.local.', properties={'id': 'xx:xx:xx:xx:xx:xx', 'md': 'NL42', 'ff': '2', 'c#': '3', 's#': '1', 'ci': '5', 'pv': '1.1', 'sh': 'SKf5+w==', 'sf': '1'})
2024-04-19 17:21:43.219 DEBUG (MainThread) [homeassistant.components.nanoleaf] Finished fetching Shapes XXXX data in 0.001 seconds (success: False)
2024-04-19 17:21:48.328 DEBUG (MainThread) [homeassistant.components.nanoleaf] Finished fetching Shapes XXXX data in 0.000 seconds (success: False)
2024-04-19 17:21:58.407 DEBUG (MainThread) [homeassistant.components.nanoleaf] Finished fetching Shapes XXXX data in 0.001 seconds (success: False)
2024-04-19 17:22:18.787 DEBUG (MainThread) [homeassistant.components.nanoleaf] Finished fetching Shapes XXXX data in 0.000 seconds (success: False)
2024-04-19 17:22:58.990 DEBUG (MainThread) [homeassistant.components.nanoleaf] Finished fetching Shapes XXXX data in 0.001 seconds (success: False)
2024-04-19 17:24:19.475 DEBUG (MainThread) [homeassistant.components.nanoleaf] Finished fetching Shapes XXXX data in 0.000 seconds (success: False)
Something about the discovery process messes up the manual IPV4 configuration, and it never works again, even after a HA reboot. The only way to get it back is to remove it and re-add it.
I disabled discovery via the Nanoleaf System options after adding my Shapes and so far it's been stable
Hopefully this helps some others having the same issue until we can fix IPV6 use correctly in the integration
@belzedaar may be stupid but can't find the System option you mention, how do you get it?
It is fixed after I upgraded Shapes to the latest firmware 9.4.2
After updating lines from 9.4.2 -> 9.5.0 this fixed itself for me
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.