Value of item as description of another item?


I have OpenHab 3.2.0 set up and working. I am tring to add contol to my blinds, and it works too, but at the moment I have to things (one switch for controling blinds and second an integer value in the rage of 0 … 255 which gives me a blind position).

For now I set up two items too, but this is not looking nice. It would be better to have one switch, and in the description of it a value of the position. It would be perfect if that value would change icons as it is now - when value is 0 icon is open, when 100 it is closed). The metter of scale range 0 … 255 to 0 … 100 is not my problem at the moment and should be easy to fix later.

Is it possible to make above scenario to work as intended?

It sounds like you are talking about presentation, some UI widget? Which UI are you using?

Yes, forgive me. I’m using Basic UI.

Alright, so you are using a xxx.sitemap file, and you may use dynamic icons in the usual way.
If you create a set of images like -
then for a numeric value 0 to 100, the -0 image is displayed for 0 Item state, the -1 image for all states 1 to 100

Note that dynamic icon does not work properly in this way for numbers over 100

Yes, it is already working this is not my problem. As I said I have two things and two items which are listed in the sitemap file. So in the UI I have one switch and a number below which translates to the position of the blind. Now I would like to have in the site map only one item. Inthe description of the switch item I would like to have a number (posisiton of the blind).

Switch item=yourRoller label="Shutter [%d]" icon=yourIcon

I haven’t tried it yet, but how OH suppose to know to get the number from other item?

Now i have in things file (one is for read/write modbus coil and the second one is for reading modbus holding register (position of the blind):

Thing data RoletaGabinet [ readStart="112", readValueType="bit", writeStart="112", writeValueType="bit", writeType="coil", writeTransform="JS(one.js)"]

Thing data BlindOfficePos [ readStart="10", lenght=1, readValueType="int16" ]

abd items file:

Switch   FF_Office_Blind        "Roleta w gabinecie"         <blinds>         (FF_Office, gBlinds)          ["Blinds", "Switchable"]   {channel="modbus:data:wagoMB:coils:RoletaGabinet:switch

Number   FF_Office_Blind_Pos    "Pozycja rolety"             <blinds> (FF_Office) {channel="modbus:data:wagoMB:holdings:BlindOfficePos:number"}

If I understand what you are after the closest you can get is to use Label and Value Colors which is one of only places in sitemaps where an entry can refer to two separate Items in the same widget (the other is visibility).

If that doesn’t suffice, you’ll have to use MainUI or HABPanel.

There is only one Item involved in the UI widget.

Number   FF_Office_Blind_Pos    "Pozycja rolety"  ...

If you don’t ask for a state display, you don’t get one.
You wanted the number displayed, so ask for it -

Number   FF_Office_Blind_Pos    "Pozycja rolety [%d]"  ...

Then you want it displayed in switch type widget

Switch item=FF_Office_Blind_Pos

You do not have to use Switch type Items with Switch type UI widgets.


If you move the toggle/slider on the UI it will send ON or OFF command to your Number type Item, that’s not accepted.

You might want to use a Dimmer type Item instead, which has a 0-100 state and will deal with both number commands and on/off commands.
Then you’d need a rule to intercept those commands to the Number Item and convert them to commands to your FF_Office_Blind switch Item.


stay with the Number type Item, but use the switch widget in "button"mode instead, with mappings.

Switch item=FF_Office_Blind_Pos mappings=[0="beep",100="boop"]

which will send number commands.
I think you’ll still need a rule to intercept those commands, and convert to ON/OFF command for the other Item.

You can have the visual simplicity that you want, but have to put in a bit of work behind the scenes.