OpenHAB CULfw for Somfy RTS Rollershutters

@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.

@bahrenholz
Hi, I would be also interested in the updated JAR with baud 38400. Is placing it in the addons folder enough or do I have to uninstall the addon from the marketplace first?

thanks,
Christoph

Hi,

I have uploaded it to dropbox. I hope this is ok for Daniel :slight_smile:

https://www.dropbox.com/s/sm6bn8m4v956656/org.openhab.binding.somfycul-2.4.0-SNAPSHOT.jar?dl=0

You should uninstall the marketplace binding and just copy it to the addons folder. Good luck and best.

My solution to the baud rate problem was to edit CULfw configuration before compiling, and downloading to the nanoCUL.
Edit board.h file in the Devices/nanoCUL directory:
Find #define UART_BAUD_RATE and edit it to 9600. Then compile and download:
make program

Now it perfectly works with the openHAB addon!

Trying to get this running… Openhab 2.5M5.

I have a CUL USB Stick, placed the jar in /usr/share/openhab2/addons (raspianpi).
In discovery, I added a culDeviceLabel and set port /dev/ttyUSB1 (saw it in logs). The things say that it is online. Is there any way I could check if it is really working?
image

I then tried to add a somfyDeviceLabel with channels.
image

Now I tried to learn it.

I pressed “prog” on working RTS remote (rollershutters are moving), then “programChannelLabel” in paper UI.
Nothing happens, no log entries.

Update: I followed OpenHAB CULfw for Somfy RTS Rollershutters (added things, added items, added items to sitemap).

Switch klappladenBueroProg    "Somfy Büro prog"  (somfyFF) {channel="somfycul:somfydevice:buero:program"}
Rollershutter klappladenBuero  "Somfy Büro"  (somfyFF) {channel="somfycul:somfydevice:buero:position"} 

I pressed “prog” on working RTS remote (rollershutters are moving), then the klappladenBueroProg.
I hear a double beep, which I think confirms that programming did work.

But when I try to send the position, nothing happens.
Here what I see in the log:

2019-11-21 19:46:29.647 [INFO ] [ing.somfycul.handler.SomfyCULHandler] - channelUID: somfycul:somfydevice:esslinks:position, command: UP

2019-11-21 19:46:29.655 [DEBUG] [ing.somfycul.handler.SomfyCULHandler] - rolling code before command null

2019-11-21 19:46:29.662 [INFO ] [.binding.somfycul.handler.CulHandler] - Send message YsA120nullnull for thing somfyDeviceLabel

2019-11-21 19:46:29.669 [DEBUG] [.binding.somfycul.handler.CulHandler] - Trying to write ‘YsA120nullnull’ to serial port /dev/ttyUSB1

2019-11-21 19:46:29.682 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method ‘ThingHandler.handleCommand()’ on ‘org.openhab.binding.somfycul.handler.SomfyCULHandler@bf20a0’: For input string: “null”

java.lang.NumberFormatException: For input string: “null”

at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[?:1.8.0_222]

at java.lang.Long.parseLong(Long.java:589) ~[?:1.8.0_222]

at java.lang.Long.valueOf(Long.java:776) ~[?:1.8.0_222]

at java.lang.Long.decode(Long.java:928) ~[?:1.8.0_222]

at org.openhab.binding.somfycul.handler.SomfyCULHandler.handleCommand(SomfyCULHandler.java:106) ~[?:?]

at sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) ~[?:?]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222]

at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]

at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [bundleFile:?]

at com.sun.proxy.$Proxy415.handleCommand(Unknown Source) [?:?]

at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:74) [bundleFile:?]

at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:48) [bundleFile:?]

at sun.reflect.GeneratedMethodAccessor167.invoke(Unknown Source) ~[?:?]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222]

at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]

at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]

at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]

at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]

Hi,
from my experience the responsiveness of the stick is very much depending on the fact if baud rate of stick and binding are corresponding. You should verify this either with a windows terminal tool (I did it that way and send commands succesfully to the rollershutter) or somehow else. Usually, if this is working your setup should too.
good luck!

1 Like

Tx. No idea how to do this exactly, but will try to find out the baud rate this evening.

Is compiling with correct baud rate still the only solution?

I think the easiest way is to do like posted above:

Its really just editing, compiling, flashing. Much simpler as to edit the binding and recompile it.
Good luck!

For some reasons, the rollingCode is null.

I tested the SomfyCULTest (on Windows).
The programm “works”, I tested both 38400 and 9600 bauds, but nothing happens.
I wonder where the values for rollingCode and address come from (I know nothing about CUL).

Do you know how to set them?

SerialPort port = SerialPortBuilder.newBuilder(“COM4”).setBaudRate(38400).setParity(Parity.NONE).build();
OutputStream out = port.getOutputStream();

	@SuppressWarnings("unused")
	String commandLEDOn = "l01\n";
	String commandLEDOff = "l00\n";

	String encryptionKey = "A1";
	// C - Command (1 = My, 2 = Up, 4 = Down, 8 = Prog)
	String command = "2";
	String rollingCode = "001D"; 
	String address = "000029";
	String somfyCommand = "Ys" + encryptionKey + command + "0" + rollingCode + address + "\n";

Update: saw the first post… I did programm it first and then reused the values. The application is now working, I can open and close my folding shutter with it.

Now the question is: how/where do I set the address in openhab binding?
From the binding code, I see it is reading a property file but can’t figure out from where.

From logs I know that my channelUID is somfycul:somfydevice:klappladenBuero:position".

The address is being set when programming the shutter for the first time via OpenHAB.

The settings or better property files per shutter are being saved in the userdata-folder of OpenHAB. In my case this is /var/lib/openhab2/somfycul.

There is a property file per shutter where the details can be seen, e.g.

