MQTT Binding and problem with decimal commas

Hi.

I’m trying to setup a binding between OpenHAB and Homeseer and I’m having some issues with comma separated decimal values in temperatures.

How can I make the MQTT Binding accept (convert on the fly or whatever) values with decimals separated by commas?

For example, this item:
Number TestTemperature3 “Temperatura Despacho [%.1f ºC]” (gDespacho,gTemperaturas) {mqtt="<[mymosquitto:homeseer/5/value:state:default]"}

This MQTT message: /homeseer/5/value : [msg] : object
{ “topic”: “/homeseer/5/value”, “payload”: “25,3”, “qos”: 0, “retain”: false, “_msgid”: “9a0b3fff.65f4c” }

Probably it’s possible to solve it with REGEX or a transformation, but I don’t know how to do it.

Thank you very much in advance.

As a workaround I wrote a flow in node-red to sustitute commas into dots but I will be very thankful if someone tells me how to fix it so I don’t need to use these calls for such a simple thing.

You can use the JS Transform to do it.

Here are the relevant snippets for doing it in a Rule, but they can equally be applied into an Item Transform (as long as the Binding supports Transforms):

in configurations/transform/europeanNumber.js:

(function(i) {
   return i.replace(",", ".")
})(input)

and then a Rule like:

import org.openhab.core.library.items.*

rule "test european-formatted-number"
when
    Time cron "0/5 * * * * ?"
then
    var out = transform("JS", "europeanNumber.js", "23,4")
    logInfo("test-number", out)
end

It’s not 100% correct, since I should also transform.” into “,” for the 1000’s separator (etc). Not sure why the MQTT/HomeSeer app is encoding it’s numbers that way. I suspect if you switched the openHAB Locale settings, prior to startup, that you could get it to work also.