Rollershutter transformation MQTT


Anyone willing to help me explain what am I doing wrong and why the mapping doesn’t work?
I’m trying to setup Item to manage my shutter over MQTT.

When I send command via console like:

openhab> smarthome:send Shutter_office_side 1
Command has been sent successfully.

shutter goes up. So I expect MQTT is set properly.

But when managing shutter using sitemap, I still getting different payload data than expected, even when transformation mapping is in place.


Rollershutter Shutter_office_side "Office side"  {mqtt=">[rpi:shutter/window/7/:command:*:MAP(] , <[rpi:shutter/window/7/status/:state:MAP(]"}



When hit UP button in basic UI, OH sends UP command:

15:11:28.511 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'Shutter_office_side' received command UP

Is there a way how to transform UP command into 1 so I can make the shutter move using basic UI?

OH restart didn’t helped.

Thanks for your guidance!

A Transform will only work on the State of an Item. A Rollershutter stores its state as a PercentType (integer between 0 and 100). UP, DOWN, and STOP are commands. These commands cause the State of the Item to change, but they are not stored in the Rollershutter Item itself. Therefore the MAP can’t work this way.

To make this work, you need to:

  • remove the outgoing mqtt binding from the Item

  • create an Item that gets triggered by Item Shutter_office_side received command

  • use the MQTT Action to publish the right value based on the command. You can even continue to use the map file if you want.

    publish(“rpi”, “shutter/window/7/”, transform(“MAP”, “”, receivedCommand) )

  • you probably want to add autoupdate=false to the Item as well so the Item doesn’t change state until the device says it has changed state.

1 Like

Hello @rlkoshak,

Thanks for your answer.
I believe your solution will work, but I’m newbie and sounds to me like a rocket science :slight_smile: so not sure how to proceed now.

I’ve followed this thread: Rollershutter MQTT previously and it seems that guys make it work. Are you sure that MAP can’t work this way?

I believe it should work the way you had it - any command, use the MAP transform.

{mqtt=">[rpi:shutter/window/7/:command:*:MAP(] , <[rpi:shutter/window/7/status/:state:MAP(]"}

You do have the map transformation service installed, yes?

But …

is exactly what you should see. The openHAB Item will receive the command UP from the UI. That UP command will get passed to the MQTT1 binding, then the transform should be applied.
What you are interested in is the outbound MQTT message.

Thanks @rossko57 for your explanation.

Map transformation is installed and works great with other items, but not with this one :confused:

When I hit the UP button in basic UI, transformation UP-> 1 don’t happen.
I receive UP payload in the MQTT topic.

Any idea why the transformation is not processed or how to debug this?

Could you tell us how you know this?
Would you show us a console initiated MQTT message (that works) and a UI initiated message (that doesn’t work)?

Nope. If you are getting UP in the payload, this suggests that the transform is not failing, it’s not being called.

I listen shutter/window/# topic using MQTT.fx and see incoming messages having payload UP:

I’ve rewrite the Item as:

Rollershutter Shutter_office_side "Office side" <Shutter> (Shutter_downstairs) [ "Shutter" ]	{mqtt=">[rpi:shutter/window/7/:command:UP:1], >[rpi:shutter/window/7/:command:DOWN:2], >[rpi:shutter/window/7/:command:STOP:0], <[rpi:shutter/status/window/7/:state:MAP(]", autoupdate="false"}

and it works! So I’ll keep it like this.
Thanks for your help. The issue is really in the transformation service itself. Will look into this.

1 Like
rule "transform tester"
   Item Shutter_office_side received command
   logInfo("test", "Transforming command " + receivedCommand)
   var ttest = transform("MAP", "", receivedCommand.toString)
   logInfo("test", "Transforming result " + ttest)

I wonder if there is some oddity about transform results as numbers here. MAP always returns strings, so we should get “1” really; but the binding should handle that.

Thanks @rossko57.
Having the issues described above I have migrated MQTT binding from 1.x to 2.4

Sonoff switches works fine now. Your Rule was helpful for debug, thanks for that.

Unfortunately I run into a a know bug: Binding-mqtt - 2.5.0.SNAPSHOT; rollershutter command is sent wrong
which prevents Rollershutter type works in Basic UI.

Rollershutter item type publishes:
0 for stop
0 for up
100 for down

You think there might be a workaround for this?
Maybe leaving rollershutter type and use own buttons and Rules or smth like that?

Maybe use a rollershutter Item, but don’t link it MQTT at all. Well, not for commands, you could link it to listen for incoming position state.

Write a rule that listens for commands to the Item and issues whatever MQTT Actions you want.

Doing it that way, it’ll be easy to change to doing the “nice” way when the updated binding is available.