#Last command: UP
#Fri Dec 13 07:00:03 CET 2019
rollingCode=0781
address=0000AA
1 Like

Tx. I don’t see such a file.
As far as I see there is already a bill pointer during programming, so the file is never written.
Alternatively I might have a permission problem. Will check this evening.

Update:
The file /var/lib/openhab2/somfycul/somfycul_somfydevice_klappladenBuero.properties did exist but was empty.
This was the reason why sending “programming” never walked, as I got the null pointer above before even the programming command was send.

at org.openhab.binding.somfycul.handler.SomfyCULHandler.handleCommand(SomfyCULHandler.java:106) ~[?:?]

I filled the property file with your template, replaced address and rollingCode from values I used in SomfyCULTest, and now it is working.

#Last command: UP
#Fri Dec 13 07:00:03 CET 2019
rollingCode=0781
address=0000AA

Now I have to check how to bind USB devices to fixed ports (I also have an Elero USB stick…).
https://wiki.siduction.de/index.php?title=Symlink_zur_eindeutigen_Erkennung_mittels_udev-Regel didn’t work so far…

Everything is working now as expected :slight_smile:

I would love to see the add-on working on 2.5 an included in official release.
Baud rate should be configurable, for me it’s 38400.

Good to hear that it works for you

Being included into the official release sounds like a plan for 2020 then. Although 2.5 is definitely not going to be feasible.

1 Like

Hi Daniel, that would be really great :slight_smile: If this is going to happen, I would really like to also add a location to the thing, which is not possible right now.

Thing somfycul:somfydevice:sunshade “[somfy] Terrassenmarkise” @ “somwhere” (somfycul:culdevice:nanocul868)

This is probably quite easy I guess. Just as an idea.

Hi all,

I tried to set up the (nano)CUL-Stick to get it working with my Somfy RTS-Rollershutters in Openhab. I’m running OH2.5.0 (openhabian on Ubuntu).

I set up the binding like explained above by copying the jar to the addons-Folder, set up the Things and items and they are showing as ONLINE. Created the sitemap for the Programming-Switch and the Shutter-Control.
With copying the jar-File to the addons-Folder, I received
Unresolved requirement: Import-Package: gnu.io
witch I resolved with

feature:install openhab-transport-serial

But then I ran into the same issue like Jean-Marc mentioned above that the files in /var/lib/openhab2/somfycul are created as “./somfycul_somfydevice_kueche.properties” (so correct naming) but they are empty.
If I try to program a shutter, I receive the same “NULL”-Error.

2019-12-27 13:46:19.512 [INFO ] [ing.somfycul.handler.SomfyCULHandler] - channelUID: somfycul:somfydevice:kueche:program, command: ON
2019-12-27 13:46:19.514 [INFO ] [.binding.somfycul.handler.CulHandler] - Send message YsA180nullnull for thing Jalousie Kueche
2019-12-27 13:46:19.524 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.somfycul.handler.SomfyCULHandler@be1707': For input string: "null"

java.lang.NumberFormatException: For input string: "null"

at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[?:1.8.0_232]

at java.lang.Long.parseLong(Long.java:589) ~[?:1.8.0_232]

at java.lang.Long.valueOf(Long.java:776) ~[?:1.8.0_232]

at java.lang.Long.decode(Long.java:928) ~[?:1.8.0_232]

at org.openhab.binding.somfycul.handler.SomfyCULHandler.handleCommand(SomfyCULHandler.java:106) ~[?:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_232]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_232]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_232]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_232]

at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]

at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [bundleFile:?]

at com.sun.proxy.$Proxy5760.handleCommand(Unknown Source) [?:?]

at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:74) [bundleFile:?]

at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:48) [bundleFile:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_232]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_232]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_232]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_232]

at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]

at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]

at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_232]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_232]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_232]

at java.lang.Thread.run(Thread.java:748) [?:1.8.0_232]

Is there a way to identify the RollingCode and Address anyhow? I’m absolutely not experienced with CUL so an easy explenation would be much appreciated. :wink:

Many thanks in advance
Matze.

Hi,

as I have not upgraded my installation to OpenHAB 2.5 I have not checked if the "old " plugin is working flawlessly. However when starting to port the plugin to the new OpenHAB version I found a couple of things that might break.

@MatzeG The address is an identifier that is set, when you learn your “new” remote to the shutter. It is being set by the plugin. The rolling code is an identifier that is updated after every command that was set by the according remote. - Technical details can be found at http://culfw.de/commandref.html#cmd_Y

So you can’t really identify those values, but they are “defined” when learning a new remote. The OpenHAB instance is thus considered a new remote for the shutter.

Cheers
Daniel

Hi Daniel,

thanks for the heads up on this and explanation. Tried further settings on this one but did not get it running with Openhab. Always had the “NULL”-Error in the logs. After several tries I decided to get back to bind the Shutters to my HomeMatic-Installation with CuxD and it works.
I just wanted to “clean up” and have the shutters controlled directly via Openhab.

But anyhow, thanks for the help and information.
Cheers, Matthias.

Hi,

I have migrated my OpenHAB installation to version 2.5 and I do have an adapted version of the plugin running. Learning new shutters should work as well. The jar file can be found at http://www.danielweisser.de/org.openhab.binding.somfycul-2.5.0.jar

The source is somehow based on https://github.com/weisserd/openhab2-addons/tree/binding-somfycul - somehow because of the current changes of OpenHAB to version 3 (Development of openHAB 3.0.0 and 2.5.x) I do not have all changes on my current branch on github.

The baud rate is now configurable and my settings look as follows:

somfycul:culdevice:cul [ port="/dev/ttyACM0", baudrate="9600" ]
2 Likes

Very nice, thanks. I’m going to try it out a.s.a.p.