None of my transformations are working - frustrated

Hello,

Running an OpenHAB installation on a physical Ubuntu box, OpenHAB version 3.3.0.M2.

I have built a simple Arduino -device and have this setup at the summer villa 200km away, measuring outdoor and indoor temperatures and indoor humidity. It is sending all the data back to a MQTT server I have running on Unraid, I then have an mqtt thing for the arduino in OpenHAB which works fine and is collecting the outdoor temp and indoor humidity perfectly, without problem.

Now, I probably made a small mistake in the code of the arduino as it is sending the indoor temp with an extra space at the end of the number - like "-2.40 " at the moment. So OpenHAB says “not supported by type ‘NumberValue’” and does not accept the value. No problem, right, just transform the space out? Well…

I first tried a javascript transformation just like it is presented in the docs. Made a javascript that trims the space out, saved it in a file and pointed the channel configuration to it like this:

I also tried with the path transform\trim.js and also like JS(transform\trim.js) but the number did not change, OpenHAB is still complaining. In fact it turns out I can write complete gibberish in the trim.js file and OpenHAB does not react, so clearly something is wrong there.

I then thought to try REGEX as it does not require a file. So I created a suitable REGEX string and entered it like this:

I also tried different forms for the text, like having REGEX: in the beginning etc. but to no avail. Again, in fact, I can write any gibberish in the profile configuration without OpenHAB noticing it at all.

So apparently my transformations are not being accepted or even not read at all by OpenHAB. What might be the issue? They are definitely installed, but are they not being used for some reason?

I would appreaciate some help on this - I realize I can do this through rules but this should be about as simple a transformation that exists and still it is not working, I am very frustrated.

The problem isn’t your transforms. The problem is where you are trying to use the transforms.

From the screenshots you’ve posted we can see that you are trying to use a profile to transform the value. Profiles act on the link between the channel and an item. But the problem as you’ve stated it is that the MQTT channel cannot even get the correct value because the info coming from the external source doesn’t match the channel’s expectations. So there’s no value coming from the channel for the profile to try and transform.

You’re correct that a transform is the solution, but instead of a profile, you have to go into the channel configuration and apply the transform there (I don’t use the mqtt binding, but it should be clear how to setup the transform as part of the channel, if not, refer to the binding docs).

Thank you - this indeed was the issue! For some reason I assumed the channel captured the “raw” data and the transformation would be performed from the channel to the item, but it had to be done in the channel. Now everything works.