Rademacher DuoFern via Fhem and MQTT

Devices from the german Company Rademacher use a proprietary protocol called DuoFern.
Unfortunatelly there is no openhab binding yet.
see: https://community.openhab.org/t/rademacher-duofern/25128

This tutorial will explain how to connect and control the devices anyway.
It is easier than the tutorial looks like. :smile:

We will make use of another smart home solution called Fhem.
This solution has a great module (actually two) for the DuoFern usb stick that supports any DuoFern-device and every feature of the protocol.

Requirements

  • openHAB server
  • Fhem server
  • MQTT broker
  • DuoFern usb stick
  • a supported DuoFern device

Installation and configuration

openhab

openHAB should already be installed an configured, of cause.

MQTT

Install a MQTT broker like mosquitto and configure it.
There should be plenty tutorials online for that. :wink:

Make yourself familiar with MQTT.
Lear the basics of how to publish messages and subscribe to topics.
Itā€™s not that hard.

Install the mqtt binding in openHAB and connect to the broker.

Fhem

Plug in the DuoFern usb stick to your server (or wherever you want to install Fhem).

Install Fhem.
https://wiki.fhem.de/wiki/Hauptseite

If you use docker, like I did on my Raspberry Pi, you need to specify your usb device.

docker run \
        -d \
        --device /dev/serial/by-id/usb-Rademacher_DuoFern_USB-Stick_WR04ZFOA-if00-port0 \
        -p 8083:8083  \
        -v /etc/localtime:/etc/localtime:ro \
        -v /etc/timezone:/etc/timezone:ro \
        -v fhem:/opt/fhem \
        --name fhem \
        sejnub/fhem:rpi-latest

source: GitHub - sejnub/docker-fhem: Docker images for the home autoomation software FHEM

configure the DUOFERNSTICK module

Once you installed Fhem you should be able to open the web interface.
http://<your-ip>:8083/

At the top you get a white text field to enter commands.

Insert the following command to add your usb stick.
It is kind of like a ā€œthingā€ or ā€œbridgeā€ in openHAB

You might want to change ā€œRademacherā€ to any name you want to give your stick
And code at the end must start with ā€œ6Fā€, while the last four characters can be defined as you want (hex 0-F).

define Rademacher DUOFERNSTICK /dev/serial/by-id/usb-Rademacher_DuoFern_USB-Stick_WR04ZFOA-if00-port0@115200 6F1A2B

see: https://wiki.fhem.de/wiki/DUOFERNSTICK

add a DUOFERN device

Press anything on your device, so it will send a message to all other DuoFern devices.
The usb stick will receive this message and Fhem will automatically create a new device.

Read the manual to see how to activate the pairing mode on the device.
Enter the following command in the web interface.

set Rademacher pair

Check the Fhem log (web interface) to see if the device is paired.

Optionally rename the device.

rename DUOFERN_409180 Rollo_WZ

For Belt Winders you need to defibe the start and end points before you can automatically control the device.

Click ā€œSave Configā€ below the Fhem logo every now and then. :wink:

On the left menu in Fhem you will find a group called ā€œDUOFERNā€.
In that group you will find your device. Open it.

You should see the status of every available attribute under ā€œReadingsā€.
Like ā€œstate: openā€ or ā€œposition: 0ā€.

To see if everything works you can use the ā€œsetā€ command at the top.

Select ā€œpositionā€ from the drop down menu and move the slider (green rectangle). Hit ā€œsetā€.
The Belt Winder should move now.

MQTT

Connect Fhem to your MQTT broker and choose a name for it (here mosquitto).

define <name> MQTT <ip:port> [<username>] [<password>]

# example
define mosquitto MQTT 192.168.1.23:1883 fhem mysectret

see: MQTT ā€“ FHEMWiki

MQTT-Bridge

A great feature of Fhem that makes this tutorial so easy if the ability to use the MQTT-Bridge to send and receive attributes via MQTT for complete devices.

Define a bridge for every device you need.

define <mqtt-device-name> MQTT_BRIDGE <fhem-device>

# example
define mqtt_Rollo_WZ MQTT_BRIDGE Rollo_WZ

The new mqtt device should be listet under ā€œEverythingā€ (left menu).

Configure a custom publish-topic for the device if you do not want to use the default one.
I recommend something like this:

