[SOLVED] Scale transformation not working for Sitemap:Selection

  • Platform information:

    • Hardware: Intel 64bit, 2GB RAM, 17G free disk
    • OS: Debian GNU/Linux 9.4
    • Java Runtime Environment: Java™ SE Runtime Environment (build 1.8.0_151-b12)
    • openHAB version: openhab2 2.3.0~20180417031559-1
  • Issue of the topic:
    I use “selections” on my sitemap for my rollershutters (mappings=[0=“OFFEN”, 20=“25%”, 40=“50%”, 60=“75%”, 90=“SCHLITZE”, 100=“ZU”]).
    So that the user always has a state for the selection, I used a scale transformation to translate the ranges to my mappings. Example
    0-19=0, 20-39=20 and so on (see transformation below).
    That meen’s, shuttertest.state=22, transformation to 20, selection “25%” selected.
    With oh2.0 everything was working fine, with 2.3.0~20180417031559-1 it seems that there is a bug? Or is it works as designed?
    When I switch in my sitemap from type:selection to type:slider, there is the correct value shown in front of the slider (see screenshots).

  • Please post configurations (if applicable):

    • Items configuration related to the issue
Rollershutter shuttertest
  • Sitemap configuration related to the issue
Selection item=shuttertest label="test [SCALE(rollladen.scale):%s]" mappings=[0="OFFEN", 20="25%", 40="50%", 60="75%", 90="SCHLITZE", 100="ZU"]
Slider item=shuttertest label="test [SCALE(rollladen.scale):%s]"
  • Transformation
cat transform/rollladen.scale
[..19]=0
[20..39]=20
[40..59]=40
[60..89]=60
[90..97]=90
[98..]=100
  • Karaf output
openhab> smarthome:items list |grep shuttertest
shuttertest (Type=RollershutterItem, State=22, Label=null, Category=null)

Items

Rollershutter shuttertest "test [SCALE(rollladen.scale):%s]"

Sitemap:

Selection item=shuttertest mappings=[0="OFFEN", 20="25%", 40="50%", 60="75%", 90="SCHLITZE", 100="ZU"]
Slider item=shuttertest

thanks for your fast response, vicent.
but unfortunately same behaviour. Also after an oh restart.

openhab> smarthome:send shuttertest 22
Command has been sent successfully.
openhab> smarthome:items list |grep test
shuttertest (Type=RollershutterItem, State=22, Label=test, Category=null)
openhab>

slider with value 20, selection with nothing selected. (same as screenshots above).

Sorry, I got confused.
The Selection item mapping will not work in this configuration because the actual value of the item remain 27% for example and is not changed by the scale transform.
you will need a second item and a rule to achieve the effect you require.

In openhab2 2.0.0~b5 it does work!

openhab> smarthome:send shuttertest 22
Command has been sent successfully.
openhab> smarthome:items list |grep test
shuttertest (Type=RollershutterItem, State=22, Label=test, Category=null)

So that is my question, is it a bug in 2.0 or 2.3?
For me, it is in 2.3, because what should be the added value of a scale transformation? Only to transform number items and representations (no slider, no selection and so on)?

State Transformation
Transformations can be used in the state part of an Item, to translate the raw state of an Item into another language, or to convert technical values into human readable information.

https://docs.openhab.org/configuration/items.html#state-transformation

So, selections should use the transformed state, not the raw state.

Has nobody an idea?

After my issue #707, it looks like, that it is no bug.
So, for everybody who is interested, here is my solution/workaround.

Items:

Rollershutter R14_Rollladen_umschalten "Rollladen R.14 [SCALE(rollladen.scale):%s]" (gR14, gSonnenschutz, gRollladen_umschalten) { channel="knx:device:router1:generic:R14_Rollladen" }
Number R14_Rollladen (gRollladen_status) { channel="knx:device:router1:generic:R14_Rollladen_status" }

Rule:

rule "rollladen_status_update"
when
  Item R16_Rollladen changed or
  Item R15_Rollladen_Garten changed or
  Item R15_Rollladen_Strasse changed or
  Item R14_Rollladen changed or
  Item R13_Rollladen changed or
  Item R12_Rollladen_Strasse changed or
  Item R12_Rollladen_Hof changed
then
  gRollladen_status.members.forEach [ item |
                                var trans = transform ("SCALE", "rollladen.scale", ((item.state  as DecimalType) * 100).toString)
                                val rollladen = gRollladen_umschalten.members.filter[ t | t.name == item.name+"_umschalten" ].head
                                rollladen.postUpdate( trans )
                        ]
end

Scale Transformations

[..19]=0
[20..39]=20
[40..59]=40
[60..89]=60
[90..97]=90
[98..]=100