Rademacher Homepilot (DuoFern) via http-Binding

if somebody is able to program a real binding based on the homebrigde plugin all will be already existing.

Add it to my to-do list. Just have to find time to do it lol… (will not happen soon)

This is my working configuration of an rollershutter with a password set:

Scripts to get and set the state

┌─[17:31:07]-[:)]-[openhabian@openhab]-[/etc/openhab2/scripts/Rolladen/ (master)]
└──> ll
insgesamt 12K
-rw-r--r-- 1 openhabian openhabian 1,2K 17:28 23.05.2022 getCookie.sh
-rw-r--r-- 1 openhabian openhabian  463 17:28 23.05.2022 getState.sh
-rw-r--r-- 1 openhabian openhabian  544 17:28 23.05.2022 setState.sh

┌─[17:31:15]-[:)]-[openhabian@openhab]-[/etc/openhab2/scripts/Rolladen/ (master)]
└──> cat getCookie.sh
#!/bin/bash

readonly password="xxx"
readonly bridgeIP="${1}"

# Request a salt
saltRequest=$(curl --silent -X POST --url "http://${bridgeIP}/authentication/password_salt")
# echo "Saltrequest: ${saltRequest}"

# Extract the salt from JSON.
salt=$(echo -n "${saltRequest}" | jq -r '.password_salt')
# echo "Salt: ${salt}"

# Calculate sha256 of password
hashedPassword=$(echo -n "${password}" | sha256sum | cut -d " " -f 1)
# echo "Hashed Password: ${hashedPassword}"

# Concatenate the salt and hashed password
saltedPassword=${salt}${hashedPassword}
# echo "saltedpassword: ${saltedPassword}"

# Calculate sha256 of the salt+hashed password
finalPassword=$(echo -n "${saltedPassword}" | sha256sum | cut -d " " -f 1)
# echo "Final Password: ${finalPassword}"

# Request the cookie
cookie=$(curl --silent --output /dev/null --cookie-jar - --header "Content-Type: application/json" \
    --request POST --data '{"password":"'"${finalPassword}"'","password_salt":"'"${salt}"'"}' \
    --url "http://${bridgeIP}/authentication/login" | \
    tail -n 1 | awk '{print $NF}')
# echo "Session Cookie: ${cookie}"
echo "${cookie}"
┌─[17:31:18]-[:)]-[openhabian@openhab]-[/etc/openhab2/scripts/Rolladen/ (master)]
└──> cat getState.sh
#!/bin/bash

# shellcheck disable=1091
source /etc/openhab2/scripts/RPi4/send.sh

readonly bridgeIP="xxx"
# shellcheck disable=2155
  readonly cookie=$(/bin/bash /etc/openhab2/scripts/Rolladen/getCookie.sh "${bridgeIP}")
[[ -z "${cookie}" ]] && exit 1


raw_state=$(curl --cookie "HPSESSION=${cookie}" --url "http://${bridgeIP}/v4/devices" 2>/dev/null)

send "Verdunklung_Rolladen" "$(echo "${raw_state}" | jq '."devices"[0]."statusesMap"."Position"')"
┌─[17:32:48]-[:(]-[openhabian@openhab]-[/etc/openhab2/scripts/Rolladen/ (master)]
└──> cat /etc/openhab2/scripts/RPi4/send.sh
#!/bin/bash

send(){
    OHIP="localhost"
    curl -X PUT --header "Content-Type: text/plain" --header "Accept: application/json" -d "${2}" "http://${OHIP}:8080/rest/items/${1}/state"
}
┌─[17:31:22]-[:)]-[openhabian@openhab]-[/etc/openhab2/scripts/Rolladen/ (master)]
└──> cat setState.sh
#!/bin/bash

readonly bridgeIP="xxx"
# shellcheck disable=2155
  readonly cookie=$(/bin/bash /etc/openhab2/scripts/Rolladen/getCookie.sh "${bridgeIP}")
[[ -z "${cookie}" ]] && exit 1
 readonly command="${1}"


echo curl --cookie "HPSESSION=${cookie}" \
    --request PUT --data "${command}" \
    --url "http://${bridgeIP}/devices/1" >> /tmp/test2

