[nanoleaf] Nanoleaf Aurora binding (just started development, collecting requirements)

I checked the logfile yesterday, but there was nothing. Now, with loglevel debug it has only this:

2019-04-23 22:20:49.061 [DEBUG] [ery.NanoleafMDNSDiscoveryParticipant] - Nanoleaf Type: NL22
2019-04-23 22:20:49.065 [DEBUG] [ery.NanoleafMDNSDiscoveryParticipant] - Nanoleaf found: 192.168.0.40 16021
2019-04-23 22:20:49.068 [DEBUG] [ery.NanoleafMDNSDiscoveryParticipant] - Adding Nanoleaf lightpanels to inbox: 62D0E39E8239 at 192.168.0.40
2019-04-23 22:20:49.070 [DEBUG] [ery.NanoleafMDNSDiscoveryParticipant] - Nanoleaf Type: NL22

There is an older error in the logfile, but it’s from the time when I was still playing around with the items/control.

2019-04-22 21:21:24.165 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHa                                                ndler.handleCommand()' on 'org.openhab.binding.nanoleaf.internal.handler.NanoleafHandler@1b836fd': Unhandled command typ                                                e
org.openhab.binding.nanoleaf.internal.NanoleafException: Unhandled command type
        at org.openhab.binding.nanoleaf.internal.handler.NanoleafHandler.sendEffectCommand(NanoleafHandler.java:148) ~[?                                                :?]
        at org.openhab.binding.nanoleaf.internal.handler.NanoleafHandler.handleCommand(NanoleafHandler.java:189) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.j                                                ava:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]
        at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [102:o                                                rg.eclipse.smarthome.core:0.10.0.oh240]
        at com.sun.proxy.$Proxy138.handleCommand(Unknown Source) [212:org.openhab.binding.nanoleaf:2.5.0.201901190212]
        at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java                                                :75) [109:org.eclipse.smarthome.core.thing:0.10.0.oh240]
        at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfil                                                e.java:49) [109:org.eclipse.smarthome.core.thing:0.10.0.oh240]
        at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.j                                                ava:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]
        at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [102:org.eclipse.smarthome.cor                                                e:0.10.0.oh240]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
        at java.lang.Thread.run(Thread.java:748) [?:?]

But I doubt that it has an effect here?

Just to be sure, I restarted the openhab service. After it was back online, I tested whether the binding works and then tried the scan again, three times. The first time nothing happened (maybe openhab still starting up?) the two other times are in the log.

2019-04-23 22:26:51.901 [DEBUG] [eaf.internal.handler.NanoleafHandler] - Received channel: nanoleaf:lightpanels:62D0E39E8239:power, command: OFF
2019-04-23 22:26:52.136 [DEBUG] [eaf.internal.handler.NanoleafHandler] - API response code: 204
2019-04-23 22:26:54.745 [DEBUG] [eaf.internal.handler.NanoleafHandler] - Received channel: nanoleaf:lightpanels:62D0E39E8239:power, command: ON
2019-04-23 22:26:55.004 [DEBUG] [eaf.internal.handler.NanoleafHandler] - API response code: 204
2019-04-23 22:27:15.001 [DEBUG] [eaf.internal.handler.NanoleafHandler] - Update channels for light panels nanoleaf:lightpanels:62D0E39E8239
2019-04-23 22:27:15.024 [DEBUG] [eaf.internal.handler.NanoleafHandler] - API response code: 200
2019-04-23 22:27:38.713 [DEBUG] [ery.NanoleafMDNSDiscoveryParticipant] - Nanoleaf Type: NL22
2019-04-23 22:27:38.719 [DEBUG] [ery.NanoleafMDNSDiscoveryParticipant] - Nanoleaf found: 192.168.0.40 16021
2019-04-23 22:27:38.722 [DEBUG] [ery.NanoleafMDNSDiscoveryParticipant] - Adding Nanoleaf light panels to inbox: 62D0E39E8239 at 192.168.0.40
2019-04-23 22:27:38.726 [DEBUG] [ery.NanoleafMDNSDiscoveryParticipant] - Nanoleaf Type: NL22
2019-04-23 22:27:53.920 [DEBUG] [ery.NanoleafMDNSDiscoveryParticipant] - Nanoleaf Type: NL22
2019-04-23 22:27:53.925 [DEBUG] [ery.NanoleafMDNSDiscoveryParticipant] - Nanoleaf found: 192.168.0.40 16021
2019-04-23 22:27:53.929 [DEBUG] [ery.NanoleafMDNSDiscoveryParticipant] - Adding Nanoleaf light panels to inbox: 62D0E39E8239 at 192.168.0.40
2019-04-23 22:27:53.932 [DEBUG] [ery.NanoleafMDNSDiscoveryParticipant] - Nanoleaf Type: NL22
2019-04-23 22:28:15.051 [DEBUG] [eaf.internal.handler.NanoleafHandler] - Update channels for light panels nanoleaf:lightpanels:62D0E39E8239
2019-04-23 22:28:15.071 [DEBUG] [eaf.internal.handler.NanoleafHandler] - API response code: 200

