Somfy RTS + CUXD + OPENHAB: remote controlling my rollershutter

h3rmanns
4 min readAug 31, 2016

--

Thanks to this description I was able to control my Somfy RTS Rollershutter using the great OpenHAB home automation system.

Because the above linked description was a little bit concise and didn’t matched my problem completely, I will try to describe what I had to do to implement this solution.

What Hardware was needed?

I connected the Stick to my CCU1 using the extension cable (otherwise the two antennas will disturb each other if placed to close together).

To control the stick using the homematic CCU1 the so called cuxd addon is needed. The current version can be downloaded here.

Using Einstellungen|System the button Zusatzsoftware installieren the CUX Daemon can be installed on the CCU1.

After that, the addon inetd has to be installed. With this, the CCU1 can be accessed using telnet (on the CCU2 this shouldn’t be necessary, since this unit supports SSH to be connected to).
After a successful installation when clicking on Zusatzsoftware, you should see the following apps installed:

Further more, under Einstellungen|Systemsteuerung should a button CUx-Daemon become visible. By clicking on it, you get to the main CUx Daemon Web Application:

The screenshot above depicts how my sunblind has been created. It has to have the ID CUX4000001. After clicking Gerät auf CCU erzeugen the actor should be accessible using the homematic ui:

On the details setting you tell homematic that the script should be executed. So check the BLIND|CMD_EXEC box. Enter the path to the script in the following textfields:

BLIND|CMD_SHORT:
tclsh /usr/local/addons/rollo/somfy.tcl CUX4000001:1 Somfy $VALUE$ A0 A00000

BLIND|CMD_LONG:
tclsh /usr/local/addons/rollo/somfy.tcl CUX4000001:1 Somfy $VALUE$ A0 A00000

BLIND|CMD_STOP:
tclsh /usr/local/addons/rollo/somfy.tcl CUX4000001:1 Somfy STOP A0 A00000

Since the somfy protocol needs a counter that has to be send to the sunblind, we create a variable using the CCU1 Einstellungen|Systemvariable:

Now, we are using the telnet access to connect to our CCU1 with user root:

telnet homematic
vi /usr/local/addons/rollo/somfy.tcl

and paste the following script:

#!/bin/tclsh

#tclsh /usr/local/addons/rollo/somfy.tcl CUX2801004:1 WohnGrF STOP A0 AA0001

#tclsh /usr/local/addons/rollo/somfy.tcl CUX4000001:1 WohnGrF $VALUE$ A0 AA0001

load tclrega.so

#set device_name “CUX4000001”

set device_name [lindex $argv 0]

set device_sysvar_name [lindex $argv 1]

set device_cmd [lindex $argv 2]

set device_remote_enc [lindex $argv 3]

set device_remote_id [lindex $argv 4]

# command-line for reading rolling counter sysvar

set cmd “var remote_counter = dom.GetObject(\”$device_sysvar_name\”).Value();”

# read sysvar

array set values [rega_script $cmd ]

set remote_counter $values(remote_counter)

# convert to integer

set remote_counter [ expr int($remote_counter)]

#puts $remote_counter

# convert to HEX

set remote_counter_hex [ format %04X $remote_counter ]

#puts $remote_counter_hex

switch $device_cmd {

“OPEN” { set device_cmd_hex “20” }

“1000” { set device_cmd_hex “20” }

“CLOSE” { set device_cmd_hex “40” }

“0” { set device_cmd_hex “40” }

“PROG” { set device_cmd_hex “80” }

“MY” { set device_cmd_hex “10” }

“500” { set device_cmd_hex “10” }

“STOP” { set device_cmd_hex “11” }

default { puts “WRONG SOMFY COMMAND” }

}

set somfy_cmd “\”Ys$device_remote_enc$device_cmd_hex$remote_counter_hex$device_remote_id\””

puts $somfy_cmd

set cmd “dom.GetObject(\”CUxD.$device_name.SEND_CMD\”).State($somfy_cmd);”

puts $cmd

#array set values [ rega_script $cmd ]

rega_script $cmd

#rega_script { dom.GetObject(“CUxD.CUX4000001:1.SEND_CMD”).State(“YsA0200018ABCDEF”);}

set remote_counter [ expr $remote_counter + 1 ]

puts $remote_counter

set cmd “”

Exit vi by entering :wq.

Afterwards add execution rights to your script:

chmod 777 somfy.tcl

Adding your CUL Stick as a Somfy remote

The last step is to connect the ccu1 to your sunblind. To do so, activate the learning mode of your Somfy RTS sunblind. This differs from model to model a little bit. I had to press a special button on the back of my somfy remote. In my case the sunblind reacts by moving the blind a litte bit.

Now we can execute the following command to establish the connection to the sunblind:

tclsh /usr/local/addons/rollo/somfy.tcl CUX4000001:1 Somfy PROG A0 A00000

Your sunblind should react to this command by moving once more a little bit. The sunblind should be working with the ccu webui now. You can verify this be executing the following command in your homematic telnet shell:

tclsh /usr/local/addons/rollo/somfy.tcl CUX4000001:1 Somfy 0 A0 A00000

This should close your sunblind.

Adding your device to openhab

Next, we will connect the CUX4000001 device to the openhab configuration. To do so, we have to add the following to the items/default.items file:

Rollershutter Markise_Garten “Markise” {homematic=”address=CUX4000001, channel=1, parameter=LEVEL, forceUpdate=true”}

The somfy sunblind can now be controlled using openhab like a normal rollershutter.

Hope this documentation is hopeful for someone else!

Troubleshooting

I had the problem that my sunblind stopped working. This was maybe because of my Somfy variable changed its value after a ccu reboot.

I solved it by setting my sunblind into learn mode (as described above) and readding my system to the sunblind by entering:

tclsh /usr/local/addons/rollo/somfy.tcl CUX4000001:1 Somfy PROG A0 A00001

Please recognize that I had to increment the remote-control Id to “A00001”! At least I had to update the homematic commands for BLIND|CMD_SHORT, BLIND|CMD_LONG and BLIND|CMD_STOP.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Responses (1)

Write a response