Dealing with different units of measurement

Whilst adapting Patrick Stuart’s ps_Ubi to connect multiple Ubis and deal with temperature reporting in Celsius rather than Fahrenheit, I came across the code for the temperature tile.

I’ve also looked at the sample code for the SmartThings Multisensor and it, not surprisingly, uses the same code for its temperature tile.

Unfortunately, when it comes to the coloured background, the tile is hard-coded to the Fahrenheit scale. So whilst I’m sitting in a quite comfortable 22 C, the tile is coloured blue rather than green because it thinks it’s below freezing. I’ll never see an orange or red background because 45 C is about as hot as it gets here (not that you want hotter - 45 C is bad enough).

Now, I’ve recoded my version of the Ubi device to align the tile colours with temperatures in Celsius, but this is just a point fix and not a good solution.

Temperature is but one example. The weather station app is great, but it reports wind speeds in miles per hour. I would prefer km/h and there are probably quite a few nautical types who would prefer to see knots.

I can see elements here and there of trying to deal with differing units of measurement, but there doesn’t seem to be a comprehensive framework that we can adopt across every device and smartapp. Such a framework would include not just ensuring every measurement includes its associated unit, but also a way of determining user preferences for units to be used, standard conversion routines and standard display/presentation routines.

Does such a framework exist or is it in the works? If so, is there any doco we can read to see how it should all come together?