Hello.
Nice to know someone else has use for this
It should definitely be part of the binding some day.
This solution works pretty well, but I have 2 issues:
The service doesn’t start after a reboot. Don’t know why. I have enabled it.
If the canvas restarts, the service also needs to be restarted.
Pleas let my know if you are able to figure this out.
Mine just live in my ~ folder (/home/omr)
Also in ~ (or change the path in the program)
omr@shs2:~$ sudo systemctl status canvasTouch.service
● canvasTouch.service
Loaded: loaded (/etc/systemd/system/canvasTouch.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2019-09-28 18:30:20 CEST; 8s ago
Main PID: 19570 (python)
Tasks: 1
Memory: 9.4M
CPU: 113ms
CGroup: /system.slice/canvasTouch.service
└─19570 /usr/bin/python /home/omr/nanoleafTouches.py
Sep 28 18:30:20 shs2 systemd[1]: Stopped canvasTouch.service.
Sep 28 18:30:20 shs2 systemd[1]: Started canvasTouch.service.
omr@shs2:~$
I try to understand the code (I am pretty good in other languages but I don’t know python and its API very well) and there is one thing that strikes me: Do you ever wait at some point to give the CPU / the panels some kind of relief or are you firing one request after the other against the panels?
Meanwhile I was brave enough to try it out and even in top there’s hardly any cpu that you can see for that process. … and it works. Now I can play around a bit with it. Sometimes it doesn’t recognize my touches, hence I will investigate in which case and why (I think you shouldn’t be too soft but rather “tap” a bit harder). Maybe in the future I am looking into how this could be applied to the nanoleaf plugin and provide a merge request (at least I feel some itch for that at the moment). Let’s see how it goes…
By the way - if you want to show it in your sitemap you should define it as such
I think it does the equivalent to linux select()/poll() on this line:
r=response.raw.read(1) # parse every single byte received until /n/n
I’m not using python as my primary programming language either, but I was inspired looking at some other examples for integrating my car into OH2 (https://github.com/ardevd/jlrpy).
As for the Canvas touches and gestures in particular, it takes a bit of practise. I don’t use gestures yet, but touches quite a lot. I also find that the people over at Nanoleaf are quite interested in user feedback, so they might be able to refine the gesture detection if it gives you trouble.
As for contributing with bindings, I have read on this forum and on Github that there has been some tool-chain trouble during the last months. I know they are trying to come up with a (better) “how-to set that up”. Haven’t checked in a while, so they might have something already.
Everything works pretty well now, so again thanks for your work! Very much appreciated!
They way I did the startup for the python script in my case is as a mentioned earlier with init.d . I have written a pretty simple init-script which just starts the python script in the background and looks as follows:
Filename: nanoleaf
Directory: /etc/init.d
#! /bin/sh
### BEGIN INIT INFO
# Provides: nanoleaf python script for openhab2
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: nanoleaf events
# Description: Start nanoleaf python script
### END INIT INFO
# Author: Stefan Höhn
nohup python /etc/openhab2/python/nanoleaf.py &
Just to let you know, Ole, I lately got together mit Martin who has written the nanoleaf binding and he agreed to let me contribute to his binding. The good news is that meanwhile it is done and under review. There are small things I like to optimize but basically it is working pretty nicely.
So stay tuned as touch events will be available by individual panel and you can write rules based on a pulse on a switch item.
Hi Ole, I just wanted to let you know that the touch support is now officially supported in the 2.5.
A big thanks to you because your working Proof-of-concept led me thinking about implementing it in the binding which I then finally did. So Kudos to you for doing the proof and convincing me to do it.
It is already part of 2.5.1. Installing 2.5.1 should be enough to have it working. One note though: I just noted that setting the color of an individual panel got broken at some stage during the official canvas support implementation. Fix is already under review and will soon be out with 2.5.2.
OH my gosh! 102 Panels? Really? I can’t believe that there really people out there who have so many devices :-).
Do they all belong to the same controller?
What are you doing with so many panels?
Can you contact me directly? Just to be sure I want to send you the last snapshot of the bundle and see if that makes a difference.
And can you also provide me the log of all nano log statements? Be sure to set it to trace when you discover a panel.