Rest API ItemStateChange hysteresis or rounding

I was able to bind to the Rest-ItemStateChanged event in OH3.

My problem now is that I have (for an example) a temperature item. This item comes from a modbus binding and has a very high resolution (6 or 7 decimal places). So of course the value changes permanently.

But I’m only interested in the first decimal place. Is there a way to define a “minimum change for event” or to use a rounded number for the value?

By the way - I never need more precision (graphs, pages) - so a change on the thing is alsio okay for me.

Not at this time short of creating a Rule and a Proxy Item.

However, is your issue that it is displaying more decimal places than you want or that it’s reporting changes more often than you want. If it’s the former, you have full control over how the value is displayed. %.1f in a label or State Description metadata will only show one decimal place for a floating point number.

Thank you for the fast answer.

My issue is that my service get’s flooded with state change events. The display of only on decimal digit is no problem at all.
So a proxy item won’t help since I get an event for every item. The proxy would only be one more event beeing fired.

The only way to fix that would be at the binding or at the source.

This binding supports readTransform at the data Thing. See docs for examples e.g. scaling using JS javascript transform. You can round in a javascript before it gets passed to channel.

You might also look into the updateUnchangedValuesEveryMillis parameter of the data Thing(s) for control of frequent updates.
So far as I know this works off the channel value, so a changing raw input from Modbus will NOT be seen as “change” (triggering update) unless/until the transformed rounded value changes, so reducing openHAB load.

@rossko57 I check the documentation here MQTT Things and Channels - Bindings | openHAB again, Serching the page for “round” or “scale” brought no results.
Could you please point me to the location where this is documented.

I love the idea to round it at Channel level since this would solve my problem.

Modbus is not MQTT.

MQTT binding does also support transforms on incoming data, but there is no throttle. You could still round by transform, but every incoming MQTT message would generate an openHAB update (but perhaps not a change).

Sorry for the confusion - I was investingating about MQTT and searching there - where nothing was found.
I just checked modbus and this looks good.
Till now I just used paper UI to define my itmes.
I’ll have a clisrr this documentation tomorrow - it’s 1am here in Austria.

Thank you for your help.

You can continue to do that with Items.
Changes here are about Things, examples given in docs are for files but you will find same parameters available in UI.

Thank you @rossko57 - I finally got it running using your hints.
I added a js file in transform and set ReadTransformation to JS(myfile.js) in PaperUI.
I also could use this with a MQTT binding.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.