Reverse the percentage for the rollershutter

  • Platform information:
    • Hardware: ARM on Raspberry pizeroW
    • OS: Dietpi with Debian buster
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: 2.5.1
      Good evening,
      i’ve setup my OpenHab with the rollershutters conigurated with Mqtt channel. It looks like that it works but in the opposite direction. !00 is all close and 0 all open. Is it possible to reverse the numbers? with the Map It is but how to manage all the positions in the middle?
      Thanks in advance to everyone that will help me.
      Omar

A javascript transform should help here.

create a file 100-0.js in /etc/openhab2/transform

put this text in it:

result = 100-input;

and call it in paperui with JS:100-0.js

Go to Configuration, Things and edit the channel. Click SHOW MORE and put JS:100-0.js in the Outgoing Value Transformation field.

Thanks for your suggestion :slight_smile:
I’ve just tried that now but on the PaperUi it say Conflict. On the CFG file where i must put the Outgoing Trasformation.

Sorry, on OH2.5 I’m not using transforms in config files yet.

This might help https://www.openhab.org/addons/transformations/javascript/

Wait. Is your item defined in an .items file or in PaperUI?

You might need to install the Javascript transform

Yes, configurated in things ( with all the mqtt things ) and under Items referred to the things.
I keep triyng…

There’s an option on the thing to invert percentage.

That’s not documented ?

You’ll probably want both transformationPattern to invert incoming status, and perhaps transformationPatternOut if your roller accepts position numeric commands.

Ah, MQTT, sorry I missed that. It’s available on the “Blinds Control” channel at least for zwave devices.

Yes, my actual roller accept 100 as full open and 0 as full close.
The most strange thing is Alexa work correctly. If I ask Alexa close… the roller goes down, but if i use the button on both paperui and basicui they work in opposite ( to close i must push Up )…

Show us your events.log for these cases, what commands go to your Item?

On the .items there is

`Rollershutter   GF_LivingDining_Shutter       "Tapparella Sala"        <rollershutter>   (GF_LivingDining, gShutter)       ["Rollershutter"]            {channel="mqtt:topic:RpiBroker:tapparelle:roller1", alexa="Blind" [ actionMappings="Close=ON,Open=OFF,Lower=ON,Raise=OFF", stateMappings="Closed=100,Open=0"]}``

on the .things I have :

 Thing topic tapparelle "Tapparelle" {
    Channels:
        Type rollershutter : roller1 "Tapparella Sala" [ stateTopic="scs/cover/value/14", commandTopic="scs/cover/setposition/14" ]

As I can see the item is already arranged to work in the right way. But how can I manage the “Button” on the BasicUi ?
Later on I will add the event.log with the rollers message.

Show us your existing sitemap line too, please.

 Text label="Tapparelle" icon="rollershutter" {
            Default item=GF_Bathroom_Shutter label="Bagno"
            Default item=GF_Bedroom_Shutter label="Camera Matrimoniale"
            Default item=GF_KidsRoom_Shutter label="Cameretta"
            Default item=GF_LivingDining_Shutter label="Sala"
        }

Looks I’ve solved! :slight_smile:

.things

Type rollershutter : roller1 "Tapparella Sala" [ stateTopic="scs/cover/value/14", commandTopic="scs/cover/setposition/14", transformationPattern="JS:invertpercent.js", transformationPatternOut="JS:invertpercent.js" ]

file invertpercent.js

(function(i)  {

   var percent_shelly = parseInt(i,10);
   var percent_oh = (100.0- percent_shelly);
   return percent_oh.toFixed(0);

})(input)

Sitemap

 Text label="Tapparelle" icon="rollershutter" {
            Default item=GF_Bathroom_Shutter label="Bagno"
            Default item=GF_Bedroom_Shutter label="Camera Matrimoniale"
            Default item=GF_KidsRoom_Shutter label="Cameretta"
            Default item=GF_LivingDining_Shutter label="Sala"
        }

On Alexa i will test this afternoon if i must keep the .items with actions mapping as Post #13
I found a solution on a Deutch Openhab forum with the help of google translator :slight_smile:

1 Like