MQTT 2 Chained transformations

Tags: #<Tag:0x00007f616d607798> #<Tag:0x00007f616d607630> #<Tag:0x00007f616d6074f0>


My system:Openhabian 1.5 on Pi4, Openhab 2.5M4 and MQTT2.
I have installed JSONPath and Javascript transformations, and is using them on other MQTT things/items and it is working.

But when i try to combine theese two, I can not get this right.

Can anyone post an example of a working in-comming MQTT telegram with js and JSONPath?

My goal is to divide the value wrapped in an MQTT telegram with JSON, without having to use two items.

Why don’t you use only JS
For example:

(function(volvo) {
    var data = JSON.parse(volvo);
    var heading = data._vehicle.calculatedPosition.heading;
    if (heading === null) {
        heading = 999;
    return heading/100;

Other wise the syntax will like this:

Then I have to create an own js for each item, this should be a reusable solution with minimal configuration for each thing.
Of what I understand from the post below, it should be possible from 2.5?

see post above
You need to use the intersection symbol:

I have tried that, but without luck. I am using that same tidel.js with sucess on other telegrams, see images below:


Did you install the JS transformation?

Yes I have that installed and in use on other things.

To be honest I never tried it because the need never really came up.

Have you tried the other way around?

Please post your code and logs in code fences

If it still doesn’t work it will be worth posting an issue on gitHub

Yes I have tried both ways. Yes I will report it on gitHub.

1 Like

There does not exist any test case for chained transformations to be honest.
Some people wanted them and there they are, but I did not use them myself.

In theory they should work because transformations itself work. And chained transformations is really just splitting the input string on the intersection character and applying those multiple transformations one after the other.

It is actually working, but OH have to be restarted every time I change the mqtt.things file.


Did you also try only to restart the bundle?
openHAB Add-ons :: Bundles :: MQTT Things and Channels

For me this helps after editing the MQTT.things files, I do not have to restart OH completely.

Post an issue on Github

For me I have to restart Openhab and not only the bundle.
Have tried both bundle:stop - bundle:start and bundle:restart.