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="", sourceFormat="%s"]}

The according file:

1=EIN (Zeitplan)
1.0=EIN (Zeitplan)

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,

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(]"    		<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":"","state":"0","editable":true,"type":"Number","name":"Thermostat_Mode","label":"Einstellung Thermostat: [MAP(]","category":"Switch","tags":[],"groupNames":["gEinstellungen"]}
  • .items file item:
{"link":"","state":"1.0","transformedState":"EIN (Zeitplan)","stateDescription":{"pattern":"MAP(","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.

Hey together,

I have some troubles understanding transformation from a number to a string
is it because of the sourceFormat="%s"

Number netatmo_outdoor_signal_number "Outdoor Signal [%d]" <qualityofservice> {channel="netatmo:NAModule1:98a11d89:020000291578:RfStatus"}
String netatmo_outdoor_signal "Outdoor Signal [MAP(]" <qualityofservice> {channel="netatmo:NAModule1:98a11d89:020000291578:RfStatus"}

my file: (is the space in no signal allowed like this btw?)

0=no signal

I get this:



The %s here will be applied to the output of the transformation.
Transformation always return strings, so %s is the correct thing to do.

Yes. Spaces require special treatment on the look-up side, to the left of =, but not on the output side, to the right of =

It looks like you don’t have MAP transformation installed?
Quite why it casts it to datestamp is a mystery though.
EDIT - oh wait, you’ve tried to put the netatmo number channel value into a String type Item. Don’t do that, do your MAP on the Number type Item.

I would recommend adding a default case to your map file, in case of unexpected values

@rossko57 you are literally awesome
I have the slight feeling you are involved in every topic here - thumbs up

You’re absolutely right and I can understand the other posts about transformation in this topic now clearly especially the difference between transformation as profile vs transformation in item label

It’s only a pitty when I use profile transformation the Item is not presented in PaperUI under Control

String netatmo_outdoor_signal_string "Outdoor Signal" <qualityofservice> {channel="netatmo:NAModule1:98a11d89:020000291578:RfStatus"[profile="transform:MAP", function="", sourceFormat="%s"]}

only =unknown to the end of my map file like a “catch everything else”?

Yup. Newish feature since 2.4

1 Like