Formatting dot numbers on German OS

I am receiving a Temperature value via MQTT.
This is a string that can contain a dot as a decimal separator.
For example ‘22’ or ‘22.2’
I want to display this temperature with Home Remote in a coherent way.
so 20 will be 20,0
20.1 will be 20,1

I used a Label with Multibinding and set StringFormat to {0:N1}
The issue now is, that a value like 20.1 gets displayed as 201,0 in the UI. This is being output in the same way in the Simulator and my IOS device.
I assume the issue here is the locale setting. Is there a way to work around this issue?

All of the built-in integrations handle these decimal conversions automatically. Generic sources like MQTT on the other hand will display the exact raw value.

Yes, the locale setting is hurting you in this case with your StringFormat {0:N1}. It’s because there is a mismatch. The MQTT value is in a different locale than your device. It’s trying to convert 20.1 to a numeric value but the thing is, with this numeric conversion, it uses the system’s current locale. The numeric conversion is assuming the decimal separator for the MQTT value is a comma “,” not “.”. For these numeric StringFormats to work, the value needs to match the system locale.

I suppose I need to add another property to each MQTTVariable where you can specify the data type for the topic & its decimal separator. Although, I haven’t been making very many changes to that device lately. I’ve really been encouraging users to use Plugins instead. In a plugin, you yourself have full control over the device. I think that’s going to be your best bet here. Use a plugin instead & then you can do the conversion yourself.

Ok. Thanks for the info.

Might still be a good idea to find a way to streamline this process for general data sources. Maybe offer basic text processing on the side of the controls where the data arrives. Search&replace, regex or even simple script processing on incoming data (without having to write a whole plugin).

I have discovered home remote round about two years ago and then wondered how this was supposed to work. The documentation seems incomplete on many topics. Some help links in the program lead to 404 sites. I still haven’t bought it since i wanted to have a working ui first. Just now i had more time to dive into home remote again. I am surprised that stuff like this isn’t more accessible. Not everyone is a programmer and either way it takes away a lot of time diving into plugins, since the integrated one that is offered is crippled.

Now to revisit this issue a few month later, since i only now had time to actually look into how plugins are supposed to work. Honestly the documentation on these is very lacking.

What i want to do is to be able to subscribe to arbitrary topics and push a value to arbitrary topics to be then later fix the incoming values with the correct number formatting. Apparently plugins do work with “devices” and as such i tried to define a device for each topic i am interested in.

My code is posted below. It doesn’t work yet, since apparently it doesn’t let me properly index all the available devices in the onPoll function. I tried to append the publish and subscribe Topics to the Id of the device, since i am not sure how such values could be otherwise stored in these objects. I hope to get some input on how to properly implement this plugin.

plugin.Name = "Test_MQTT";
plugin.OnChangeRequest = onChangeRequest;
plugin.OnConnect = onConnect;
plugin.OnDisconnect = onDisconnect;
plugin.OnPoll = onPoll;
plugin.OnSynchronizeDevices = onSynchronizeDevices;
plugin.PollingInterval = 500;
plugin.DefaultSettings = { "Host": "", "Port": "", "Username": "", "Password": "" };

var mqtt = new MQTTClient();
var subscribed = false;

function onChangeRequest(device, attribute, value) {
	// TODO
}

function onConnect() {
    mqtt.connect("mqtt://" + plugin.Settings["Username"] + ":" + plugin.Settings["Password"] + "@" + plugin.Settings["Host"] + ":" + plugin.Settings["Port"]);
    //This method is shared with both "onPoll" & "onSynchronizeDevices"
    //We need to subscribe to different sets of topics for those functions.
    //That's why we aren't subscribing here.
    //Connecting with default options will clean our subscriptions, so we need to reset our "subscribed" variable.
    subscribed = false;
    console.log("connected");
}

function onDisconnect() {
    mqtt.disconnect();
    console.log("disconnected");
}

function onPoll() {
    //Even though we have an infinite "while" loop below that reads messages, we need to consider the possiblity that a previous "onPoll" call was cancelled.
    //And we don't want to send more subscribe requests than we need.
    //So after we subscribe, set the "subscribed" variable so we know we are confidently subscribed.

	if (!subscribed) {
		var subscribeTopics = [];
		for (var curDevice in plugin.Devices) {
			var deviceIdParts = curDevice.Id.split(":");
			var subscribeTopic = deviceIdParts[1];
			if (subscribeTopic.length > 0) {
				subscribeTopics.push(subscribeTopic);
			}
		}

		mqtt.subscribe(subscribeTopics);
		subscribed = true;
    }
    while (true) {
        var message = mqtt.readMessage();
            var device = null;
            
		for (var curDevice in plugin.Devices) {
			var deviceIdParts = curDevice.Id.split(":");
			var subscribeTopic = deviceIdParts[1];
			if (subscribeTopic.length > 0) {
				if (subscribeTopic.toUpperCase() === message.topic.toUpperCase()) {
					device = curDevice;
					break;
				}
			}
		}
            
            if (device != null) {
                var payload = message.payload.toString();
                device.Variable = payload;
            }
    
    }
}

function newDevice(deviceId, subscribeTopic, publishTopic)
{
console.log(deviceId);
	device = new Device();
	device.DisplayName = deviceId;
	device.Id = deviceId + ':' + subscribeTopic + ':' + publishTopic;
	var attributes = [];
	attributes.push("Variable");
	device.Attributes = attributes;

	plugin.Devices[deviceId] = device;
	console.log(device.Id);
}

function onSynchronizeDevices() {
	newDevice("HelloId", "Hello/test", "Hello/test/set");
	newDevice("Hello2Id", "Hello/test2", "Hello/test2/set");
}

You aren’t using the “for” loops correctly. This is JavaScript, they work a little differently than other languages.

This is how your loops should look:

for (var curDeviceId in plugin.Devices) {
    var curDevice = plugin.Devices[curDeviceId];
    // The rest of your code...
}

https://www.w3schools.com/js/js_loop_forin.asp