Nanoleaf Elements Integration Failed to Connect

I’m trying to link Nanoleaf Elements to Home Assistant 2022.4.7 running on a Raspberrry Pi. Whenever I try and add either set of Elements, I get a Failed To Connect error:

I’ve been struggling because most help posts re: nanoleaf are quite old and reference solutions not currently in the documentation (one involves manual config and tokens, but the manual config in the current documentation is about adding the integration manually)
I found a similar sounding bug here. so I added the folder from that thread to my config folder but no joy.
I can connect to the Elements using the Nanoleaf Android app fine.
It’s worth mentioning I’m not particularly competent - HA is by far the most complex IT system I’ve had to engage with for over a decade.

Logs!

Traceback (most recent call last):

File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn

conn = connection.create_connection(

File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 95, in create_connection

raise err

File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 85, in create_connection

sock.connect(sa)

OSError: [Errno 101] Network unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 703, in urlopen

httplib_response = self._make_request(

File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 398, in _make_request

conn.request(method, url, **httplib_request_kw)

File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 239, in request

super(HTTPConnection, self).request(method, url, body=body, headers=headers)

File "/usr/local/lib/python3.9/http/client.py", line 1285, in request

self._send_request(method, url, body, headers, encode_chunked)

File "/usr/local/lib/python3.9/http/client.py", line 1331, in _send_request

self.endheaders(body, encode_chunked=encode_chunked)

File "/usr/local/lib/python3.9/http/client.py", line 1280, in endheaders

self._send_output(message_body, encode_chunked=encode_chunked)

File "/usr/local/lib/python3.9/http/client.py", line 1040, in _send_output

self.send(msg)

File "/usr/local/lib/python3.9/http/client.py", line 980, in send

self.connect()

File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 205, in connect

conn = self._new_conn()

File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn

raise NewConnectionError(

urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f8a59dd60>: Failed to establish a new connection: [Errno 101] Network unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 440, in send

resp = conn.urlopen(

File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 785, in urlopen

retries = retries.increment(

File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 592, in increment

raise MaxRetryError(_pool, url, error or ResponseError(cause))

urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.68.107', port=80): Max retries exceeded with url: /app (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8a59dd60>: Failed to establish a new connection: [Errno 101] Network unreachable'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform

await asyncio.shield(task)

File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run

result = self.fn(*self.args, **self.kwargs)

File "/config/custom_components/tapo_p100_control/switch.py", line 44, in setup_platform

add_entities([P100Plug(p100)])

File "/config/custom_components/tapo_p100_control/switch.py", line 53, in __init__

self.update()

File "/config/custom_components/tapo_p100_control/switch.py", line 83, in update

self._p100.handshake()

File "/usr/local/lib/python3.9/site-packages/PyP100/PyP100.py", line 122, in handshake

r = self.session.post(URL, json=Payload, timeout=2)

File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 577, in post

return self.request('POST', url, data=data, json=json, **kwargs)

File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 529, in request

resp = self.send(prep, **send_kwargs)

File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 645, in send

r = adapter.send(request, **kwargs)

File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 519, in send

raise ConnectionError(e, request=request)

requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.68.107', port=80): Max retries exceeded with url: /app (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8a59dd60>: Failed to establish a new connection: [Errno 101] Network unreachable'))

2022-04-30 00:27:33 ERROR (SyncWorker_3) [custom_components.tapo_p100_control.switch] Could not connect to plug. Possibly invalid credentials

2022-04-30 00:27:33 ERROR (MainThread) [homeassistant.components.switch] Error while setting up tapo_p100_control platform for switch

Traceback (most recent call last):

File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn

conn = connection.create_connection(

File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 95, in create_connection

raise err

File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 85, in create_connection

sock.connect(sa)

OSError: [Errno 101] Network unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 703, in urlopen

httplib_response = self._make_request(

File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 398, in _make_request

conn.request(method, url, **httplib_request_kw)

File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 239, in request

super(HTTPConnection, self).request(method, url, body=body, headers=headers)

File "/usr/local/lib/python3.9/http/client.py", line 1285, in request

self._send_request(method, url, body, headers, encode_chunked)

File "/usr/local/lib/python3.9/http/client.py", line 1331, in _send_request

self.endheaders(body, encode_chunked=encode_chunked)

File "/usr/local/lib/python3.9/http/client.py", line 1280, in endheaders

self._send_output(message_body, encode_chunked=encode_chunked)

File "/usr/local/lib/python3.9/http/client.py", line 1040, in _send_output

self.send(msg)

File "/usr/local/lib/python3.9/http/client.py", line 980, in send

self.connect()

File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 205, in connect

conn = self._new_conn()

File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn

raise NewConnectionError(

urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f94f4ed60>: Failed to establish a new connection: [Errno 101] Network unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 440, in send

resp = conn.urlopen(

File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 785, in urlopen

retries = retries.increment(

File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 592, in increment

raise MaxRetryError(_pool, url, error or ResponseError(cause))

urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.68.108', port=80): Max retries exceeded with url: /app (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f94f4ed60>: Failed to establish a new connection: [Errno 101] Network unreachable'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform

await asyncio.shield(task)

File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run

result = self.fn(*self.args, **self.kwargs)

File "/config/custom_components/tapo_p100_control/switch.py", line 44, in setup_platform

add_entities([P100Plug(p100)])

File "/config/custom_components/tapo_p100_control/switch.py", line 53, in __init__

self.update()

File "/config/custom_components/tapo_p100_control/switch.py", line 83, in update

self._p100.handshake()

File "/usr/local/lib/python3.9/site-packages/PyP100/PyP100.py", line 122, in handshake

r = self.session.post(URL, json=Payload, timeout=2)

File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 577, in post

return self.request('POST', url, data=data, json=json, **kwargs)

File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 529, in request

resp = self.send(prep, **send_kwargs)

File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 645, in send

r = adapter.send(request, **kwargs)

File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 519, in send

raise ConnectionError(e, request=request)

requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.68.108', port=80): Max retries exceeded with url: /app (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f94f4ed60>: Failed to establish a new connection: [Errno 101] Network unreachable'))

2022-04-30 00:27:39 ERROR (MainThread) [aionanoleaf.nanoleaf] You are using a test version of aionanoleaf to fix issue 67816

Hello

I have all the nanoleafs running on my setup and they’ve all been integrated to HA within the last 3 months. I’ve not seen the issue you’re showing and the built in integration for Nanoleaf/HA is one of the slickest I’ve seen for detecting/connecting.

I don’t mean to insult your intelligence, I’m just trying to figure out your level of familiarity with the device…I know you said most of the info you found was for the old config. When you went to connect the device in HA, did you put the elements in pairing mode and get the flashing lights on the elements control panel?

From the screenshot it looks the same as when it times out and I want to rule out the most obvious thing first.

1 Like

Dude, it absolutely makes sense to make sure I’m not making some extremely basic error. I very possibly am, and I really appreciate the kindness of your reply.

So, as far as I can tell - yes, I put the Elements into pairing. But I took a quick video of the issue in case I’m doing it in entirely the wrong way.

1 Like

An interesting development is - HA now won’t discover my alt set of Elements, only 80F4. I didn’t make any changes to the network, and I can still access both Elements through the Nanoleaf app, but I’m wondering if the problem might be with my network. I have a Deco Mesh installed because I live in what is essentially a 1950s bomb shelter but the Elements might be struggling with it.

-update-
I did a soft refresh on the Elements, no change.
The HA logs were complaining about some custom integrations so I disabled evrything which wasn’t necessary, no change (although HA is complaining about a Tapo intergration which I turned off)

2022-04-30 13:15:38 ERROR (SyncWorker_2) [custom_components.tapo_p100_control.switch] Could not connect to plug. Possibly invalid credentials
2022-04-30 13:15:38 ERROR (MainThread) [homeassistant.components.switch] Error while setting up tapo_p100_control platform for switch

So in general I’m stumped. I’m going to be extremely pleased if it turns out I’ve been trying to pair this the wrong way

From the video, you’re definitely following the correct steps so we’ve ruled that out!

Nanoleaf CAN be temperamental with a complex network so you may be onto something. I have a Shapes unit that STILL has a funny setup process but works fine otherwise. I have a Ubiquiti network with multiple access points.

I think it has something to do with the way Nanoleaf recognizes the networks. It recognizes them as separate but because they all have the same name, sometimes it freaks out and doesn’t communicate correctly. I had to provision another wireless network that i call nanoleaf and I connected that ONE device to it. It’s still all part of the same network but for some reason, the device plays nicer when it doesn’t have the same network name. I have only one nanoleaf device that insists on being setup this way and I don’t know why. I’ve tried numerous times to move this device back to the main network and every time I do, I have issues.

I’m only minimally good at reading logs so unfortunately I can’t get anything useful out of the logs you provided. From everything you’ve shown me, this should work.

I am an Android user but I know using an apple device with nanoleaf in the mix can cause issues (it tries to replicate the device because of homekit). I’m guessing you’re android only.

1 Like

Awesome. I think we can assume that the problem is with Nanoleaf and networks rather than Home Assistant, so I’ll focus on that for now. Thanks for your help so far!

Ok, I found the solution - As per @Sergeantpup I pared back my network - I still had my basic network running (as opposed to my Deco Mesh), so I factory reset both sets of elements and coaxed them onto that network instead. It still took a little prodding but I eventually got them onto Home Assistant wooo

1 Like

now if you want some cool randomizers/scripts for your nanoleafs let me know!

1 Like

Thanks, that’d be great

Hello,

I saw you have a SONOS from an above screenshot so I’m going to show an example with a SONOS for the music stuff but you can swap it out for something other than SONOS if you want.

Putting these in scripts makes them easier to hook to triggers later. Here is an effect randomizer that ONLY randomizes NON-music effects:

alias: 'Lines: Effect Randomizer'
sequence:
  - service: light.turn_on
    target:
      device_id: 29a555e40c88a24d83c07dd17ee6491d
    data:
      effect: >-
        {{ ["Aurora Borealis", "Checkerboard", "Cherry Blossoms", "Chill Vibes",
        "Colored Snakes", "Earthtone", "Holodek", "Jade Palace", "Northern
        Lights", "Lines Purple Sun", "Radioactive", "Relaxing Neon", "Retro
        Future", "Scary Night Forest", "Sea of Thieves", "Sparrows", "Starry
        Night", "Sunlight Through Trees", "Matrix"] | random }}
mode: single
icon: mdi:triangle-outline

Here is a randomizer that randomizes ONLY the music effects:

alias: 'Lines: Music Effect Randomizer'
sequence:
  - service: light.turn_on
    target:
      device_id: 29a555e40c88a24d83c07dd17ee6491d
    data:
      effect: >-
        {{ ["Music Cotton Candy", "Music Jalapeno Heat", "Music Pop Rocks",
        "Music Pulse Pop Beats"] | random }}
mode: single
icon: mdi:triangle-outline
alias: Nanoleafs Randomizer
description: ''
trigger:
  - platform: time_pattern
    minutes: '30'
condition:
  - condition: and
    conditions:
      - condition: state
        entity_id: input_boolean.house_awake
        state: 'on'
      - type: is_open
        condition: device
        device_id: b1c35c134c59dd8979a12b3c488e301e
        entity_id: binary_sensor.bedroom_door_contact_sensor
        domain: binary_sensor
      - type: is_open
        condition: device
        device_id: 253da192a574953187a6ffa226818201
        entity_id: binary_sensor.bedroom_2_door_contact_sensor
        domain: binary_sensor
      - condition: time
        before: '21:45:00'
        after: '08:00:00'
action:
  - service: script.randomizer_control
    data: {}
mode: single

I know it’s calling another script I haven’t shown but all that script does is aggregate the randomizers because I have so many:

alias: All Nanoleaf Effects Randomizer
sequence:
  - service: script.1642351975423
    data: {}
  - service: script.canvas_effect_randomizer
    data: {}
  - service: script.shapes_effect_randomizer
    data: {}
  - service: script.woodleaf_randomizer
    data: {}
  - service: script.lines_effect_randomizer
    data: {}
mode: single
icon: mdi:shape-plus

At this point, it’s during the day and the house is awake, each of the nanoleafs get’s it’s randomizer script triggered every 30 mins. But now I want to play music and make the lights do dumb stuff:

I have an independent SONOS in each room that has a nanoleaf so I have them all independently tied like this:

alias: Lines Music Effects
description: ''
trigger:
  - platform: device
    device_id: 44c16384ae6ac4d727a6f458c9ffbd85
    domain: media_player
    entity_id: media_player.media_room_sonos
    type: playing
  - platform: device
    device_id: 44c16384ae6ac4d727a6f458c9ffbd85
    domain: media_player
    entity_id: media_player.media_room_sonos
    type: paused
condition:
  - condition: time
    before: '21:44:00'
    after: '08:00:00'
action:
  - choose:
      - conditions:
          - condition: device
            device_id: 44c16384ae6ac4d727a6f458c9ffbd85
            domain: media_player
            entity_id: media_player.media_room_sonos
            type: is_playing
        sequence:
          - service: script.lines_music_effect_randomizer
            data: {}
      - conditions:
          - condition: device
            device_id: 44c16384ae6ac4d727a6f458c9ffbd85
            domain: media_player
            entity_id: media_player.media_room_sonos
            type: is_paused
        sequence:
          - service: script.lines_effect_randomizer
            data: {}
    default: []
mode: single

It detects when music is playing during conditions and then hits the music effects randomizer. When the music stops, the automation hits the non-music effect randomizers to basically put everything back to normal and the regular randomizer just picks up in the next 30 mins.

There’s a gap in this automation if you are on a music randomizer and the other randomizer is still running it will change your music effect to a non-music effect but this is hardly noticeable and wasn’t worth me fixing but if you are rebuilding it, it would be easy for you to add that protection. I think sonos detects a track change as music playing anyway so I’ve never noticed the non music randomizer overriding it, but again this would be an easy fix if one were so inclined.

At 945p all randomizers are outside their timeblock and won’t fire, then all nanoleafs go into a low light red night mode until the house completely shuts down.

Because everything is done with scripts I have buttons on my dashboards that can basically call all the randomizers at will (useful feature down the road).

I have an alexa routine that will call the randomizers when I pretend I’m Castor from Tron and say “alter the mood, change the scheme!”

I’m testing some adaptive lighting for the nanoleafs. I’ve tried multiple things including actual adaptive lighting but because Nanoleaf can be so freaking blinding, it doesn’t work well if it gets cloudy in real life vs the adaptive GPS schedule. If you have light sensors, let me know and I can provide it.