OpenHAB CULfw for Somfy RTS Rollershutters

Hi,
I have also tried with Daniels solution but still no luck. If i set the shutter to learning mode with the remote and switch the learning button than nothing happens. The debug log says that the code has been written to the device and the rolling code has been updated, but the learning process did not work. I was wondering if there is some way to debug the procedure somehow? Is the shutter motor unit supposed to send some acknowledge back to the CUL which could be tracked? Is there some other software which could be used to test the procedure?
Any help is really appreciated.
Cheers,
Ben

Hi Ben,

the process of debugging the whole process is painful or sometimes non existent. There is no feedback from the motor unit, so no way of tracing if the command was acknowledged.

For me the process was, that I had a working solution based on FHEM but wanted to replace it with OpenHAB.

Thus some hints can be found below:

Cheers
Daniel

Hi Daniel,
again, it took a while to go into testing, but pressure is gaining due to all the sun now :slight_smile:
In order to test if hardware, firmware, distance, etc. are good I’ve decided to give fhem a try. Here it works. I was using different guides, but this one here should be sufficient: https://forum.fhem.de/index.php?topic=45569.0 and https://wiki.fhem.de/wiki/Somfy_via_SIGNALduino. I still use a nanoCUL 863 instead of signalduino. However, I don’t want to have a second system to maintain and I also don’t like the “style” of fhem. I would really like if this is going to work in openhab as well and I’m sure it must!
One thing I was wondering about, but couldnt check because I cannot look into the sources of the binding: in fhem some attributes for the stick will be set like slowRF and also the SOMFY protocol like shown here:

I guess the binding will take care about this, right? Can I check it somehow? And one other thing, due to my tests I have a rolling code which is always increasing. Is there a possibility to reset it? Or is this no problem at all as long as the shutter is not trained?

Thanks for help and advice as always.
Cheers,
Ben

Hi Ben,

the sources of the binding can be found at: https://github.com/weisserd/openhab2-addons/tree/feature_somfycul

The binding uses a fixed encryption key - as this seems to work - at least for me the last 6 months :wink:

The rolling code is updated and can bei easily seen (and edited - reloaded after an OpenHAB restart) in the config file (see folder %USERDATA/somfycul/SHUTTER_UID.properties). I had the same problem when switching from FHEM to OpenHAB, so I decided to have the rolling code easily available.

Cheers
Daniel

@Daniel_Weisser : Wanna try your binding - come from FHEM and there my Markise runs with CUL - now i switch to OH2 and searching for a solution found this thread - but cant find your binding via OH2 and eclipse IOT marktplace just find Somfy Tahoma Binding but not yours :frowning:

hi @black0r1337,

it should be reachable via the marketplace. However it is tagged as Alpha and thus you probably have to change the configuration of the marketplace settings: https://www.openhab.org/docs/configuration/eclipseiotmarket.html#configuration

And maybe I should come up with a plan to further develop and/or integrate it directly into OpenHAB. Because it is currently in the state “Works for me”. But if there are any questions don’t hesitate to ask.

Cheers
Daniel

Hi Daniel,

I was working on some other aspects with OpenHAB in the last months, but wanted to finish the Somfy issue now. However, it is not working. I have placed a question regarding JAVA already at stackoverflow, but didn’t receive any reply yet. I have also removed your name from the project in order to fulfil DSGV :slight_smile:
I was starting by installing oracla JAVA and have checked out the SomfyCUL test code from here:
Testcode for simple tests: https://github.com/weisserd/serial-cul-test
I have than compiled it with maven and this went well eventually (after some training). But now I get this error message:

mvn exec:java -Dexec.mainClass=de.saltest.home.SomfyCULTest


[INFO] --- exec-maven-plugin:1.6.0:java (default-cli) @ serialTest ---
Okt 07, 2018 3:25:41 PM de.saltest.home.SomfyCULTest main
INFORMATION: Opening port ttyUSB0
Could not load lib from jar and from system.
gnu.io.LibLoadException: directory does not exist /libs
        at gnu.io.LibraryLoader.loadLib(LibraryLoader.java:65)
        at gnu.io.LibraryLoader.loadLibsFromJar(LibraryLoader.java:48)
        at gnu.io.LibraryLoader.loadRxtxNative(LibraryLoader.java:29)
        at gnu.io.RXTXCommDriver.<clinit>(RXTXCommDriver.java:85)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:264)
        at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:104)
        at org.openmuc.jrxtx.JRxTxPort.openSerialPort(JRxTxPort.java:50)
        at org.openmuc.jrxtx.SerialPortBuilder.build(SerialPortBuilder.java:166)
        at de.saltest.home.SomfyCULTest.main(SomfyCULTest.java:24)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
        at java.lang.Thread.run(Thread.java:748)
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver

