[SOLVED] Scale and decimals

Hi folks,

I’m trying to use a scale transformation to convert wind strengh (mph) to beaufort index.

The problem is the wind strengh can be decimal, not only integer: eg. 3.51 mph
And in that case I’m not able to work with scale:

2018-08-21 15:08:45.028 [WARN ] [rm.AbstractFileTransformationService] - Could not transform '3.51' with the file 'beaufort_mph.scale' : No matching range for '3.51'

My item:

Number Http_darkSKY_fore_windgust "Gust Strength [%.0f mph]" (gOutdoor, gWeather) { http="<[darkSKY:10000:JSONPATH($.daily.data[1].windGust)]"}

Sitemap:

Text item=Http_darkSKY_fore_windgust label="Beaufort (Gust) [SCALE(beaufort_mph.scale):%s]" icon="meteoalarm_wind" valuecolor=[>=73="purple",>=55="fuchsia",>=39="red",>=25="orange",<25="green"]

my beaufort_mph.scale file:

[..1[=Calm
[1..3]=Light Air
[4..7]=Light Breeze
[8..12]=Gentle Breeze
[13..18]=Moderate Breeze
[19..24]=Fresh Breeze
[25..31]=Strong Breeze
[32..38]=High Wind
[39..46]=Gale
[47..54]=Strong Gale
[55..63]=Storm
[64..72]=Violent Storm
]72..]=Hurricane

I was expecting any fraction between end points would be good, integer or decimal. Not true, as I can see.
Any suggestion?

thanks
Andrea

I’ve never used the scale transformation but looking at the doc’s here:

https://www.openhab.org/addons/transformations/scale/#example

the brackets may need to be changed/reoriented ??

Screenshot%20at%202018-08-21%2008-30-30

This is correct, there is no matching range for 3.51:

[..1[=Calm
[1..3]=Light Air
[4..7]=Light Breeze
[8..12]=Gentle Breeze
[13..18]=Moderate Breeze
[19..24]=Fresh Breeze
[25..31]=Strong Breeze
[32..38]=High Wind
[39..46]=Gale
[47..54]=Strong Gale
[55..63]=Storm
[64..72]=Violent Storm
]72..]=Hurricane

There in nothing between 3 and 4, or 7 and 8, or 12 and 13…

Change it like this:

[..1[=Calm
[1..4[=Light Air
[4..8[=Light Breeze
[8..13[=Gentle Breeze
[13..19[=Moderate Breeze
[19..25[=Fresh Breeze
[25..33[=Strong Breeze
[32..39[=High Wind
[39..47[=Gale
[47..55[=Strong Gale
[55..64[=Storm
[64..72[=Violent Storm
[72..]=Hurricane
1 Like

I didn’t see this example in the doc’s but other than the first and last entry would the result be the same if the left bracket only was turned ( i.e. ]1…4]=Light Air ) or what is the difference?

[1..3]=Light Air
[4..7]=Light Breeze

Stops at 3 inclusive and starts again at 4 inclusive

[1..4[=Light Air
[4..7]=Light Breeze

Is continuous
1 to 4 exclusive and then 4 inclusive to 7 exclusive

2 Likes

Thank you guys :sunny:

it works like a charm!

Andrea