Nanoleaf per tile light control build in HA

Are there any plans on expanding the nanoleaf core integration? At the moment i use a restcommand to control my individual element panels on my nanoleaf setup. this works but is a pain to setup in automations. It would be great if the integration has a detection build in which gets all the panel id’s and sets them up as individual lights in home assistant or groups them in the integration so that they can be individually controlled.

at the moment this is my rest command:

nanoleaf:
  url: http://192.168.178.86:16021/api/v1/hih87hn076565rfv7/effects
  method: PUT
  payload: >
    { "write" : {"command": "display", "animType": "static", "animData":
    {%- set all = [ 36776, 40379, 39889, 47065, 62644, 56943, 44929, 4212, 50749, 42705, 55753, 9801, 2975, 5181, 59276, 33852, 34713, 42845 ] %}
    {%- set ns = namespace(panels=[panels | count | string]) %}
    {%- for panel in panels %}
    {%- set ns.panels = ns.panels + [ '{} 1 {} {} {} 0 20'.format(all[panel.number-1], panel.r, panel.g, panel.b) ] %}
    {%- endfor %}
    "{{ ns.panels | join(' ') }}",
    "loop": false, "palette": [], "colorType": "HSB"}
    }
  content_type: 'application/json'

i can control the individual lights by putting this in the automation:

- id: '1618492041197'
  alias: Nanoleaf post
  description: ''
  trigger:
  - platform: state
    entity_id: input_select.post
    to: Er is post
  condition:
  - condition: state
    entity_id: input_boolean.niet_storen
    state: 'off'
  action:
  - service: scene.create
    data:
      scene_id: nanoleaf_voordat
      snapshot_entities:
      - light.woonkamer_nanoleaf
  - service: rest_command.nanoleaf
    data:
      panels:
      - number: 1
        r: 100
        g: 0
        b: 100
      - number: 2
        r: 0
        g: 0
        b: 0
  mode: single

With this i can set panel 1 to 18 to have a specific color on the R,G and B spectrum the number goes from 0 to 255 and with this i can set the brightness as wel. Setting R to 125 is half brightness red and R 255 is full brightness.

Maybe this can help the person who build this in expanding the integration. The panels do have all the open api support to implement all the panels individually. There is an api call to get all the panel id’s and with the code i provided these panels can be set to have a specific color and brightness. So in theory it should be possible to expand the integration and let HA add all the panels as individual lights.

nice.

    {%- set all = [ 36776, 40379, 39889, 47065, 62644, 56943, 44929, 4212, 50749, 42705, 55753, 9801, 2975, 5181, 59276, 33852, 34713, 42845 ] %}

Are these the id’s of the panels? If so you do you get them? I have 18 nanoleaf aurora panels and want try this myself :slight_smile:

i use node-red to get the panel id’s with a http request node. in this node you set this:

method get

url: http://192.168.178.86:16021/api/v1/[api key here without the]

if you did this right you get something like this:

Nanoleaf has a very extensive webpage where this all is explained in detail on how to get info, api key etc etc.

Its nothing more then putting this in a flow and readout the debug node on the right:

So there must be an easy way to implement this info into home assistant and control them as individual lights. the problem is that i do not have the knowhow to write or rewrite integrations. So if the person that have written it could edit the code i am willing to provide all the info i have. and even test it out for them.

The panels even have location data (x,y and o) that is stored to being able to know where they are in the chain.

It would be amazing if in home assistant a maplayout would load after you could just select a tile and control the rgb on it. but if they could only be addressed as individual lights in ha would allready be amazing.

1 Like

Great!!! I got my output. Print my layout and add the numbers.

Now I can control the panels also. Thanks for the help!!

Thanks so much your example help me a lot.
Do you have an idea on how to put back the latest selected effect after for example 5 minutes ?

I think I can get the effect name with
curl --location ‘http://192.168.x.x:16021/api/v1/Add-a-user-to-generate-auth-token/effects/select

like

  - platform: rest
    name: nanoleaf-previous_record
    resource: http://192.168.x.x:16021/api/v1/Add-a-user-to-generate-auth-token/effects/select
    method: GET
    value_template: "{{ value_json }}"

and to put the effect back with

rest_command:
  nanoleaf-put_back:
    url: http://192.168.x.x:16021/api/v1/Add-a-user-to-generate-auth-token/effects
    method: PUT
    payload: >
      { "select" : sensor.nanoleaf_previous_record }
    content_type: 'application/json'

But there it is clearly not correct …

The problem I think is that when you set the RGB colors on tiles the nano leaf base will report it as “unknown” effect. So if you get the current effect it will save unknown.

I use this last time with Eurovision. Added all countries flags into automation. And shorten the code. This is how I have every tile his collar:

            - service: rest_command.nanoleaf
              data:
                panels:
                  [ 
                    {"number": 2,"r": 0,"g": 100,"b": 0},
                    {"number": 3,"r": 0,"g": 100,"b": 0},
                    {"number": 4,"r": 100,"g": 100,"b": 0},
                    {"number": 5,"r": 100,"g": 100,"b": 0},
                    {"number": 6,"r": 100,"g": 50,"b": 0},
                    {"number": 7,"r": 100,"g": 50,"b": 0},
                    {"number": 8,"r": 100,"g": 0,"b": 0},
                    {"number": 9,"r": 100,"g": 0,"b": 0},
                    {"number": 10,"r": 100,"g": 100,"b": 0},
                    {"number": 1,"r": 0,"g": 0,"b": 100},
                    {"number": 11,"r": 0,"g": 0,"b": 100},
                    {"number": 12,"r": 0,"g": 0,"b": 50},
                    {"number": 13,"r": 50,"g": 0,"b": 50},
                    {"number": 14,"r": 50,"g": 0,"b": 50},
                    {"number": 15,"r": 100,"g": 100,"b": 100},
                    {"number": 16,"r": 100,"g": 0,"b": 100},
                    {"number": 17,"r": 0,"g": 75,"b": 100},
                    {"number": 18,"r": 50,"g": 25,"b": 25}
                  ]