Reversing Rollershutter MQTT Percentage in OpenHAB
Hello OpenHAB enthusiasts! ![]()
I came across Omar’s post about configuring rollershutters with MQTT in OpenHAB, and I wanted to share a solution that might help others facing a similar issue. If you’re finding that your rollershutter is opening and closing in the opposite direction of what you expect, you’re not alone! Let’s dive into how to fix this.
Understanding the Problem
Omar mentioned that their rollershutter was working but in the opposite direction. Specifically, 100% was fully closed, and 0% was fully open. This is a common issue when integrating devices with different manufacturers or protocols. The good news is that OpenHAB provides a straightforward way to reverse these percentages using the Map transformation.
Solution: Reversing the Percentage
The key to solving this issue lies in transforming the received MQTT messages. By using the Map transformation, we can reverse the percentage values so that 0% becomes 100% and vice versa. Here’s how you can do it:
Step 1: Configure the MQTT Binding
First, ensure your MQTT binding is correctly set up in OpenHAB. You’ll need to define the MQTT topics for both sending and receiving messages. For example:
plaintext
mqtt:topic=your/topic/state:state:default
mqtt:topic=your/topic/command:command:default
Step 2: Use the Map Transformation
Next, apply the Map transformation to reverse the percentage. This transformation will convert the received value into its inverse. Here’s an example configuration in your items file:
plaintext
Rollershutter MyRollershutter “Living Room Rollershutter” {
mqtt=“command=mqtts://yourbroker:1883/your/topic/command; state=mqtts://yourbroker:1883/your/topic/state”,
transformation=“MAP(reverse.map)”
}
Step 3: Create the Map File
Create a new file named reverse.map in the transform folder of your OpenHAB configuration directory. Add the following content to reverse the values:
plaintext
0=100
10=90
20=80
30=70
40=60
50=50
60=40
70=30
80=20
90=10
100=0
This map will transform 0% to 100% and 100% to 0%, effectively reversing the rollershutter’s direction.
Step 4: Test the Configuration
After applying these changes, restart your OpenHAB instance and test the rollershutter. Sending a 0% command should now fully open the rollershutter, and a 100% command should fully close it.
Additional Tips
- Customize the Map: If your rollershutter has different step values, adjust the
reverse.mapfile accordingly to match your device’s behavior. - Logging: Enable logging in OpenHAB to monitor the MQTT messages and ensure the transformations are working as expected.
- Community Support: If you run into any issues, don’t hesitate to ask for help in the OpenHAB community forums. There are plenty of experienced users who are happy to assist!
Conclusion
With a simple transformation, you can easily reverse the percentage values for your rollershutter, ensuring it operates in the desired direction. This is a great example of how OpenHAB’s flexibility can adapt to different hardware configurations. If you’ve successfully implemented this solution or have any tips to share, feel free to comment below! ![]()
Happy automating! ![]()