Nanoleaf Binding OH3 - Stabilization Update

Thanks for your quick reply.

How do I do that? I can’t seem to find it in the UI…

No. Is it this I need to install?

If so, I’d add something like this to my docker-compose and see what happens:

Oh, and I forgot to mention: I am on OH 3.3.0.

3.3.0 is okay. Yes, frontail. Makes log viewing much easier. See Rules Blockly - Before Using | openHAB

Being on docker may always be something tricky with networking. The binding has a long running open connection …

Regarding logging see Logging | openHAB

The ‘tap’ channel for a panel is not working. I did see some similar discussion above, but here is what is happening for me.

The lightpanel thing defines a ‘tap’ channel:

	<thing-type id="lightpanel">
        ...
		<channels>
			<channel id="color" typeId="system.color"/>
			<channel id="tap" typeId="system.button"/>
		</channels>
        ...
	</thing-type>

When I link it I see:

2022-12-03 09:15:06.215 [WARN ] [nternal.handler.NanoleafPanelHandler] - Channel with id tap not handled

And indeed in the code, in the PanelHandler, handleCommand:

        try {
            switch (channelUID.getId()) {
                case CHANNEL_PANEL_COLOR:
                    sendRenderedEffectCommand(command);
                    break;
                default:
                    logger.warn("Channel with id {} not handled", channelUID.getId());
                    break;
            }

there is no case to handle the ‘tap’.

(Using 3.3.0, but source code from current main branch)

Did you check Nanoleaf - Bindings | openHAB ?

As it explains there is no TAP-Channel but rather a Trigger. That was a breaking some months ago as a channel wasn’t the right solution.

What you are looking for in the code is the following

    public void updatePanelGesture(int gesture) {
        switch (gesture) {
            case 0:
                triggerChannel(CHANNEL_PANEL_TAP, CommonTriggerEvents.SHORT_PRESSED);
                break;
            case 1:
                triggerChannel(CHANNEL_PANEL_TAP, CommonTriggerEvents.DOUBLE_PRESSED);
                break;
        }
    }

Does that help?

@stefan.hoehn did you see this one?
Any idea how to debug?

I am 100% sure it is related to the fractional part being saved to the json-db. Can you please check the entries of the panel thing first to make sure it does not contain something like “54086.0”?

I enabled TRACE logging and found this:

2022-12-04 15:38:25.727 [DEBUG] [al.handler.NanoleafControllerHandler] - touch detected for controller nanoleaf:controller:741ADCF0C4B8
2022-12-04 15:38:25.730 [TRACE] [al.handler.NanoleafControllerHandler] - content id: 4
data: {"events":[{"panelId":42633,"gesture":0}]}
2022-12-04 15:38:25.732 [DEBUG] [al.handler.NanoleafControllerHandler] - panel: 42633 gesture id: 0

Now, I only did the re-saving exercise on this one panel out of my 102.
Further down in the log:

2022-12-04 15:38:25.759 [TRACE] [al.handler.NanoleafControllerHandler] - Checking available panel -42995.0- versus event panel -42633-
2022-12-04 15:38:25.760 [TRACE] [al.handler.NanoleafControllerHandler] - Checking available panel -42633.0- versus event panel -42633-
2022-12-04 15:38:25.760 [TRACE] [al.handler.NanoleafControllerHandler] - Checking available panel -3654.0- versus event panel -42633-

Could it be a side effect of not re-saving all panels things?
Oh, and I’m currently on:

openhab> list | grep -i nano
258 │ Active │  80 │ 3.4.0.M1               │ openHAB Add-ons :: Bundles :: Nanoleaf Binding

You need to save each panel individually that is affected unfortunately afaik or edit the json file.

As long as there is a “.0” in the id it won’t detect it as equal.

But I only use gestures on this single panel. It works fine just after the re-save, but fails again after a OH3 restart.

So what is the Id of that single panel and can you send a trace when press that one?

If that single panel still has a .0 I am kind of confused. I would then say, we should ping the J-N-K and ask him if he has an idea why it behaves that way on your side.

The Id is 42633 as shown in this post:

Ok, so it does say “touch detected” for 42633 but the id is still (or again) 42633.0 (“Checking available panel -42633.0- versus event panel -42633-”). Hence, the json-setting is broken.

Thanks for the reply Stefan!

While I did use the docs to configure my setup I completely missed the part about the triggering channel, which is in fact a new concept to me, so once again thanks for pointing it out!

I did run into another issue after that. It seems the ‘long running client’ httpClientSSETouchEvent never got initialized as seen from this logging:

2022-12-04 16:53:39.206 [TRACE] [al.handler.NanoleafControllerHandler] - tj: touch job 920870700 started for new request -1 controller nanoleaf:controller:836ec07a7213 with null",

‘null’ is where it logs the httpClientSSETouchEvent value.

I tried restarting openHab, restarting the NUC, deleting the things, deleting the binding but it wasn’t working. This morning however I did a simple ‘Pause’ … wait … ‘Unpause’ of the controller in the web interface and now it’s working.

(And indeed in the logging I did see the line:

09:19:28.955 [DEBUG] [nal.handler.NanoleafControllerHandler] - Using long SSE httpClient=HttpClient@274783e8{STARTED} for 836ec07a7213}

which gets logged upon the succesful creation of httpClientSSETouchEvent.

Not sure why this happened. I am using thing/item files to configure everything.

Looking at the initialize I did see that whether or not the httpClientSSETouchEvent gets initialized actually does not depend on the LightPanels/Canvas deviceType configuration but on the modelId property of the device (which is then used to overrule the deviceType).

So possibly, in my case, this got done before the modelId was obtained from the device which resulted in the httpClientSSETouchEvent not being initialized. Then again, that should have resulted in the deviceType being overruled to LightPanels and thus I should not have seen any of the ‘tj:’ lines in the logging, but there was one every second in the trace log.

I’ll keep an eye on it, especially what happens when I have to reboot my system a next time.

1 Like

Hi, apologies to jump on the existing thread but searching has led me to this forum and your code snippet shows exactly what I’m looking for. I am migrating my setup from iobroker, and their binding can also handle a long-press (gesture id = 6, it’s undocumented but it works). I’ve been trying to figure out how to edit my config to handle this case as it allows more flexibility with rules per panel. I was just hoping to test it out with my local install. Is it at all possible for me to only edit my local binding to include this in your case statement, such that:

        switch (gesture) {
            case 0:
                triggerChannel(CHANNEL_PANEL_TAP, CommonTriggerEvents.SHORT_PRESSED);
                break;
            case 1:
                triggerChannel(CHANNEL_PANEL_TAP, CommonTriggerEvents.DOUBLE_PRESSED);
                break;
            case 6:
                triggerChannel(CHANNEL_PANEL_TAP, CommonTriggerEvents.LONG_PRESSED);
                break;

If it is not possible, that’s okay, I understand. Or, if this is the wrong place for this comment I apologise. I’ve been searching for any kind of configuration files in my openHAB install so that I could add the gesture id ‘6’ to listen for.

It is not clear to me what you are asking. Nanoleafs do not have “long press”. They have touch and swipe.

  • What do you mean with “their binding”?
  • Is this related to the Nanoleaf binding?
  • What is it that you want to achieve?

Apologies I’m still getting up to speed with the openHAB way of doing things. :sweat_smile: Thanks for your patience.

I have a set of 9 nanoleaf shapes, and some smart lights too. I’m trying to set up a rule similar to what I used to have, which is to listen for touch events on one specific lightpanel, and then, if the gesture is a short press, toggle the ceiling light in the room; else if it’s a long press (if you hold your hand on the panel for 2 seconds or so), set a specific effect on the entire nanoleaf panel. On iobroker I was able to get the gesture and panel details straight from the controller, the gesture was an integer where:
0 = short press
1 = double press
6 = long press

I’m trying to do the same here. So I have set up my controller and all nine panels as Things, and within each panel Thing I’ve added the available channels Color and Tap. I have rules set up to listen to changes in Tap. Here’s one:

I’ve tested this and it’s working great!
So I understand from the Nanoleaf Bindings documentation that Tap listens for the events SHORT_PRESSED and DOUBLE_PRESSED (I hope I set this up properly, the profile I used was Trigger Event String). I got very excited seeing your quoted code before and jumped right in, apologies! My main question is, is it possible for me to somehow add a third state LONG_PRESSED, where all the way back to the main Nanoleaf OpenAPI it includes a case where the gestureID of a panel is 6, in addition to the current 0 and 1? Please let me know if that doesn’t make sense and I’ll do my best to clarify.

Edit: Clarification on what I mean by gestures:
0: Single Tap
1: Double Tap
2: Swipe Up
3: Swipe Down
4: Swipe Left
5: Swipe Right
6: Long Press (Undocumented - I believe Nanoleaf shipped with this option for HomeKit but removed it later as it was not considered reliable enough; but they only removed it from the frontend, the nanoleaf still reports this gesture)

You made me curious :smiley:

Here’s how you can follow my check:

  • So I fired up my test panels
  • I set the logging to
log:set debug org.openhab.binding.nanoleaf
  • I filtered the logs on “gesture id:” and
022-12-06 17:47:52.806 [DEBUG] [al.handler.NanoleafControllerHandler] - panel: 58030 gesture id: 0
2022-12-06 17:47:54.958 [DEBUG] [al.handler.NanoleafControllerHandler] - panel: 46937 gesture id: 0
2022-12-06 17:47:57.119 [DEBUG] [al.handler.NanoleafControllerHandler] - panel: 46937 gesture id: 0
2022-12-06 17:48:01.439 [DEBUG] [al.handler.NanoleafControllerHandler] - panel: 46937 gesture id: 0
2022-12-06 17:48:03.958 [DEBUG] [al.handler.NanoleafControllerHandler] - panel: 46937 gesture id: 1
2022-12-06 17:48:07.199 [DEBUG] [al.handler.NanoleafControllerHandler] - panel: 46937 gesture id: 1
2022-12-06 17:48:10.438 [DEBUG] [al.handler.NanoleafControllerHandler] - panel: 46937 gesture id: 6

which shows you it is indeed possible.

Just buy me a :beers: and I am on it :wink: It seems after some long time there will be eventually an update on the binding from me.

The change is actually pretty simple as you guessed:

    public void updatePanelGesture(int gesture) {
        switch (gesture) {
            case 0:
                triggerChannel(CHANNEL_PANEL_TAP, CommonTriggerEvents.SHORT_PRESSED);
                break;
            case 1:
                triggerChannel(CHANNEL_PANEL_TAP, CommonTriggerEvents.DOUBLE_PRESSED);
                break;
            case 6:
                triggerChannel(CHANNEL_PANEL_TAP, CommonTriggerEvents.LONG_PRESSED);
                break;                
        }
    }

It is actually much more work to build and test it :wink:

by the way, there is a really cool one already there from Jørgen( @austvik ) which renders the layout of the panels on a specific channel. Maybe Jørgen, you want to announce it here an describe how cool it is :partying_face: )

2 Likes

My friend you have no idea how happy this makes me!!! Oh my goodness
100% if you need help testing you have all my energy at your disposal
The prospect of being able to not only do this but also get the panel layout to make cool and amazing patterns, I am so excited to experiment with this

1 Like

What does that tell you? :wink:

1 Like

My changes for 3.4.0 are a couple of changes which makes it easier to identify the correct panel.

Triangles, squares and hexagons are supported, but lines are not supported yet. I found some lines on cyber monday so will add support for that as well.

2 Likes