# Send the command to the bridge
curl --cookie "HPSESSION=${cookie}" --request PUT --data "${command}" --url "http://${bridgeIP}/devices/1"

Cronjob to call the getter every 5 minutes

rule "Alle 5 Minuten: Rolladen Status abrufen"
when
    Time cron "0 */5 * * * ?"
then
    executeCommandLine("/etc/openhab2/scripts/Rolladen/getState.sh")
end
2 Likes

Is there anybody who know the http command for ventilation ? I tried sun but I guess that the ventilation is another cmd.

many thanks
Chris

Hello and thank you for the great work you all did to control the Rademacher components via Openhab and query sensors!

I have another question regarding Homepilot groups.

Is there a possibility, for example, to address the roller shutter groups instead of the individual roller shutters via DID?

Hi Rademacher-Users,
openHAB 4.0 is on its way and a first milestone version is available and can be tested.

I would like to make you aware that our existing config will not work anymore with that new openHAB version because the JS transformation will no longer exists. The SCRIPT transformation should be used instead.

@danil and all others - do you see a chance to review your RollerShutterPositionJSON.js ?
Can this be realized with SCRIPT transformation as well?

I am looking forward to get Rademacher stuff working (again) in openHAB 4.x :slight_smile:

Kai

Hi Kai,
yes, I can confirm SCRIPT Transformation is working too.

Renamed RollershutterPositionJSON.js to RollershutterPositionJSON.script
Changed commandTransformation: JS:RollerShutterPositionJSON.js to commandTransformation: SCRIPT:js:RollershutterPositionJSON.script

Edit: Tested with openHAB 3.4.2

Hi,
thank you for your post. With your code I was able to connect my homepilot to my openhab3 system. Unfortunately I am very much of a rooky but I have the will to learn. Maybe you can give me a hint with my problem I have right now.
I can control my rollershutter and switches, everything works perfectly but what I cannot get working is the Status of my switches. For example I switch on my living room light with the homepilot app but the openhab client won’t show me that the light is switched on. When I look at http://192.168.xxx.xxx/v4/devices?devtype=switch I can see my switch and that there is a change at “statusesMap: position”. If the switch is off it will show “0” and if it is on the value is “100”. How do I configure openhab that way that it checks this value and refreshes the gui. Thank you very much in advance for your support.

Hi @Skywalker / Marc,
I just tested this with my Rademacher Switch. I am using that plug with my hood in the kitchen and status is available in my openHAB.
When using Rademacher HomePilot GUI I can see in OH log:

 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'AbzugshaubeStatus' changed from 0 to 100
 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'AbzugshaubeStatus' changed from 100 to 0

Did you add the transformation to the .things?
My plug is called “Kueche_Abzugshaube” (=Kitchen_Hood)
My config files:
.things:

Type switch : Kueche_Abzugshaube [
            mode="WRITEONLY",
            commandExtension="/devices/27",
            onValue="{\"name\":\"TURN_ON_CMD\"}",
            offValue="{\"name\":\"TURN_OFF_CMD\"}"
        ]
Type number : Kueche_Abzugshaube#Status [
            stateExtension="/v4/devices/27",
            stateTransformation="JSONPATH:$.device.statusesMap.Position",
            commandTransformation="JS:RollerShutterPositionJSON.js",
            commandExtension="/devices/27"
        ]

And .items file:

Switch        Abzugshaube    	        "Abzugshaube  [%s]"            {homekit="Switchable", alexa="Switch", channel="http:url:HomePilot1:Kueche_Abzugshaube"} 
Number        AbzugshaubeStatus        	"Abzugshaube, Status [%d %%]"  {channel="http:url:HomePilot1:Kueche_Abzugshaube#Status"}

Many thanks for your support. Of course it works directly. I am on my way to have a lucky wife :wink:

1 Like

happy wife, happy life :rofl:

