Nanoleaf outdoor string lights - auth token error
The problem
The new firmware for the nanoleaf outdoor string lights allow them to be connected via API, which allows this nanoleaf HA integration to work.
The problem is that while EVERY other nanoleaf product requires a POST to get the auth token, these string lights require a GET. That causes the integration to fail with Unspecified Error when trying to add the device.
Here is an example of the POST failing to the lights:
curl -v http://192.168.4.33:16021/api/v1/new -X POST
* Trying 192.168.4.33:16021...
* TCP_NODELAY set
* Connected to 192.168.4.33 (192.168.4.33) port 16021 (#0)
> POST /api/v1/new HTTP/1.1
> Host: 192.168.4.33:16021
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 405 Method Not Allowed
< Content-Type: text/html
< Content-Length: 45
<
* Connection #0 to host 192.168.4.33 left intact
Specified method is invalid for this resource
Here is an example of the GET succeeding:
curl -v http://192.168.4.33:16021/api/v1/new
* Trying 192.168.4.33:16021...
* TCP_NODELAY set
* Connected to 192.168.4.33 (192.168.4.33) port 16021 (#0)
> GET /api/v1/new HTTP/1.1
> Host: 192.168.4.33:16021
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/html
< Content-Length: 50
<
* Excess found in a read: excess = 77, size = 50, maxdownload = 50, bytecount = 0
* Connection #0 to host 192.168.4.33 left intact
{"auth_token": "SG7o18JoBcoHc6uDvyWHHUM5Xv5WVl4N"}
Here are the logs from HA showing the integration attempting a POST and receiving a 405 Method Not Allowed error.
Logger: homeassistant.components.nanoleaf.config_flow
Source: components/nanoleaf/config_flow.py:58
integration: Nanoleaf ([documentation](https://www.home-assistant.io/integrations/nanoleaf), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+nanoleaf%22))
First occurred: 7:51:38 AM (5 occurrences)
Last logged: 7:53:33 AM
Unknown error connecting to Nanoleaf
Traceback (most recent call last):
File "/config/deps/homeassistant/components/nanoleaf/config_flow.py", line 58, in async_step_user
await self.nanoleaf.authorize()
File "/usr/local/lib/python3.12/site-packages/aionanoleaf/nanoleaf.py", line 274, in authorize
resp.raise_for_status()
File "/config/deps/aiohttp/client_reqrep.py", line 1157, in raise_for_status
raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 405, message='Method Not Allowed', url='http://192.168.4.33:16021/api/v1/new'
What version of Home Assistant Core has the issue?
core-2024.11.1
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
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:58
integration: Nanoleaf (documentation, issues)
First occurred: 7:51:38 AM (5 occurrences)
Last logged: 7:53:33 AM
Unknown error connecting to Nanoleaf
Traceback (most recent call last):
File "/config/deps/homeassistant/components/nanoleaf/config_flow.py", line 58, in async_step_user
await self.nanoleaf.authorize()
File "/usr/local/lib/python3.12/site-packages/aionanoleaf/nanoleaf.py", line 274, in authorize
resp.raise_for_status()
File "/config/deps/aiohttp/client_reqrep.py", line 1157, in raise_for_status
raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 405, message='Method Not Allowed', url='http://192.168.4.33:16021/api/v1/new'
Additional information
No response
Hey there @milanmeu, @joostlek, 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.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the issue.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.
(message by CodeOwnersMention)
nanoleaf documentation nanoleaf source (message by IssueLinks)
I know ya'll know the codebase for your own work, but just to save you a moment, it looks like this is the location that needs to attempt a GET after the POST fails:
There is a discussion about this in the nanoleaf developer forum for the holiday string lights. This will be fixed by nanoleaf. The firmware currently in beta supports the POST. Perhaps that also fixes the outdoor string lights.
Same issue with nanoleaf Essentials Matter Smart Multicolor HD Lightstrip.
I've been investigating for hours now... and my conclusion is that the problem is definitely on the side of Nanoleaf and not with the Home Assistant integration.
I accessed the HA docker container with root access and replaced the mentioned POST request through a GET request at this location. After fixing an issue with wrong content type of the GET request's response (text/html instead of application/json) I could move one step further, but now error 500.
I moved then to Postman to check out the requests according to https://forum.nanoleaf.me/docs. It is definitely possible to acquire an access token by requesting http://192.168.x.x:16021/api/v1/new when using GET instead of POST. But the next command to get the device information http://192.168.x.x:16021/api/v1/:access_token fails with an internal server error 500.
I don't know what Nanoleaf is doing here and I don't know where to report this findings.
The only way to integrate my nanoleaf Essentials Matter Smart Multicolor HD Lightstrip is with the detour via Google Home, but than I can only select single colors and cannot access the scenes. That makes it almost worthless :-(
Best regards, Andy
There's no need to report any further. The nanoleaf developers already have a fix that's available in the latest beta firmware and will be releasing it soon. Once the fix is released from nanoleaf, this issue will be closed as fixed-in-upstream
For anyone in the need of a workaround until the issue is fixed upstream, connecting the Essentials Holiday String Lights via Matter worked for me!
For anyone in the need of a workaround until the issue is fixed upstream, connecting the Essentials Holiday String Lights via Matter worked for me!
not a real option
Matter does not expose the light effects.
Until the api is fixed to be used with the nanoleaf integration I use Matter for the light control and the "RESTful Command" integration to set the effect and "RESTful Sensor" integration to get the current effect.
Until the api is fixed to be used with the nanoleaf integration I use Matter for the light control and the "RESTful Command" integration to set the effect and "RESTful Sensor" integration to get the current effect.
that's very interesting. by chance, would you be so nice to better explain in detail how did you workarounded like that, answering this thread? This could help a lot.
Good news, bad news.
The good news is that the new firmware for the outdoor string lights fixes the original problem and they now accept a POST to retrieve the auth token.
The bad news is that the integration fails to add them.
First, here's a verification that the API tokens work as expected:
$ curl -X POST http://192.168.4.33:16021/api/v1/new
{"auth_token": "REDACTED"}
$ curl -X PUT 192.168.4.33:16021/api/v1/REDACTED/state -d '{"on":{"value":true}}'
The above turns the lights on correctly.
When trying to add the lights via the integration, I get the following, presumably after the token was successfully retrieved:
Logger: homeassistant.components.nanoleaf.config_flow
Source: components/nanoleaf/config_flow.py:187
integration: Nanoleaf ([documentation](https://www.home-assistant.io/integrations/nanoleaf), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+nanoleaf%22))
First occurred: 4:47:38 PM (3 occurrences)
Last logged: 4:52:41 PM
Unknown error connecting with Nanoleaf at 192.168.4.33
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/nanoleaf/config_flow.py", line 187, in async_setup_finish
await self.nanoleaf.get_info()
File "/usr/local/lib/python3.13/site-packages/aionanoleaf/nanoleaf.py", line 292, in get_info
self._is_on = data["state"]["on"]["value"]
~~~~^^^^^^^^^
KeyError: 'state'
I may have more time to investigate in a few days, but it looks like there's still work to do on the HA side.
Real quick investigation shows that the Outdoor String Lights don't send state with the initial GET /
Here's the response from a skylight:
$ curl -X GET 192.168.4.29:16021/api/v1/REDACTED
{"name":"Skylight 53AF","serialNo":"S23471Q0461","manufacturer":"Nanoleaf","firmwareVersion":"10.0.8","hardwareVersion":"1.4-1","model":"NL64","discovery":{},"effects":{"effectsList":["20 Minute Sunset","Blue Skies","Cosmic Galaxy","Firebird","Full Moon","Gentle Rain","Golden Hour","Late Night","Midnight Mood","Molten Sunrise","Mountain Air","Natural Light","Northern Lights","Ocean","Rain","Shooting Stars","Sun Shower","Sunlight through trees","Tachyon Light2","Vibrant Sunrise"],"select":"*Solid*"},"firmwareUpgrade":{},"panelLayout":{"globalOrientation":{"value":90,"max":360,"min":0},"layout":{"numPanels":12,"sideLength":180,"positionData":[{"panelId":45417,"x":360,"y":360,"o":0,"shapeType":31},{"panelId":36524,"x":360,"y":180,"o":270,"shapeType":30},{"panelId":17833,"x":360,"y":0,"o":270,"shapeType":30},{"panelId":36117,"x":180,"y":0,"o":180,"shapeType":30},{"panelId":43112,"x":0,"y":0,"o":180,"shapeType":30},{"panelId":16640,"x":0,"y":180,"o":90,"shapeType":30},{"panelId":37677,"x":0,"y":360,"o":90,"shapeType":30},{"panelId":39599,"x":360,"y":540,"o":90,"shapeType":30},{"panelId":25907,"x":360,"y":720,"o":90,"shapeType":30},{"panelId":26249,"x":180,"y":720,"o":180,"shapeType":30},{"panelId":40163,"x":0,"y":720,"o":180,"shapeType":30},{"panelId":23001,"x":0,"y":540,"o":270,"shapeType":30}]}},"qkihnokomhartlnp":{},"schedules":{},"state":{"brightness":{"value":98,"max":100,"min":0},"colorMode":"hs","ct":{"value":6500,"max":6500,"min":2700},"hue":{"value":31,"max":360,"min":0},"on":{"value":false},"sat":{"value":85,"max":100,"min":0}}}
Here's the response from the string lights:
$ curl -X GET 192.168.4.33:16021/api/v1/REDACTED
{"name": "Nanoleaf OMSL 19C","serialNo": "V24040OD002L1","manufacturer": "Nanoleaf","firmwareVersion": "3.0.10","hardwareVersion": "1.1.0","model": "NL73K1"}
You can call GET /api/v1/key/state to get the state object, but that's not how the HA integration works.
Going to ping the Nanoleaf devs again to see if they'd be willing to fix on their side.
The authorization process with the authorization process with the Beta version works like a charme, but the GET endpoint only delivers the following information for my device:
{ "name": "Nanoleaf IMLS BB9", "serialNo": "xxxxxxxxxxxxxxxxxxx", "manufacturer": "Nanoleaf", "firmwareVersion": "3.0.10", "hardwareVersion": "1.1.0", "model": "NL72K1" } Neccessary properties like state and effects are missing.
I manually edited the nanoleaf.py Home Assistant integration and inserted the expected data hardcoded. And I could manage to integrate the device in Home Assistant. The effects dropdown on my dashboard works, but I cannot toggle the light on/off nor identity it. The API delivers back a BadRequest 400.
The answer from Nanoleaf:
yes these are known issues. I have reached out to HA already to work with them on this.
There are some changes in the API for the Matter Wifi Essentials device, with reason, so HA will have to make some minor changes.
If I combine my investigations with the one of @rsteckler I assume we could bring it to work when changing nanoleaf.py so that it makes another request to GET /api/v1/key/state and integrate the response into the response from GET /api/v1/key.
But I hope Nanoleaf and the Home Assistent Nanoleaf Integration developers will work on these issues soon together to provide us soon with a working solution.
I've got some news for you guys.
I've got the API documentation of the new beta API that works with Nanoleaf Matter Wifi Essentials devices firmware >= 3.0.10: https://nanoleaf.atlassian.net/wiki/spaces/nlapid/pages/2296381472/Nanoleaf+Matter+WiFi+Essentials+Open+API+Documentation
There are only some minor changes on Nanoleaf's side:
- The ‘/‘ endpoint does not return the state and only returns device information for now --> Use the new '/state' endpoint instead to get on/off state, brightness, hue, saturation, color temperate and color mode. --> Use the endpoint '/effects' to get current selected effect and effects list
- Effects use the hexPalette field instead of just palette.
- Events are not supported
- GET on /effects is not supported.
--> Instead send a PUT request to effects with the payload
{"write":{"command":"requestAll"}}*
The official Nanoleaf integration component relys on the python package https://github.com/jonathanrobichaud4/aionanoleaf which communicates locally with the Nanoleaf API.
I forked aionanoleaf to adjust the above described changes. There are only changes to the nanoleaf.py file.
With these changes the integration of my Nanoleaf Matter Essentials HD Light Strip in Home Assistant was successful and will propably also be for the Outdoor string lights and any newer devices from Nanoleaf (that have at least firmware 3.0.10 installed). I can get and control the states from within HA and also select the available effects.
The package will still support the older devices and gets the state of the newer devices by calling GET /state and GET /effects/select if states are missing retrieved by calling GET /.
But unfortunately there are two drawbacks at the moment:
-
When setting a new state on the light, Home Assistant shows a toast message with an error, although the command works on the light. After longer investigations I realized a change between the HTTP responses from the older and newer devices. The new device doesn't set the
Content-Length: 0header in its HTTP response and specifies the headerTransfer-Encoding: chunked. I assume that this fact leads to these errors. A request concerning this has already been sent to Nanoleaf. I'll stay tuned. -
The auto discovery works, but after successful integration it detects the same device another time. I just ignore this message in HA. No big deal, but I won't win any beauty contests with it ;-)
BTW: The original aionanoleaf package is from @milanmeu, but has been forked by @jonathanrobichaud4. In the current Home Assistant version (2025.1.2) the fork of Jonathan is used. This fork of Jonathan brings some basic support for the Nanoleaf 4D screenmirroring which I use with success in my household. It was also @jonathanrobichaud4 who released a HA custom component ha-nanoleaf-4d that supports the 4D effect. I don't know why the fork of aionanoleaf is already part of Home Assistant, but the custom component is not. The custom component you have to install manually or by using HACS. This is just b-side info, but it explains why I forked the fork of Jonathan and not the original repository.
I hope to get soon some positive news from Nanoleaf on my first drawback (or from one of you guys). And if I/we will succeed with eliminating the drawbacks, let's go get merged this into the master (and finally into Home Assistant). It would also be nice to hear something of the official Home Assistant integration owners @milanmeu and @joostlek.
Best regards Andy
I don't think my package is used in homeassistant itself. With custom components you can also use custom libraries which I did fork to make aionanoleaf4d. So if you're using the custom component it would replace the original library I think? I haven't really been paying attention to what's been going on because of school and life
Still the issue here with NL73K1 (Essentials Matter Smart Multicolor outdoor), and I don't understand how I can use the fork from @loebi-ch . Do someone know if this will be solved someday?
becoming hopeless.
Same problem here. My light strings can't connect trough the nanoleaf api.
Logger: homeassistant.components.nanoleaf.config_flow Bron: components/nanoleaf/config_flow.py:191 integratie: Nanoleaf (documentatie, problemen) Eerst voorgekomen: 5 maart 2025 om 21:49:30 (3 gebeurtenissen) Laatst gelogd: 19:54:33 Unknown error connecting with Nanoleaf at 192.175.0.151 Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/nanoleaf/config_flow.py", line 191, in async_setup_finish await self.nanoleaf.get_info() File "/usr/local/lib/python3.13/site-packages/aionanoleaf/nanoleaf.py", line 292, in get_info self._is_on = data["state"]["on"]["value"] ~~~~^^^^^^^^^ KeyError: 'state'
Can connect trough matter, but functionality is almost nothing compared to the nanoleaf app.
I hope it will be solved one day. I exactly reported the problems to the software director from Nanoleaf and he agreed on that, but still waiting for them to solve the issues on Nanoleaf side before continueing my fork and hopefully merge it one day into the productive HA...
To use my fork just copy the code to /config/aionanoleaf. Home Assistant uses then the aionanoleaf in your config instead of the original one...
The fork works great to add the new Nanoleaf Matter devices to HA and use the devices in automations. But when using it with tiles in the dashboard you get an error displayed although it works. That's a bug on Nanoleaf side which I reported in January and stiḷl waiting to be solved.
Btw: You need to have the Beta Firmware 3.0.10 on your Nanoleaf device.
Hope that there will be some better news shortly.
Best regards Andy
Thanks a lot for your detailed procedure. I was able to successfully add the lights, but now the lights effects are buggy, even when I only use the Android app :-( Maybe it's because my lights are running firmware 3.0.23?
I think I'll fall back to Matter control :-(
What do you mean with buggy? Can you explain a little more in detail please? And which Android app (Nanoleaf or HA)?
How do you got/install the firmware 3.0.23? I'm still running 3.0.10 and I have no clue how to get a newer one...
My device is the NL72K1... I think that there should no be big differences but that's just an assumption.
Once I paired the device in HA, the lights keep flashing all the time, without me doing anything. The android Android app I'm refering to is the Nanoleaf one.
My device is: NL73K1 Firmware: 3.0.23 Hardware: 1.1.0
I just used the official app and accept any update that was proposed...
Seeing the same error as @Jurgen-DOUCHY when trying to pair my Matter Smart Multicolor Floor Lamp
Commenting to monitor progress, as I'm also having trouble.
I only recently bothered to check the Nanoleaf app for updates and updated my outdoor string lights to v3.0.23, at which point they we discovered in Home Assistant. I tried to add them using the normal process, but discovered there is now a "Connect to API" option in the app instead of the old button press procedure (which is nice as it saved me going outside).
Unfortunately it still won't pair with the Nanoleaf Integration, as I get an unknown error.
same here with different Nanoleaf Matter solutions using 3.0.23 fw, the one which introduced API support, but still not working.
Hi Gents,
I faced the same issues as you. However, since I had previously programmed my automation in Python, I decided to transfer (together with AI) that know-how to Home Assistant and created an integration for it. It might still be somewhat in beta, but it's working for me with the Nanoleaf Essentials HD NL72K1, error free integrated and accessed via API (WLAN/IP) network from HA as a custom integration called nanoleaf-essentials.
If there is any interest find the custom integration here - all mentioned problems are addressed and fixed in there: https://github.com/mcaonline/nanoleaf-essentials-hass
If there is any interest find the custom integration here - all mentioned problems are addressed and fixed in there: https://github.com/mcaonline/nanoleaf-essentials-hass
Curious to try, but is looks like hacs does not accept the url of your repository. Probably the .io on the back?
UPDATE: The integration above is now complete and submitted to HACS! 🎉
Current Status:
- ✅ Integration fully developed and tested
- ✅ HACS Pull Request submitted
- ✅ Manual installation available and working
- ✅ Community can use it immediately
Repository: https://github.com/mcaonline/nanoleaf-essentials-hass
For anyone facing Nanoleaf Essentials (Multicolor HD and myabe more products) issues: You can now install this integration manually while waiting for HACS approval. It solves all the POST/GET API problems mentioned in this issue.
The integration includes robust error handling, HTML response parsing, and works reliably with Nanoleaf Essentials devices. Installation instructions are in the README.
Great to see a new integration for the matter essential lights, thank you!
I'll try it out as soon as it is available via hacs.
What firmware version is your lightstrip running on?