jrxtx is installed:

dpkg-query -L librxtx-java
/usr/lib/jni/librxtxRS485.so
/usr/lib/jni/librxtxRaw.so
/usr/lib/jni/librxtxI2C.so
/usr/lib/jni/librxtxParallel.so
/usr/lib/jni/librxtxSerial.so
/usr/share/java/RXTXcomm.jar

Do you have an idea what could be the problem here? I guess it is just a small issue, but I’m lost now…
Thanks again,

Ben

Hi Ben,

did you try to add the native path of the library as start parameter:

-Djava.library.path=/usr/lib/jni

And for starting the application I suggest not using mvn.

Cheers
Daniel

Hi Daniel,
yes I tried this already. Also I have copied the libraries directly to the same folders, etc. The error message is like this:

java -Djava.library.path=/usr/lib/jni -cp /usr/share/java/RXTXcomm.jar -jar ./target/serialTest-0.0.1-SNAPSHOT.jar

Okt 07, 2018 3:30:42 PM de.saltest.home.SomfyCULTest main
INFORMATION: Opening port ttyUSB0
Exception in thread "main" java.lang.NoClassDefFoundError: org/openmuc/jrxtx/SerialPortBuilder
        at de.saltest.home.SomfyCULTest.main(SomfyCULTest.java:24)
Caused by: java.lang.ClassNotFoundException: org.openmuc.jrxtx.SerialPortBuilder
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 1 more

Another thing, if I try to compile using javac I get also an error:

javac -classpath /usr/lib/jni -cp /usr/share/java/RXTXcomm.jar:. src/main/java/de/saltest/home/SomfyCULTest.java
src/main/java/de/saltest/home/SomfyCULTest.java:7: error: package org.openmuc.jrxtx does not exist
import org.openmuc.jrxtx.Parity;
                        ^

Any more ideas?
Thanks!
BR,
Ben

Hi Ben,

sure I do have more ideas :wink:

I would do the build with Maven and build a JAR with all dependencies included. (https://www.mkyong.com/maven/create-a-fat-jar-file-maven-assembly-plugin/) So you shouldn’t run into compile and packaging problems. Manually compiling produces more issues/problems when trying to find the right dependencies/libs.

As a result when starting (with java ...) the error concerning class not found should hopefully not arise and there is no need for an additional entry in the classpath.

Cheers
Daniel

Hi Daniel,
still no success, I’m getting more or less the same error:

 java -jar ./target/serialTest-0.0.1-SNAPSHOT-jar-with-dependencies.jar
Okt 09, 2018 11:36:34 PM de.danielweisser.home.SomfyCULTest main
INFORMATION: Opening port ttyUSB0
Could not load lib from jar and from system.
gnu.io.LibLoadException: directory does not exist /libs
        at gnu.io.LibraryLoader.loadLib(LibraryLoader.java:65)
        at gnu.io.LibraryLoader.loadLibsFromJar(LibraryLoader.java:48)
        at gnu.io.LibraryLoader.loadRxtxNative(LibraryLoader.java:29)
        at gnu.io.RXTXCommDriver.<clinit>(RXTXCommDriver.java:85)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:264)
        at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:104)
        at org.openmuc.jrxtx.JRxTxPort.openSerialPort(JRxTxPort.java:50)
        at org.openmuc.jrxtx.SerialPortBuilder.build(SerialPortBuilder.java:166)
        at de.danielweisser.home.SomfyCULTest.main(SomfyCULTest.java:24)
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver
Could not load lib from jar and from system.
gnu.io.LibLoadException: directory does not exist /libs
        at gnu.io.LibraryLoader.loadLib(LibraryLoader.java:65)
        at gnu.io.LibraryLoader.loadLibsFromJar(LibraryLoader.java:48)
        at gnu.io.LibraryLoader.loadRxtxNative(LibraryLoader.java:29)
        at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:118)
        at org.openmuc.jrxtx.JRxTxPort.openSerialPort(JRxTxPort.java:50)
        at org.openmuc.jrxtx.SerialPortBuilder.build(SerialPortBuilder.java:166)
        at de.danielweisser.home.SomfyCULTest.main(SomfyCULTest.java:24)
