Transform a range?

Is there a way to transform a whole range of numbers. Something like a map() function in arduino.
For example to transform the numbers from 234 to 833 into a range from 0 to 100.

I guess MAP will not work and I can’t find ANY documentation or examples of SCALE.

Thank you!

I believe you can do this most easily though a JavaScrip(JS) transform: http://docs.openhab.org/addons/transformations/javascript/readme.html
For example, here a simple rule to translate from Fahrenheit into Celsius:

(function(i){
	return (i-32)*5/9;
})(input)

You have to save this as a file in the transformation folder.

2 Likes

You may want to check out this: http://docs.openhab.org/addons/transformations/scale/readme.html
Documentation plus examples, kindly provided…

1 Like

I found that, bu as I understand those examples it transforms a renge of numbers into a string… not into a nother range.

Unless it would work like this: ?

[12…23]=[0…100]

The SCALE transform is unlikely to do what you want, but I wanted you be aware of where to find the docs in case you need it again. For what you need, you will either need to write a rule or use the javascript transform as indicated above.