Weird long float values only in n3-line-chart using rrd4j

I have a strange annoyance in OH2.5. I love the interactive n3-line-charts, and have one with temperatures set up. The temperatures are coming from MQTT as single digit precision floats (i.e. %0.1f). Everywhere I look this is now they are. They are defined as Numbers using Paper UI.
Persistence is with RR4DJ.

The interactive legend for the chart (in HABPANEL) shows these values as long floats, with values like 17.0999999654335. Is there any way to limit the precision in the chart or stop this from happening?

HABPanel uses the “state description pattern” which I believe you can’t define in Paper UI, unfortunately.
If you can, redefine your item (or add another one) in an .items file with a format pattern between brackets.

Number Temperature1 "Temperature 1 [%.1f °C]" { channel="mqtt:..." }

Or perhaps you can try the “format” channel parameter in Paper UI, not exactly sure how that works? (open the dialog below with the pencil icon besides the channel in the things details page)

I tried setting the format in Paper UI, no change. I even added a limit precision javascript transform. No change.

If I put the same item in an .items file, will it break everything?

You can add another one with another name, just for the purpose of setting a format. There should be no problem with two items linked to the same channel, both will receive updates. Then if you find the existing one redundant you can delete it.

1 Like