Exception in thread "main" java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
        at java.lang.Runtime.loadLibrary0(Runtime.java:870)
        at java.lang.System.loadLibrary(System.java:1122)
        at gnu.io.LibraryLoader.loadRxtxNative(LibraryLoader.java:32)
        at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:118)
        at org.openmuc.jrxtx.JRxTxPort.openSerialPort(JRxTxPort.java:50)
        at org.openmuc.jrxtx.SerialPortBuilder.build(SerialPortBuilder.java:166)
        at de.danielweisser.home.SomfyCULTest.main(SomfyCULTest.java:24)

However, it seems that the necessary libraries are packed into the jar:

jar tf target/serialTest-0.0.1-SNAPSHOT-jar-with-dependencies.jar
META-INF/
META-INF/MANIFEST.MF
gnu/
gnu/io/
gnu/io/CommDriver.class
gnu/io/CommPort.class
gnu/io/CommPortEnum.class
gnu/io/CommPortEnumerator.class
gnu/io/CommPortException.class
gnu/io/CommPortIdentifier.class
gnu/io/CommPortOwnershipListener.class
gnu/io/Configure$1.class
gnu/io/Configure$2.class
gnu/io/Configure$3.class
gnu/io/Configure$4.class
gnu/io/Configure.class
gnu/io/I2C$I2CInputStream.class
gnu/io/I2C$I2COutputStream.class
gnu/io/I2C$MonitorThread.class
gnu/io/I2C.class
gnu/io/I2CPort.class
gnu/io/I2CPortEvent.class
gnu/io/I2CPortEventListener.class
gnu/io/LPRPort$MonitorThread.class
gnu/io/LPRPort$ParallelInputStream.class
gnu/io/LPRPort$ParallelOutputStream.class
gnu/io/LPRPort.class
gnu/io/LibLoadException.class
gnu/io/LibraryLoader.class
gnu/io/NoSuchPortException.class
gnu/io/ParallelPort.class
gnu/io/ParallelPortEvent.class
gnu/io/ParallelPortEventListener.class
gnu/io/PortInUseException.class
gnu/io/RS485$MonitorThread.class
gnu/io/RS485$RS485InputStream.class
gnu/io/RS485$RS485OutputStream.class
gnu/io/RS485.class
gnu/io/RS485Port.class
gnu/io/RS485PortEvent.class
gnu/io/RS485PortEventListener.class
gnu/io/RXTXCommDriver.class
gnu/io/RXTXPort$MonitorThread.class
gnu/io/RXTXPort$SerialInputStream.class
gnu/io/RXTXPort$SerialOutputStream.class
gnu/io/RXTXPort.class
gnu/io/RXTXVersion.class
gnu/io/Raw$MonitorThread.class
gnu/io/Raw$RawInputStream.class
gnu/io/Raw$RawOutputStream.class
gnu/io/Raw.class
gnu/io/RawPort.class
gnu/io/RawPortEvent.class
gnu/io/RawPortEventListener.class
gnu/io/SerialPort.class
gnu/io/SerialPortEvent.class
gnu/io/SerialPortEventListener.class
gnu/io/UnSupportedLoggerException.class
gnu/io/UnsupportedCommOperationException.class
gnu/io/Zystem.class
gnu/io/package-info.class
org/
org/openmuc/
org/openmuc/jrxtx/
org/openmuc/jrxtx/DataBits.class
org/openmuc/jrxtx/FlowControl.class
org/openmuc/jrxtx/JRxTxPort$1.class
org/openmuc/jrxtx/JRxTxPort$SerialInputStream.class
org/openmuc/jrxtx/JRxTxPort$SerialOutputStream.class
org/openmuc/jrxtx/JRxTxPort.class
org/openmuc/jrxtx/Parity.class
org/openmuc/jrxtx/PortNotFoundException.class
org/openmuc/jrxtx/SerialPort.class
org/openmuc/jrxtx/SerialPortBuilder.class
org/openmuc/jrxtx/SerialPortException.class
org/openmuc/jrxtx/SerialPortTimeoutException.class
org/openmuc/jrxtx/StopBits.class
de/
de/danielweisser/
de/danielweisser/home/
META-INF/maven/
META-INF/maven/de.danielweisser/
META-INF/maven/de.danielweisser/serialTest/
de/danielweisser/home/SomfyCULTest.class
META-INF/maven/de.danielweisser/serialTest/pom.xml
META-INF/maven/de.danielweisser/serialTest/pom.properties

