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).
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.
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.
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