Input validation in thing configuration

I was making some changes to my binding, and noticed that the thing configuration in Main UI only seems to allow two decimals in the text box.

Since these are fields for lat/long-coordinates I need higher precision than this (the weather service supports up to 6 decimal places).

In other places in the forum I’ve read that the UI gets the validation from the binding/thing xml, but I haven’t configured any restrictions to this. But to make sure I tried to set pattern="%.6f" in the config-description, but still the same result. What needs to be in the xml to make this work? Or is it a bug/limitation in the UI? In that case it needs to be fixed before the final release of OH3. @ysc?

My config-description:

	<config-description uri="thing-type:smhi:forecast">
		<parameter name="latitude" type="decimal" pattern="%.6f" required="true">
			<label>Latitude</label>
			<description>Latitude for the forecast</description>
		</parameter>
		<parameter name="longitude" type="decimal" pattern="%.6f" required="true">
			<label>Longitude</label>
			<description>Longitude for the forecast</description>
		</parameter>
...
	</config-description>

(As mentioned I have also tried without the pattern-parameter)

try using 58.5812xxx and 16.158xxx as in using “.” for the decimal delimiter and not “,”. Should work with this.

Thanks, but still only accepts 2 decimals :slightly_frowning_face:

The decimal separator doesn’t seem to matter either, if I use a ‘.’ (with a valid value) and then save, it reverts to ‘,’ the next time I open the page. Guess it uses the browser default locale.

Edit: If I fill out with zeroes they are truncated when I exit the text-box, so had to try with ones.

ok, I guess then the binding doesn’t support more than two digits. I don’t know this specific one, but other weather bindings take the “nearest” and/or “most fitting” station…

The point is that this is my binding, and I’m trying to figure out how to support inputting more precise values. The weather service’s web-api takes lat/long parameters with up to 6 decimals precision, and returns values for the closest station. Everything is fully supported by the binding, the only problem is that the UI doesn’t allow the input.

2 Likes

I don’t know the answer to your specific issue here. But it’s recommended to use one parameter, type text and context location for location input.

Hmm, that would be a breaking change, and since OH3 is in a feature freeze after RC1 (which is scheduled for today) there won’t be any chance to get this fixed in time for the OH3 release, right?