Shelly roller shutter : setup item and Position value

Hello,

added item rollershutter using shelly2 via mqtt1 binding.

Generally Working, but position in percent is reversed by shelly.

Mqtt reporting 0 when shutter is closed. But the standard defined by KNX is:
100% = closed
0% = open

So this is my solution (as long as shelly not fixing the output) :

items/shelly.items:

Rollershutter Rollladen_wz_westen “Rollladen westen [%.0f %%]” {mqtt=">[tux:shellies/shellyswitch-55B74B/roller/0/command:command:*:MAP(shelly-rollladen.map)], <[tux:shellies/shellyswitch-55B74B/roller/0/pos:state:JS(rollershutter.js)]" , autoupdate=“false” }

transform/shelly-rollladen.map
OFF=off
ON=on
off=OFF
on=ON
UP=open
DOWN=close
STOP=stop
close=0
open=100
stop=? (0 or 100?) :slight_smile:
0=close
100=open

transform/rollershutter.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)

The % value for openhab is evaluated as
100% - shelly-position.

So, the shutter icon will show correct the State/Position.

BR/
Peter

2 Likes

With the MQTT1 binding the only thing I can think of is to switch to the JavaScript transform and do the mapping and swapping in the one transform.

Or you can use a proxy Item and as rule to calculate correct percentage.

With the MQTT2 binding, you can chain transforms so you’d only need a simple JavaScript to calculate the correct percent and continue to use the map transform.

Thank you very much for your script. It solved to me some problems on the event.log jejej

Do You know how can i control the % of the roller shutter. I mean to send “open 20%”
I see that if you set in the official app of shelly a 20% it send by mqtt the toppic: shellies/shellyswitch25-E59E6D/roller/0/pos 20
But i cant do it in openhab directly.

I want to do that because i am trying that when the sun is on a certain position the roller shutter open or close some porcentaje

Sorry for my english!! :smile:

Hello Nykroy,

i added later a shelly-shutter item “xx_pos”: to adress topic “…/roller/0/command/pos”

Rollershutter Rollladen_wz_westen_pos "Rollladen westen pos [%.0f %%]" <rollershutter> {mqtt=">[tux:shellies/shellyswitch-x5B74B/roller/0/command/pos:command:*:default], <[tux:shellies/shellyswitch-x5B74B/roller/0/pos:state:JS(rollershutter.js)]" , autoupdate="false" }

i use this to close the blinds at mid day if door is closed and not much clouds and not already closed more deep

rules/shelly.rule

      // Current cloudiness < 50%
        if ( myCloudiness < 50 )
        {
                // nur herunterfahren, nicht wieder hochfahren!
                if (Rollladen_wz_westen_pos.state < (100 - 50) )   # inverted state in shelly
                {
                        Rollladen_wz_westen_pos.sendCommand(50)  # send inverted POS% to shelly

so the old commands
Rollladen_wz_westen.sendCommand(“UP”)
Rollladen_wz_westen.sendCommand(“DOWN”)
are equal to
Rollladen_wz_westen_pos.sendCommand(0)
Rollladen_wz_westen_pos.sendCommand(100)

have fun!

BR/
Peter

1 Like

Thank you!!! Today i am going to try it!

thanks a lot! helped me a lot inverting values for Shelly 2.5 with MQTT 2.5 Binding:

Type rollershutter : control “control” [ stateTopic=“shellies/shellyswitch25-5D98C1/roller/0/pos”, commandTopic=“shellies/shellyswitch25-5D98C1/roller/0/command/pos”, transformationPattern=“JS:InvertPercent.js”, transformationPatternOut=“JS:InvertPercent.js” ]