variable for slider value

I have a volume slider which can be set from 0 - 20

The value should be used in a command like: MV${param}

Now the problem: the value ${param} should represent is always 2-digits ( 00 , 01 , 02 etc.)
I need the first values to have a leading zero.

You will have to use rules for this. Then you can format a string sent any way you like.

I tried this:

package org.openremote.controller.protocol;

global org.openremote.controller.statuscache.CommandFacade execute;

import java.util.*;

rule “CEOL Volume einstellen” when

$evt:Event( source == “Volume Slider”, $val : value)


String valStr = $val.toString();

if (valStr != null ) {

        String twodigits = String.format("%02d", valStr);

  execute.command( "Volume einstellen TCPIP", twodigits);


but it does not work…