Indeed!
I got it to work as followed based on the script by the HA forum:
#!/bin/bash
######
# Config
password="Test1234!"
bridgeIP="192.168.XXX.XXX"
command='{"name":"GOTO_POS_CMD","value":"50"}'
######
# You shouldn't need to change anything after this line
# 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}"
# Send the command to do stuff
curl --cookie "HPSESSION=${cookie}" \
--request PUT --data "${command}" \
--url "http://${bridgeIP}/devices/1"
This script will caluclate the cookie and use it to authenticate. Tested it successfully on my rollershutter.
Next step is to check wether it is possible to send this cookie with an sendHttpPutRequest. As far is I can tell from the docs this is not possible. Correct my if I’m wrong.
To bypass this my idea was to set the cookie in a header as follows
val headers = newHashMap("Cookie" -> "HPSESSION=value")
However in contrast to the docs OH complains about the numer of arguments
Rule 'Rolladen': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.HTTP.sendHttpPutRequest(java.lang.String,java.lang.String,java.lang.String,int) on instance: null
TODO:
Fix above mentioned error
Check on how to receive the data in http.conf. Maybe replace it with the shell script as descriped below
Now openhab can’t authenticate as I don’t give him any creds
The cookie expires after a session so we have to check how to get a valid cookie.
Implement the script to get the cookie in the rule. As a backup instead of the script returning the cookie and using sendHttpPutRequest in OH we can’t just pass the command to the script and it will run the request
→ All the issues could be dealt with by using one/two simple shell scripts. Does somebody have a besser idea?
probably one would then also use a logout afterwards to prevent to have multiple sessions open, i guess
because the sessions stays up and the cookie valid pretty log.
maybe another idea:
if somebody is able to program a real binding based on the homebrigde plugin all will be already existing.
im not a programmer so this idea may be naive
rule "Alle 5 Minuten: Rolladen Status abrufen"
when
Time cron "0 */5 * * * ?"
then
executeCommandLine("/etc/openhab2/scripts/Rolladen/getState.sh")
end
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
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
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"}
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.
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
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.
Thank you @Udo_Hartmann for that valuable information.
I installed JavaScript Scripting and the previous config is working again!
e.g. things file:
Type number : Room_1 [
stateExtension="/v4/devices/24",
stateTransformation="JSONPATH:$.device.statusesMap.Position",
commandTransformation="JS:RollerShutterPositionJSON.js",
commandExtension="/devices/24"