MQTT dimmer channel Outgoing Value Format

Hello! I try to send only integer values ​​to the broker, but floating ones come! That is, the “Outgoing Value Format” field does not work… What i am doing wrong?


The presence or absence of quotation marks does not matter.

You might be interested in this thread

Try this format instead %d

Thanks everyone!

  1. OVF %d does not help
  2. JS transform works:
(function(brightness) {
    var thesunobj = Math.floor(brightness);
    return thesunobj;
})(input)

But at the same time, the broker receives the value in the form: number.0 (692.0, 300.0, 0.0, 1023.0 etc).
How to fix it?
There is one more problem.
When the brightness slider is set to any value, a converted number is sent to the broker (624.0 for example). The dimer changes brightness, but in the logs (and the Paper UI interface) I get this:

2020-01-11 09:40:39.932 [vent.ItemStateChangedEvent] - TheSun_HotBrightness changed from 24.926686217008796830896244500763714313507080078125 to 61

2020-01-11 09:40:39.988 [vent.ItemStateChangedEvent] - TheSun_HotBrightness changed from 61 to 60.9970674486803545732982456684112548828125

I understand why this happens, but how to get rid of it?

I don’t really understand how you get a string of numbers in brackets.

Are you trying to say you want your javascript transform to return an integer?

int thesunobj = Math.floor(brightness);

Get rid of what? Which is result that you are not expecting?

This is just an example of data. {some digits}.0

Yes!

The dimer accepts a brightness value in the range 0-1023. Openhab converts this number to a range of 0-100. When a dimer sets a brightness value of 8 (out of 1023), Openhab converts 8 to 8.015640273704789819930738.
image
How do I specify in the Item settings that the value is always integer? That is, how to specify the number of decimal places? I would like to do this using Paper UI.

Why would you care about the decimal places?

PaperUI is the administrator’s toolbox, it’s not supposed to look pretty or hide values from you.

In a user-facing UI there are format options, if you want to present a numeric dimmer, e.g. with no decimals and a % sign in a sitemap [%.0f %%]
If you just have a slider, who cares.

Anyway, if you must have it tidied to integer, then do so in your transformation.
You appear to be complaining about an incoming value now, so presumably a different JS transform to the one shown so far?

You cannot make a Number Item be integer only, you can only constrain the values it get updated with.