Can I manually look for the IDs? I found another thread with an URL where you supposedly see them, but that just returns a blank page in my browser (yes, I changed the ip from the example).

To add the panels manually, you could follow these steps:

  • Get the controller auth token by calling the openhab REST API with http(s)://<your_openhab-ip:port>/rest/things
  • Search in the response for the string authToken which will give you the Nanoleaf controller thing auth token
  • In a browser/REST client, call http://<your-nanoleaf-ip:port>/api/v1/<auth_token>/
  • You will get back a JSON-formatted response which contains an array of all your panels, something like

... "panelLayout":{"layout":{"numPanels":14,"sideLength":150,"positionData":[{"panelId":135,"x":0,"y":173,"o":300,"shapeType":0}, ...

  • panelId (135 in the example above) refers to the id you have to specify as the id attribute of the lightpanel thing(s) in your Thing file

I will also check the pairing of panels again with my device to see if I run into the same issues


Best regards
Martin

Hey there =)

I am confused on where to put the ID in. Is it possible to do it in the Paper UI?

Is this an old version of the Binding I have? It says its 2.5.0. Or do I have to do it via a file in the Editor?
If so can you please share a screenshot on what to add? Especially for the Individual Light Panels.

Thanks!

You can check out the binding documentation which has an example of a thing file which contains the controller/bridge definition with two (light)panels. The id is set as a configuration parameter [ id=... ] on each lightpanel thing type.

Thanks for the advice. Works perfectly!

One last thing: there is a spelling mistake in the binding documentation: it says nanolead-rules

Is this binding usable with OH 2.3.0 or do i need a later version?

So just tried to add the jar to my 2.3.0 and see if i can make it work. It appears i cant 


At first i added it via Paper UI, which lead to a controller that was usable (tested with power channel). I could not discover any panels however. The solution this thread provides is to add all things as text files.
I cant add the controller as things file properly though, the port and ip adress are always missing in paper ui (when i look at it). The thing is shown as offline.
I see the following error: “2019-07-12 23:19:11.825 [ERROR] [eaf.internal.handler.NanoleafHandler] - URI could not be parsed with path /api/v1/” The token is correct.

Sidenote: if i use the string “nanoleaf:controller:MyLightPanels” from the documentation i get alot exceptions in my logs, and if i use “nanoleaf:lightpanels:MyLightPanels” i only get the above error regarding the API call.

Is this because im on 2.3.0? Or is there any point i am missing?

Hi Martin

I have a question regarding the Nanoleaf binding - good job by the way - it’s this:
I downloaded the binding and copied the .jar file to /usr/share/openhab2/addons which caused it to pop up in the Paper UI inbox from where I was able to activate it, it automagically detected the Canvas I had on-line and after pairing the panels activated the control in Paper UI - this is where I became confused - I could switch the panels on and off, control brightness and colour from Control but could not activate any additional functions.
I created the .map in transform, the sitemap, items and the thing and I could control all of the functions - the question is why? Does it require both the thing I created and the thing which automagically appeared or is there a way I can massage them into a single thing?

I have not defined anything in .things. (auto-discover only)

My .items looks like:

Switch CanvasKitchenPower       (kitchen) { channel = "nanoleaf:controller:9F276836E179:power" }
Color CanvasKitchenColor                  { channel = "nanoleaf:controller:9F276836E179:color" }
Dimmer CanvasKitchenTempSlider            { channel = "nanoleaf:controller:9F276836E179:colorTemperature" }
Number CanvasKitchenTempAbs               { channel = "nanoleaf:controller:9F276836E179:colorTemperatureAbs" }
String CanvasKitchenColorMode             { channel = "nanoleaf:controller:9F276836E179:colorMode" }
String CanvasKitchenEffect                { channel = "nanoleaf:controller:9F276836E179:effect" }
Switch CanvasKitchenRhythmState           { channel = "nanoleaf:controller:9F276836E179:rhythmState" }
Switch CanvasKitchenRhythmActive          { channel = "nanoleaf:controller:9F276836E179:rhythmActive" }
Number CanvasKitchenRhythmMode            { channel = "nanoleaf:controller:9F276836E179:rhythmMode" }

Number CanvasTouchId      (canvasTouch)
Number CanvasTouchGesture (canvasTouch) 

Example rule:

rule "Nanoleaf touch"
when
    Member of canvasTouch received update
then
    logInfo("CanvasTouch", triggeringItem.name + " State=" + triggeringItem.state)

    switch(triggeringItem.name) {
        case "CanvasTouchId":{  
          logInfo("CanvasTouch", "PanelId=" + triggeringItem.state + " gesture=" + CanvasTouchGesture.state)
          switch(triggeringItem.state) {
              case 22092: {
                  CanvasKitchenPower.sendCommand(if (CanvasKitchenPower.state==ON) OFF else ON)
                  if (CanvasKitchenPower.state==OFF) {
                      CanvasKitchenColor.sendCommand(100)
                      CanvasKitchenEffect.sendCommand("Fray")
                  }
              }
              case 15141: {
                  CanvasKitchenColor.sendCommand(25)
                  CanvasKitchenEffect.sendCommand("WhiteDimmed")
              }
              case 42426: {
                  BuildInKjokkenBench.sendCommand(if (BuildInKjokkenBench.state==ON) OFF else ON)
              }
              case 42633: {
                  if (CanvasKitchenEffect.state != "Meteor Shower") {
                    CanvasKitchenEffect.sendCommand("Meteor Shower")
                    BuildInKjokkenBench.sendCommand(OFF)
                  } else {
                    CanvasKitchenColor.sendCommand(25)
                    CanvasKitchenEffect.sendCommand("WhiteDimmed")
                  }
              }
              case 38949: {
                  var HSBType currentState
                  currentState = CanvasKitchenColor.state as HSBType
                  var DecimalType new_H = currentState.hue
                  var PercentType new_S = currentState.saturation
                  var PercentType new_B = new PercentType(currentState.brightness as Number + 10)
                  logInfo("File", "color test: hue = {} sat = {} bright = {}", new_H, new_S, new_B)
                  var HSBType newState = new HSBType(new_H, new_S, new_B)
                  logInfo("File", "color test: hue = {} sat = {} bright = {}", new_H, new_S, new_B)
                  CanvasKitchenColor.sendCommand(newState)
                  logInfo("CanvasTouch", "CanvasKitchenColor=" + CanvasKitchenColor.state)
              }
              case 20017: {
                  var HSBType currentState
                  currentState = CanvasKitchenColor.state as HSBType
                  var DecimalType new_H = currentState.hue
                  var PercentType new_S = currentState.saturation
                  var PercentType new_B = new PercentType(currentState.brightness as Number - 10)
                  logInfo("File", "color test: hue = {} sat = {} bright = {}", new_H, new_S, new_B)
                  var HSBType newState = new HSBType(new_H, new_S, new_B)
                  logInfo("File", "color test: hue = {} sat = {} bright = {}", new_H, new_S, new_B)
                  CanvasKitchenColor.sendCommand(newState)
                  logInfo("CanvasTouch", "CanvasKitchenColor=" + CanvasKitchenColor.state)
              }
          }
        } 
        default: {
        }
    }
end

rule "Nanoleaf color"
when
    Item CanvasKitchenColor changed
then
    logInfo("CanvasTouch", CanvasKitchenColor.name + " State=" + CanvasKitchenColor.state)
end

rule "Nanoleaf effect"
when
    Item CanvasKitchenEffect changed
then
    logInfo("CanvasTouch", CanvasKitchenEffect.name + " State=" + CanvasKitchenEffect.state)
end

@OMR Can you explain the setup to get it running?

@mraepple Do you plan to support touches with the binding?

cheers
Stefan

I’m having this issue:

Is there any work around other than actually fixing the bug? How have everyone else got it running?

Hi - I submitted this pull request which fixes the issue. Tested successfully on OH 2.4 and 2.5 (latest snapshot).

Hi Stefan, no, because I don’t own a Canvas/touch device for testing. However, based on the API documentation, I started this branch which may be a good start for somebody owning a Canvas to continue testing and developing :slight_smile:

Best regards
Martin

Hi @mraepple,

I am happy to help you even with programming. Also I have two panel Panels with which I can try out the implementation.

Did you see @OMR 's implementation in python here? Nanoleaf Canvas, capturing Touch Events

Just tell me what I should do with the branch and how I could build the binding out of it to deploy it on my openhab installation.

cheers
Stefan

Hi Stefan,

No - not yet, but looks like a nice solution when using the Canvas as stylish switches! As mentioned by @OMR , it would be great to have this functionality integrated in the binding one day.

This is great. I can only fly blind when developing against the API documentation.

I’ve forked the current OH2 addon repo (which now contains the latest bug fixes for the binding) and created a new feature branch for the Canvas device support. You can clone it from here. After that, just go into the bundles\org.openhab.binding.nanoleaf subdirectory, and run mvn clean install -DskipTests. This should build in the target directory a JAR file you can use for testing with your devices.

After you have deployed the new JAR file to your OpenHAB (test) instance, go to the binding configuration (e.g. in PaperUI). There you will see a new configuration parameter for the “Device Type”, which allows you to switch between “Light Panels” and “Canvas” device.

If you want to see my initial changes made to the current version of the binding to support the Canvas device, you can use this view on GitHub.

Hope this helps to get you started, and let me know if you have any questions.

Cheers
Martin

After giving up the last time, I tried it again tonight, but still ran into the same problem with auto discovery. So now, I removed everything and added all 21 panels as items by hand, using the template from the readme. Once done, I opened the site map in the basic UI and tried the controller first 
 on/off 
 not working. No errors in log. I tried changing the color of a single panel 
 nothing. Only errors from missing mappings (Null, - ) in the log. I checked the .items file twice for proper IP, port and auth 
 all good. This is the last thing in my home that I haven’t integrated and I’m quite frustrated. There are so many possibilities for using the lightpanels as status indicators/output for various processes around the home. Or for simply displaying the weather forecast 


But is this being developed anymore, besides canvas? It seems the last commit to the master branch was in January


Yes, it is. I picked it up by adding the canvas and it is working fine for that and it is working well for light panels on Martin’s side. Do you mind to wait until the latest version with my addition has been made available and we then start debugging it.

I have also made the documentation a bit more elaborate how to solve some common problems which might help you.

Here is the link to the unreleased documentation:
https://github.com/raepple/openhab2-addons/blob/canvas_touch_support/bundles/org.openhab.binding.nanoleaf/README.me

Please use autodiscovery only. I described it in detail as it wasn’t completely clear to me as well in the beginning.

In the meantime: you know how set the logging of the binding to debug and could you provide the logs to me?

Cheers
Stefan

Hey guys,
I can also only control the whole Aurora but not every single tile. Since Nanoleaf firmware updates frequently change the API i was reluctant to update in the past . I would be happy to also test once the new version is out.

Sebastian, I had the same issue as I didn’t really understood how to setup the tiles (we call them lightpanels). Please follow the new instructions that I have posted above and see if the controller is discovered. Then run a second discovery which should discover the lightpanels (hence tiles). Only then try to access them. Note that accessing (general) settings at the controller may overwrite the settings on a single lightpanel.

Hope that helps
Stefan

Oh so I should check out the canvas branch? Yes, I have set it to debug already. I’d be happy to test the new Version as well. With some luck, I’ll be able to do some testing on Wednesday.

Is there a snapshot ready for check out? The link to the new docu is not working for me (404).
I guess you mean this?

It doesn’t seem much different than the previous docu, just the touch stuff is new :slight_smile: