[Solved] HABPanel - Transformation "Scale" is not recognized by HABPanel

Hi,
I am using OpenHAB v2.5.6 running in an docker container on my x86 NAS and just migrated from Darksky to Openweathermap. OWM provides the current wind direction in a Number:Angle format and I use a transformation scaling in the item definition file to translate the angle into “human readable” wind direction. But HABPanel does not recognize that.

How can I transform the angle value in HABPanel to show the wind direction word?

Here are is the appropriate information:

Item definition in the items file:

Number:Angle  localCurrentWindDirection "Current wind direction [SCALE(winddirection.scale):%s %unit%]" <wind> { channel="openweathermap:weather-and-forecast:api:local:current#wind-direction" }

winddirections.scale file:

[0..11.25[ = N
[11.25..33.75[ = N-NO
[33.75..56.25[ = NO
[56.25..78.75[ = O-NO
[78.75..101.25[ = O
[101.25..123.75[ = O-SO
[123.75..146.25[ = S
[146.25..168.75[ = S-SO
[168.75..191.25[ = S
[191.25..213.75[ = S-SW
[213.75..236.25[ = SW
[236.25..258.75[ = W-Sw
[258.75..281.25[ = W
[281.25..303.75[ = W-NW
[303.75..326.25[ = NW
[326.25..348.75[ = N-NW
[348.75..360] = N

Basic UI presentation:

HABPanel presentation (Richtung = Direction):
image

HABPanel Definition:

I already tried to put the SCALE(winddirection.scale) command into the format field and tried using the “server-side format” checkbox but the I only get whole transformation string + the untransformed angle value.

It must be working differently but I do not know how.

I kindly appreciate any idea or hint how to solve that :slight_smile:

Thank you
Justus!

The little tickbox at bottom should do the trick.

Hi @rossko57 ,

thanks for the idea … I tried this already

but it does not work …

When I check the tickbox:

The outcome is:

image

:frowning:

You would need to do the transformation on the item level , in other words in the .items file.

There is a discrepancy here, filename (s). Maybe it is only a typo, because you should have seen complaints in your logs.

There is weirdness in your [state presentation] part. You cannot have %unit% with a transform, the transform’s output is a string with no units. I would not have expected that to be terminal though.

Top tip; put a default “catchall” entry in your scale file so that you can see unexpected non-matches.
It’s in the docs

Hi Jürgen, thx but see above I do the translation in the items file :slight_smile:

Number:Angle          localCurrentWindDirection "Current wind direction [SCALE(winddirection.scale):%s %unit%]" <wind> { channel="openweathermap:weather-and-forecast:api:local:current#wind-direction" }

Hi @rossko57,
this was only a typo in my writing in this topic:

admin@MY_NAS:/.../docker/openHAB/2.5.6/conf/transform$ ls -l winddirection.scale 
-rw-rw-rw- 1 9001 9001 368 Sep 12 10:46 winddirection.scale
admin@MY_NAS:/.../docker/openHAB/2.5.6/conf/transform$ 

And as stated above the transformation works in the Basic UI (see screenshot above)

There is a similar issue with the MAPcommand in another topic …

I am checking if there are parallel indicators.

Thank you for your support!

I played a bit around with setting some values from the transformation file winddirection.scale

I set the value 217, 138, 320 using the REST API UI and I see that the Basic UI is transforming but not HABPanel and getting the item state via REST API UI also shows the number not the translated winddirection???

By the way the sitemap entry for localCurrentWindDirection looks like this:

        Text item=localCurrentHumidity
        Text item=localCurrentWindSpeed
        Text item=localCurrentWindDirection
        Text item=localCurrentCloudiness

No transformation in the sitemap file …

I am curious … when using the transformation in the items definition:

Number:Angle  localCurrentWindDirection "Current wind direction [SCALE(winddirection.scale):%s %unit%]" <wind> { channel="openweathermap:weather-and-forecast:api:local:current#wind-direction" }

Should the output of -GET- /items/{itemname}/state in the REST-API UI show:

"217.0" or should it show “SW” ???

Ok,

played a little around and when I change the item defintion to:

Number:Dimensionless
and
[SCALE(winddirection.scale):%s] without unit

Number:Dimensionless  localCurrentWindDirection "Current wind direction [SCALE(winddirection.scale):%s]" <wind> { channel="openweathermap:weather-and-forecast:api:local:current#wind-direction" }

It works :thinking:
Ok, seems that HABPanel has some issues with the number classification and the units …

Why did you have the unit in the format in the first place? Your scale takes the angle and transforms it into a cardinal direction, which has no unit anyway.

1 Like

Hi @CrazyIvan359,
I have copied the items definition from the documentation and the added the transformation …
Looking back, of course the outcome after the transformation is a string and has no more unit. But I was mislead by the Basic UI where also this wrong item definition was displayed correctly. I needed the feedback of the community to discover my wrong definition and to correctly understand how the transformation works :slight_smile:

Thanks to all for sharing your thoughts and giving me advise to find the solution.

Cheers
Justus

I also find this curious. Glad it’s working now.

You do not want that either. This is not “just a number”, it is a Quantity Type. It does have units, but the units have no real dimensions. Huh? Well, think of percentage - it’s a ratio, with units of %

Hi @rossko57,

so what do I want the … shall I change it back to Number:Angle but leave the %unit% in the item definition?

Thanks for your advice!
Cheers Justus

Ok, I have changed my item definition to:

Number:Angle  localCurrentWindDirection "Current wind direction [SCALE(winddirection.scale):%s]" <wind> { channel="openweathermap:weather-and-forecast:api:local:current#wind-direction" }

with Number:Angle but without %unit% … and it still works …

I leave it now like this: “Never Touch A Running System” :stuck_out_tongue:

1 Like