attr mqtt_Rollo_WZ  publish-topic-base state/fhem/Rollo_WZ/

The following command will create all necessary attributes to publish all ā€œReadingsā€.

get mqtt_Rollo_WZ readings

Next you need to define the first subscribe attribute, that executes a ā€œsetā€ command once a message is received.

attr mqtt_Rollo_WZ  subscribeSet_position set/fhem/Rollo_WZ/position

Now you can check if everything works by subscribing to the ā€œstate/fhem/ā€ topic with a MQTT client.
And you can publish messages to see if you can control the device.

# This example uses "mosquitto_pub" as a MQTT client for linux
mosquitto_pub -h 192.168.1.23 -p 1883 -u fhem-P mysecret -t set/fhem/Rollo_WZ/position -m "7"

Once you verified that everything works as expected you can define all the other attributes to control the device.

attr mqtt_Rollo_WZ subscribeSet_sunPosition         set/fhem/Rollo_WZ/sunPosition
attr mqtt_Rollo_WZ subscribeSet_ventilatingPosition set/fhem/Rollo_WZ/ventilatingPosition
attr mqtt_Rollo_WZ subscribeSet_dawnAutomatic       set/fhem/Rollo_WZ/dawnAutomatic
attr mqtt_Rollo_WZ subscribeSet_duskAutomatic       set/fhem/Rollo_WZ/duskAutomatic
attr mqtt_Rollo_WZ subscribeSet_manualMode          set/fhem/Rollo_WZ/manualMode
attr mqtt_Rollo_WZ subscribeSet_sunAutomatic        set/fhem/Rollo_WZ/sunAutomatic
attr mqtt_Rollo_WZ subscribeSet_sunMode             set/fhem/Rollo_WZ/sunMode
attr mqtt_Rollo_WZ subscribeSet_timeAutomatic       set/fhem/Rollo_WZ/timeAutomatic
attr mqtt_Rollo_WZ subscribeSet_ventilatingMode     set/fhem/Rollo_WZ/ventilatingMode

# moving commands
attr mqtt_Rollo_WZ subscribeSet_up                  set/fhem/Rollo_WZ/up
attr mqtt_Rollo_WZ subscribeSet_down                set/fhem/Rollo_WZ/down
attr mqtt_Rollo_WZ subscribeSet_stop                set/fhem/Rollo_WZ/stop
attr mqtt_Rollo_WZ subscribeSet_toggle              set/fhem/Rollo_WZ/toggle
attr mqtt_Rollo_WZ subscribeSet_dawn                set/fhem/Rollo_WZ/dawn
attr mqtt_Rollo_WZ subscribeSet_dusk                set/fhem/Rollo_WZ/dusk
attr mqtt_Rollo_WZ subscribeSet_getStatus           set/fhem/Rollo_WZ/getStatus
attr mqtt_Rollo_WZ subscribeSet_remotePair          set/fhem/Rollo_WZ/remotePair
attr mqtt_Rollo_WZ subscribeSet_remoteUnpair        set/fhem/Rollo_WZ/remoteUnpair
attr mqtt_Rollo_WZ subscribeSet_reset               set/fhem/Rollo_WZ/reset

configure openHAB

fhem.items

mosquitto: is the name of my mqtt broker I defined in services/mqtt.cfg.

