MAP transformation profile not working for number items

  • Platform information:
    • Hardware: Raspberry Pi 3B
    • OS: openHABian
    • Java Runtime Environment: Zulu8.40.0.178-CA-linux_aarch32hf
    • openHAB version: 2.5.0.M2
  • Issue of the topic:

Using MAP transformation as a profile doesn’t seem to work for Number items. Tried with items defined in PaperUI as well as via .items file:
Number Thermostat_Mode_Test "Modus: %s" {channel="zwave:device:6a4485d3:node9:thermostat_mode"[profile="transform:MAP", function="thermostat_mode.map", sourceFormat="%s"]}

The according thermostat_mode.map file:

0=AUS
0.0=AUS
1=EIN (Zeitplan)
1.0=EIN (Zeitplan)
=unbekannt

For String items the transformation works as expected (didn’t try other item types).
There are no errors or warnings found in the logs according to that issue.
Since using profiles seems to be the only way to do transformation on items created in PaperUI, I don’t know how to workaround.

Don’t know if this is expected behaviour or if I should file an issue on github?

Best regards,
Hans

Does your label work? I would assume there is a missing [] like this “Modus: [%s]”
But I dont know if it has any influence on the profile though.

You’re right, but unfortunately it doesn’t have any influence on the described issue.

You could try without the profile…I use map transform like this in items:

Number nilan_Control_State	      "Actual control state [MAP(nilan_control_state.map):%s]"    		<settings>  		{channel="modbus:data:myNilan:statusRegisters:inp1002:number"}

Notice I have the transform file inside the label.

Yes, it is. You are using the MAP to transform a number like 0 into a string like “AUS”.
You cannot fit a string into a Number type Item.

So this sounds logical to me, but this means that using transformation as a profile is different from using it in the item label. So, do I understand correctly that the transformation profile does rather transform the item state than it’s label? Is there any other way to add transformation on the item label via PaperUI?

I know, but this doesn’t work for items created via PaperUI…

Yes, very much so.

You can transform a channel using profile in between binding and Item.
This is what you were doing, the transformed value will be used for Item state. (attempted in this case)

You can transform an Item state in between Item and UI display.
This is @Kim_Andersen example.
You see the transformed value in your UI but the Item state remains unchanged.

Some bindings allow transforms to be given in config.
These work between raw data and channel e.g. an MQTT message “On” could be transformed to an openHAB friendly ON in a switch channel.

As already mentioned, this doesn’t seem to work in PaperUI (not only for the label shown in PaperUI, but the label isn’t transformed at all as it would be if defined via .items file).

A little off-topic:
Seems that item creation is rather different anyway when comparing configuration via PaperUI and .items file. When comparing results in the REST interface (besides the state and group):

  • PaperUI item:
{"link":"http://192.168.1.3:8080/rest/items/Thermostat_Mode","state":"0","editable":true,"type":"Number","name":"Thermostat_Mode","label":"Einstellung Thermostat: [MAP(thermostat_mode.map):%s]","category":"Switch","tags":[],"groupNames":["gEinstellungen"]}
  • .items file item:
{"link":"http://192.168.1.3:8080/rest/items/Thermostat_Mode_Test","state":"1.0","transformedState":"EIN (Zeitplan)","stateDescription":{"pattern":"MAP(thermostat_mode.map):%s","readOnly":false,"options":[{"value":"0","label":"Off"},{"value":"1","label":"On"}]},"commandDescription":{"commandOptions":[{"command":"0","label":"Off"},{"command":"1","label":"On"}]},"editable":false,"type":"Number","name":"Thermostat_Mode_Test","label":"Einstellung Thermostat:","tags":[],"groupNames":[]}

I just tried to configure all my 2.x items via PaperUI, as I wanted to use openHAB 2 technologies and advantages (avoiding configuration issues, single source of truth) as discussed in Next generation design : Ideas & Discussions. But I think I take the effort and go back to use .items files, since PaperUI has too much limitations up to now, which I didn’t expect.
I know that PaperUI is going to be substituted by a new UI in the future, and I really hope this can be handled better then, but I don’t think I can await the changes without using .items files :neutral_face:.

No, its not intended to.
PaperUI is an administrators interface, not intended for end users. As such, it shows you the actual state of the Items.

That’s a fascinating observation. That xxx.items definitions pull out the [format] into a different box, but PaperUI leaves it in the label.
I can assure you that both work, [format] including transforms is applied in BasicUI etc., just tried it all out.

1 Like

Unfortunately not in HABpanel. I think the HABpanel itemValue() uses the transformedState field provided by the REST interface, but this is only available for items defined by .items files according to the observations above.

HABpanel, now. I don’t use it, but I think transformed or not is under the panel builder’s control using option [ignoreTransform]

Loong thread about an old limitation of HABpanel goes into interesting detail.