Hi,
I am back again ;-). How can I add an item (e.g. a switch or shutter) to a location, or maybe to two location in item file? I have searched a bit on the openhab manual and found out that it is quite simple to add an item to a group. for example (Wohnzimmer). ```
Example from manual:
String Bedroom_Sonos_CurrentTitle “Title [%s]” (gBedRoom) {channel=“sonos:…”}
In this case (gBedRoom) ist the group.
I did not found any notice for doing this procedure for locations. I have tried it then via MAINUI in the “model” section. I created some locations and then I have tried to link my item (eg Wohnzimmer_Wohnwand (switch) to the location Wohnzimmer but of course it did not work.
All items that are added manually by items.file are locked and cannot be modified by MAINUI. Is there any chance to solve this problem or do you have any idea where I can read more about this.
Many thanks for your help again…
Greetings,
Marc

Hi @Skywalker,
I do not use locations - I cannot comment on this.

How about using rules?
Maybe you can build your scenario with rules: “if someting happens THEN execute a Radmacher-command”.
This is how I do it for all my automations.
regards, Kai

Hi @danil,
today openHAB 4 was released…
While everything still was working in Milesstone1 and 2 now I am unable to get it running again.
Did you had a chance to test this (again)?
I renamed the commands accordingly and there is not even an error or something else in the log.
Shutters are not moving to target position anymore.
The script RollerShutterPositionJSON.script does not need any changes, right?
regards, Kai

After the upgrade to OH4 I still run into the problem the the translation script RollerShutterPositionJSON.js doesn’t work anymore.

Get the error

Transformation service JS for pattern RollerShutterPositionJSON.js not found!

The file ist there. In other topics I found out that it’s a syntax problem but not sure. Another thing can be the hint in the upgrade routine :

ORE: Rules are now triggered by ItemStateUpdatedEvent instead of ItemStateEvent. If you use JSR223 scripting without helper libraries and expect a certain Java type, code changes might be needed.

This is used by the RAdemacher integration. I use the helper libraries so I guess I don’t must do anything.

Actual I have no clue what the problem is and no idea where to search.

Would be great if someone has an idea.
Christian

please ignore. See comment from Udo below.

please see advice from danil.
You need to rename some stuff:
Rename RollershutterPositionJSON.js to RollershutterPositionJSON.script
Change commandTransformation: JS:RollerShutterPositionJSON.js to commandTransformation: SCRIPT:js:RollershutterPositionJSON.script

No, please don’t, this information is outdated!

openHAB4 Milestones used SCRIPT Transformation instead of JS to enable more than JS.
BUT: in openHAB1 (and all following versions) there was and is already the .script file extension.
So, there was another change for the better.

You can now simply use JS and the file extension .js and other scripts as well. But there is no JS transformation any longer, you have to install JavaScript Scripting instead, which will take care of the JS Transformation.

2 Likes

Thank you @Udo_Hartmann for that valuable information.
I installed JavaScript Scripting and the previous config is working again! :heart_eyes:

e.g. things file:

Type number : Room_1 [
            stateExtension="/v4/devices/24",
            stateTransformation="JSONPATH:$.device.statusesMap.Position",
            commandTransformation="JS:RollerShutterPositionJSON.js",
            commandExtension="/devices/24"

Great, thanks !! It works now.

Christian

P.S.
For everybody, don’t do my mistake and install the Nashorn Javascript Version - this doesn’t work.

1 Like

Hi, thanks for these detailed descriptions!

While I am currently setting up openHAB 4.0.3 (openHABian on a Raspi 4 / 8GB) for my first time, I have quite some experience with scripting and smart home, maybe that’s why the roller shutter code as well as the evironmental sensor (UWS) worked within a day :smile:

For controlling our floor heating, I have several Rademacher 9485 wall thermostats / controllers installed.
API-wise (when looking at the JSON code the HomePilot (or smarthome-box, as it’s called since the last update) these guys look very similar to the radiator thermostats from the example - not too surprising I guess.

Correct me if I’m wrong, but the code of the example only reads the values (actual and setpoint temperature etc.) from the thermostat, it is not able to actually set values - or is it?

Did anyone already try to implement setting temperature values or activating one of the thermostat’s temperature presets? I would be curious to know! :slight_smile: :wink:

1 Like

Hi @Hundertvolt1 Nico,
thanks for your feedback and I am happy to hear that roller shutters are working for you.

Yes, you are right.
I also have some thermostats and would like to send commands from openHAB - but I didn’t had the time to implement it yet. I guess when it gets colder outside I will have more “pressure” to work on it :crazy_face:.
If you are faster we would be happy if you could share your code for sending commands to thermostats.

best, Kai