// Control
Number Rollo_WZ_position        "Rollo WZ pos. [%d %%]" <rollershutter>  { mqtt=">[mosquitto:set/fhem/Rollo_WZ/position:command:*:default],
                                                                                 <[mosquitto:state/fhem/Rollo_WZ/position:state:default]" }
String Rollo_WZ_mode            "Rollo WZ mode."        <movecontrol>    { mqtt=">[mosquitto:set/fhem/Rollo_WZ/up:command:up:default],
                                                                                 >[mosquitto:set/fhem/Rollo_WZ/down:command:down:default],
                                                                                 >[mosquitto:set/fhem/Rollo_WZ/stop:command:stop:default],
                                                                                 >[mosquitto:set/fhem/Rollo_WZ/toggle:command:toggle:default],
                                                                                 >[mosquitto:set/fhem/Rollo_WZ/dawn:command:dawn:default],
                                                                                 >[mosquitto:set/fhem/Rollo_WZ/dusk:command:dusk:default],
                                                                                 <[mosquitto:state/fhem/Rollo_WZ/moving:state:default]" }
Switch Rollo_WZ_sunMode         "Rollo WZ sunMode."     <sun>            { mqtt=">[mosquitto:set/fhem/Rollo_WZ/sunMode:command:*:MAP(onoffcases.map)],
                                                                                 <[mosquitto:state/fhem/Rollo_WZ/sunMode:state:MAP(onoffcases.map)]" }
Switch Rollo_WZ_ventilatingMode "Rollo WZ ventil.Mode." <fan>            { mqtt=">[mosquitto:set/fhem/Rollo_WZ/ventilatingMode:command:*:MAP(onoffcases.map)],
                                                                                 <[mosquitto:state/fhem/Rollo_WZ/ventilatingMode:state:MAP(onoffcases.map)]" }
Switch Rollo_WZ_manualMode      "Rollo WZ manualMode"   <boy_3>          { mqtt=">[mosquitto:set/fhem/Rollo_WZ/manualMode:command:*:MAP(onoffcases.map)],
                                                                                 <[mosquitto:state/fhem/Rollo_WZ/manualMode:state:MAP(onoffcases.map)]" }

// Settings
Switch Rollo_WZ_dawnAutomatic   "Rollo WZ dawnAuto."    <sunrise>           { mqtt=">[mosquitto:set/fhem/Rollo_WZ/dawnAutomatic:command:*:MAP(onoffcases.map)],
                                                                                    <[mosquitto:state/fhem/Rollo_WZ/dawnAutomatic:state:MAP(onoffcases.map)]" }
Switch Rollo_WZ_duskAutomatic   "Rollo WZ duskAuto."    <sunset>            { mqtt=">[mosquitto:set/fhem/Rollo_WZ/duskAutomatic:command:*:MAP(onoffcases.map)],
                                                                                    <[mosquitto:state/fhem/Rollo_WZ/duskAutomatic:state:MAP(onoffcases.map)]" }
Switch Rollo_WZ_timeAutomatic   "Rollo WZ timeAuto."    <clock>             { mqtt=">[mosquitto:set/fhem/Rollo_WZ/timeAutomatic:command:*:MAP(onoffcases.map)],
                                                                                    <[mosquitto:state/fhem/Rollo_WZ/timeAutomatic:state:MAP(onoffcases.map)]" }
Switch Rollo_WZ_sunAutomatic    "Rollo WZ sunAuto."     <sun>               { mqtt=">[mosquitto:set/fhem/Rollo_WZ/sunAutomatic:command:*:MAP(onoffcases.map)],
                                                                                    <[mosquitto:state/fhem/Rollo_WZ/sunAutomatic:state:MAP(onoffcases.map)]" }
Number Rollo_WZ_sunPosition     "Rollo WZ sunPos. [%d %%]" <rollershutter>  { mqtt=">[mosquitto:set/fhem/Rollo_WZ/sunPosition:command:*:default],
                                                                                    <[mosquitto:state/fhem/Rollo_WZ/sunPosition:state:default]" }
Number Rollo_WZ_ventilatingPosition "Rollo WZ ventil.Pos. [%d %%]" <rollershutter>  { mqtt=">[mosquitto:set/fhem/Rollo_WZ/ventilatingPosition:command:*:default],
                                                                                            <[mosquitto:state/fhem/Rollo_WZ/ventilatingPosition:state:default]" }

// Configuration
Switch Rollo_WZ_getStatus        "Rollo WZ getStatus"    <zoom>             { mqtt=">[mosquitto:set/fhem/Rollo_WZ/getStatus:command:ON:default]",
                                                                              autoupdate="false" }
Switch Rollo_WZ_remotePair       "Rollo WZ remotePair"   <lock>             { mqtt=">[mosquitto:set/fhem/Rollo_WZ/remotePair:command:ON:default]",
                                                                              autoupdate="false" }
Switch Rollo_WZ_remoteUnpair     "Rollo WZ remoteUnpair" <lock>             { mqtt=">[mosquitto:set/fhem/Rollo_WZ/remoteUnpair:command:ON:default]",
                                                                              autoupdate="false" }
String Rollo_WZ_reset            "Rollo WZ reset"        <error>            { mqtt=">[mosquitto:set/fhem/Rollo_WZ/reset:command:settings:default],
                                                                                    >[mosquitto:set/fhem/Rollo_WZ/reset:command:full:default]",
                                                                              autoupdate="false" }

fhem.sitemap

sitemap fhem label="Fhem"
{
    Frame label="Rollo_WZ" {
        Frame label="Control" {
            Text      item=Rollo_WZ_position
            Slider    item=Rollo_WZ_position
            Switch    item=Rollo_WZ_mode mappings=[up=up, down=down, stop=stop, toggle=toggle]
            Switch    item=Rollo_WZ_mode mappings=[dawn=dawn, dusk=dusk]
            Switch    item=Rollo_WZ_sunMode
            Switch    item=Rollo_WZ_ventilatingMode
            Switch    item=Rollo_WZ_manualMode
        }
        Frame label="Settings" {
            Switch    item=Rollo_WZ_dawnAutomatic
            Switch    item=Rollo_WZ_duskAutomatic
            Switch    item=Rollo_WZ_timeAutomatic
            Frame label="Sun" {
                    Switch    item=Rollo_WZ_sunAutomatic
                    Text      item=Rollo_WZ_sunPosition
                    Slider    item=Rollo_WZ_sunPosition
            }
            Frame label="Ventilation" {
                    Text      item=Rollo_WZ_ventilatingPosition
                    Slider    item=Rollo_WZ_ventilatingPosition
            }
        }
        Frame label="Configuration" {
            Switch    item=Rollo_WZ_getStatus
            Switch    item=Rollo_WZ_remotePair
            Switch    item=Rollo_WZ_remoteUnpair
            Switch    item=Rollo_WZ_reset mappings=[settings=settings, full=full]

        }
    }

}

onoffcases.map

on=ON
off=OFF
ON=on
OFF=off

Check if the items in openHAB create and receive the necessary mqtt messages.
This should work very fast without any noticeable delay.

Now you should be able to control your Rademacher DuoFern device with openHAB.

Have fun.

Demo:

other issues

reset usb port

After every reboot of my RasPi I had to replug the DuoFern adapter and restart the fhem container.
So I wrote a little script that rests the usb port after reboot and restarts the container for me.

see: GitHub - CWempe/usbreset

This is my cron file

@reboot   root   sleep 30 && /home/<username>/usbreset/reset_dynamic_port.sh WR04ZFOA && sleep 20 && docker restart fhem

I donā€™t know if the sleep commands are necessary. I just put them there. :wink:

5 Likes

Hi,

danke fĆ¼r das super Tutorial. Danach habe ich lange gesucht.

Leider funktioniert bei mir nicht alles. Vielleicht hast du eine Idee?
Die MQTT-Bridge ist eingerichtet und ich konnte Ć¼ber einen MQTT Befehl den Rollladen auf Position 50 fahren.

Ɯber den Regler auf der FHEM Seite kann ich den Rollladen auch steuern.

In openHAB habe ich die default.items und default.sitemap angelegt. Die openHAB Seite sieht soweit auch gut aus:

Aber wenn ich auf der openHAB Seite nun versuche den Rollladen zu bewegen, passiert nichts.

I will answer in english, because this is an international community.

I would recommend to subscribe to the topics with a mqtt client to see if openhab is sending the correct mqtt messages.
If you see messages the question would be if fhem is subscribing to the topics correctly.
Or maybe openhab is sending wrong topics.

How can i do this? What should i do?

I would use the linux command ā€œmosquitto_subā€.

To subscribe to every topic, use this command:

mosquitto_sub -h <mqtt-server-ip> -u <user> -P <password>-p 1883 -t +/# -v

When you click the ā€œupā€ button in the openhab GUI, you should see something like this:

set/fhem/Rollo_WZ/up up
state/fhem/Rollo_WZ/moving up

If i use the command nothing happens:

Where should i see the informations (set/fhem/Rollo_WZ/up up state/fhem/Rollo_WZ/moving up)? I have look into the fhem log but there is now entry if i click on a button.

Ok, now it works. I have forgot to Install the mqtt binding in openHAB.

Now i try to connect this settings with amazon alexa. But it dosnĀ“t work. Do you have test this?

No, I donā€™t have an Alexa device, yet.

very interesting solution.
i have a similar problem, there is no oh2 binding for eltaco enocean actors, but they works fine with fhem.
it should be possible to follow your instructions to make it work, right?

Yes.
Just get your devices to work with Fhem and configure the MQTT bridge (in Fhem and in openhab).

after couple hours it works fine now with all enocean actors/rollershutters.
thx for this great idea and solution @christoph_wempe

Do I need a manual central operating unit, standard hand transmitter, home pilot or duo fern comfort device from Rademacher, to use your solution OR is it enough, if I have all the software running and a Rademacher USB Device?

Currently I only have 2 Rolloport Duofern Standard and Iā€™m thinking about which operating unit I should buy. If I only need the stick, it would be greatful, because I have a running openHAB on a Pi2 for control all of my heating devices.

Thanks
Stephan

You only need the stick!

btw: I currently have an issue where fhem does not publich any info to mqtt after I reinstalled my setup again.
sending commands from openhab to fhem via mqtt does work.
Hopefully I will figure this out soon. :slight_smile:
I am sure itā€™s only a simple mistake I made.

EDIT: I did not change anything, but it id working after restarting fhem. :slight_smile:

Now, the USB-Stick is active on the Pi and FHEM know him:

But Iā€™m not able to pair any of my Rollotron Duofern Standard. I press the up or down key, but
the stick nor the FHEM say me something about new devices.

ā€œset Rademacher pairā€ dont work, the enabled pairing mode on the device does not work.
I dont see any devices in the log:
2017.05.23 13:11:39 3: Opening Rademacher device /dev/serial/by-id/usb-Rademacher_DuoFern_USB-Stick_WR04ZFOA-if00-port0
2017.05.23 13:11:39 3: Canā€™t open /dev/serial/by-id/usb-Rademacher_DuoFern_USB-Stick_WR04ZFOA-if00-port0: Datei oder Verzeichnis nicht gefunden
2017.05.23 13:13:39 1: PERL WARNING: Use of uninitialized value in numeric eq (==) at ./FHEM/10_DUOFERNSTICK.pm line 574.
2017.05.23 13:13:39 1: PERL WARNING: Use of uninitialized value in addition (+) at ./FHEM/10_DUOFERNSTICK.pm line 554.

I think, the message at line 2 can be ignored, because FHEM know a device item named DUOFERNSTICK:
CFGFN

DEF /dev/serial/by-id/usb-Rademacher_DuoFern_USB-Stick_WR04ZFOA-if00-port0@115200 6F1A2B
DeviceName /dev/serial/by-id/usb-Rademacher_DuoFern_USB-Stick_WR04ZFOA-if00-port0@115200
DongleSerial 6F1A2B
NAME Rademacher
NR 32
NTFY_ORDER 50-Rademacher
PARTIAL
STATE CMDs_done
TYPE DUOFERNSTICK

Did you have any hints for me? I can not find any documentation in the web about the Duofern-Stick. The Rademacher websitedont know this device.

Stephan

Device adding and pairing was successful after I remove and insert the stick.
Sorry for all the trouble.

After this line I miss the command. Should be:
get mqtt_Rollo_WZ readings

Greets
Stephan

Thanks.
I fixed it.

Even though I am not sure, because it now works for me without this command. :neutral_face:

Thank you very much for sharing this solution! Finally I have the possibility to integrate my RolloTubes into openHAB! :slight_smile:

However, there are some open questions to me (thanks to the (imo) confusing Rademacher system):

  1. What should the modes ā€œDAWNā€ and ā€œDUSKā€ do? Unfortunately, nothing happens if I trigger these (also not in fhem). And I canā€™t find a matching function in my hand-held transmitter (ā€œDuoFern Handzentraleā€). Maybe this is only for the RolloTrons?

  2. Could you please share you onoffcases.map file? :slight_smile: That would make this tutorial foolproof :slight_smile:

As far as I understand:

  • When you activate DUSK, the shutters should drive to the defined Ventilate position.
  • DAWN --> 0%, I think

EDIT: I added the map in my fisrt post.

onoffcases.map

on=ON
off=OFF
ON=on
OFF=off

Ok, at least for my RolloTubes this doesnā€™t work.
(Itā€™s not a MQTT / OH2 Thing, FHEM also does nothing when ā€œset Rollo_WZ duskā€ is executed, although a ventilating position is programmed).

But itā€™s not a big deal, I just was curious about this feature.
Thanks to the openHAB rules almost any position/automatic feature of Rademacher is obsolete :slight_smile:

Best regards