- Platform information:
- Hardware: Raspberry pi 3B+
- OS: linux Openhab image
- Java : openjdk version “1.8.0_152”
- openHAB version: openHAB 2.5.0~M4-1 (Milestone Build)
Hello,
I despair of trying to transform the shells 2.5 pos Topic to reverse the Shutter Icon.
On the Shelly device is
100 the blinds is close
0 the blinds is open
but at the sidemap the icon is open at 0 und closed at 100.
I search a while in the community and found a JS transform script.
InvertPercent.js
(function(i) {
// shelly 0% = Closed
// oh2 0% = open
//The following script converts [0% - 100%] to [100% - 0%].
var percent_shelly = parseInt(i, 10);
var percent_oh = (100.0 - percent_shelly);
//Return result with one decimal accuracy
return percent_oh.toFixed(1);
})(input)
I put the .js into the tranform Folder and add to the
.things
Thing topic Rollo_wozi_klein {
Channels:
Type string : online “Online” [ stateTopic=“shellies/shellyswitch25-73BF2B/online” ]
Type number : position “Position” [ stateTopic=“shellies/shellyswitch25-73BF2B/roller/0/pos”, commandTopic=“shellies/shellyswitch25-73BF2B/roller/0/command/pos”, transformationPattern=“JS:InvertPercent.js”]
but it does not work
Can anybody explain the mistake
Best regards
André