Define a scale for Slider

I created an item for the brightness of a light.

Number sLED_brightness "Brightness [%d]" <light> { mqtt="<[mosquitto:homie/5ccf7f15b638/light/brightness:state:default], >[mosquitto:homie/5ccf7f15b638/light/brightness/set:command:*:default]" }

The brightnes can range from 0 to 255.
The Slider goes from 0 to 100.

How can I scale/transform these automatically in openhab?

I guess a workaround would be to create a transformation file with 100 entries.

[0..3]=1
[4..6]=2
[7..9]=3
....
[253..255]=100

Hey Christoph!

There was a very similar question three days ago:

Your problem should be a perfect candidate for a javascript transformation. Looking at your example scale: I’d say it’s important to make sure that the transformation maps 0 to 0 and 255 to 100.
Good luck :wink:

1 Like

Thanks.

But I already modified my Arduino sketch to work with percentage (0-100).
This is easier for a person.
And Arduino has a simple map-function for this. :wink:

But its nice to see there is a good solution for such problems. :slight_smile:

1 Like