Apply UoM to thing-types.xml : state : min / max / step parameters

In thing-types.xml one can define certain attributes of a channel-type’s state as follows…

<state min="15" max="30" step="0.5" pattern="%.1f %unit%" readOnly="false"/>

My question is whether it is possible to apply Units of Measurement to the min, max and step parameters of state. So for example for a thermostat target temperature one might define it as follows…

<state min="15|°C" max="30|°C" step="0.5|°C" ... />
.. or ..
<state min="60|°F" max="90|°F" step="1|°F" ... />

It doesn’t look like it, those attributes are all parsed as BigDecimal:

Hi @rossgb many thanks for the response. I guess the answer “no” is clear. However I wonder if it should be added to the “to-do” list, perhaps for OH v3?

It’s not a definitive “no”. I don’t have a deep knowledge of the openHAB core, I just did a quick search of the code. There may be another mechanism that you can use to set bounds on a channel-type.

When it comes to UoM it’s probably easiest to just leave the min,max,step stuff to the sitemap/HABPanel level and either do sanity checks in your ThingHandler or let the device/service you are binding do the validation.

@rossgb yup, that’s what I (my users) have to do now; but it certainly would be good (IMHO) if the developer could provide default values (e.g. min/max/step values in Celsius, and also in Fahrenheit) so the user does not have to think too much about it…

There is an older issue in ESH repository where a brief discussion was going on about this feature. It tells you something about the issues implementing it and a draft of how it may be designed. I think adding this to the OH3 roadmap is a good idea. It is a nice feature.

2 Likes

Thanks for the link. I have added a suggestion to that thread.