Am I right? Or do I miss something?
Cheers,
Ben

Sorry, I was a little fast. If I use the library path option and the full JAR it seems to work:

java -Djava.library.path=/usr/lib/jni -cp /usr/share/java/RXTXcomm.jar -jar ./target/serialTest-0.0.1-SNAPSHOT-jar-with-dependencies.jar
Okt 09, 2018 11:43:40 PM de.danielweisser.home.SomfyCULTest main
INFORMATION: Opening port ttyUSB0
Okt 09, 2018 11:43:40 PM de.danielweisser.home.SomfyCULTest main
INFORMATION: Closed port

I’m going to test more now and keep you posted how it works.
Thanks so far.
Best,
Ben

Hi Ben,

good to hear that you’re making progress.

Cheers
Daniel

Hi Daniel,
I think I have an idea what could be the issue with the binding. I have tried the java test code and it works. However, it does only work at 38400 baud. With 9600 it is not reacting at all. I was looking at the source code and was realizing that the transfer speed to the CUL is hardcoded at 9600 baud, The question now is how I can compile the binding by myself (changing the sources) or would it be possible to make the transfer speed a pararmeter? What do do you think what be the best approach?

In the meantime I did try to compile the binding myself. I’ve chosen the maven approach, but had some difficulties to compile your forked branch with the somfycul binding. so I did checked out the original master branch of openhab-addons and deleted .m2 first in my raspi home folder and compiled just an arbitrary single binding using:

mvn clean install

however, the same approach did not work with somfycul and resultet in the following error message:

[ERROR] Internal error: java.lang.RuntimeException: Invalid repository URL: http://download.eclipse.org/smarthome/updates-release/${esh.releaseVersion}: Illeg                                                                                                al character in path at index 55: http://download.eclipse.org/smarthome/updates-release/${esh.releaseVersion} -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: Invalid repository URL: http://download.eclipse.org/smarthome/updates-rel                                                                                                ease/${esh.releaseVersion}
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:121)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

I assume you’re using eclipse to do the compilation? Do you have an idea, why compilation fails with maven on the raspberry?

Thanks and BR,
Ben

Hi Ben,

the best approach would be to take the Somfy binding and enhance it (add config parameters, improve documentation, add tests) and bring it to a state where the integration into the main OpenHAB distribution is possible.

For my setup I take the code, compile it via my Linux (Ubuntu-based) machine via Maven and then put it to the raspi (by shell and by the Eclipse marketplace for tests).

The error in your command seems to be that the variable ${esh.releaseVersion} is not properly resolved.

Cheers
Daniel

Finally, I was successful. The shadow blinds are working now in openHAB. This is what I did directly on my RPi:

  • checking out the original openhab-addons sources from github
  • changing into the binding folder
  • execute the skeleton script to create an empty binding (with the very same name and author as the somfycul binding)
  • compare the sources of the original somfycul binding with the empty one and copy the relevant parts to the skeleton files
  • change the baud rate in the sources to 38400
  • compile the single binding with:
mvn clean install
  • copy the successfully compiled jar file from target folder to addons folder in openHAB
  • optional: clear the cache (for me it was not working without clearing, but afterwards it worked instantly)

thats it :slight_smile:

Now im looking for a possibility to make sure that all three of my USB sticks are always getting the same tty* after reboot. Usually it works, but not always.

Thanks for the support and for developing the binding sources!

Cheers,
Ben

1 Like

Hi Ben,

the solution for your tty* problem can be found at https://wiki.siduction.de/index.php?title=Symlink_zur_eindeutigen_Erkennung_mittels_udev-Regel

Cheers
Daniel

Hi Daniel,
thanks, this worked! However, I had to add the new ports in /etc/default/openhab2 otherwise 2 of 3 were not recognized.

Cheers,
Ben

@bahrenholz - are you willing to share the JAR of your recompiled version? I’ve not got a development environment that’s recompiling it yet, and have the same problem with baud rate.

Hi, I did send it via email, but I’m not sure if it came through. GMail is denying transportation of such files anyways.