MQTT not sending the calculated value outside from Openhab

I have the results of my Transformation on my Openhab thats good. But If I want the same Item value sent to Grafana via InfluxDB (outside from Openhab) it gives me the raw value of the item! which means JSONPATH($.ANALOG.A0) and not the results of “Voltage [JS(VoltageCorr.js):%.1f]”

How can I send that calculation result outside?

Thank you

Yes, that is exactly what is supposed to happen. Influxdb stores the Item state.

You’d need to get it into an Item state.

The easiest way might be to write a JS transform that does both the JSONPATH and the caclulation, and use that in your MQTT configuration.

If you used MQTT version 2 binding, you could chain two transformations. But you can’t with version 1.

Thanks Rossko57 !

I have tried these but no return. - anything wron in the syntax?

Number Vbattery {mqtt="<[broker:topic:state:JS(VoltageCorr.js)]"}

//Number Vbattery { mqtt="<[broker:topic:state:JSONPATH($.VoltageCorr.js)]" }

//Number Vbattery { mqtt="<[broker:topic:state:JSONPATH(VoltageCorr.js)]" }

Thanks again

You are using the MQTT version 1, as stated before chaining is possible with version 2 onlyl

Well, you started off by needing to extract the part you were interested in from the MQTT payload using JSONPATH.
When you do not use JSONPATH, you do not get the part you are interested in.
So there is no part for your javascript to process.

I suggested that you write a new javascript, and that you make that javascript handle both getting the JSON part that you want from the MQTT payload, and do whatever maths that your existing javascript does.

You cannot use two separate transformations because you have chosen to use MQTT binding version 1, which allows only one transformation.
But you can script your one transformation to do both tasks, JSON and maths.