Can't get mqtt item to send simple integer

Hi,

I’m using OH3 and am trying to get a mqtt item to send a simple integer value between 0 and 254 to an mqtt server.

I have set up a channel (number value type) with command topic - (xxx/yyy/set/brightness) and state topic (xxx/yyy/brightness) and have set an absolute minimum of 0 and an absolute maximum of 254.

Now when I create a Number-Item, I can’t control the number at all, the item only shows me a graph of past values.
When I create a Dimmer Item, I get the expected slider between 0 and 254, but the system sends weird commands - between 0 and 100 it sends values of 0-1 to the mqtt server, so 50 would come up as 0.5. Above 100 it does not send any commands at all.

Any idea where I’m going wrong?

Thanks!

A Number Item is just a number. It’s not usually used to control anything so by default it just shows up as a read only number with a graph of it’s history behind it. You’ll need to override that by adding “Default stand alone widget” Item metadata and select a more appropriate UI element to represent it. In this case, it sounds like you want a slider so choose oh_slider_card (or something like that) and fill in the configuration parameters.

Alternatively, you can keep the Dimmer Item/Channel but you’ll need to configure it to convert the 0-100 that the Dimmer supports to the 0-254 your device needs and that becomes a bit more complicated because you end up with decimals instead of integers and you need to add transformations to remove the decimals.

I also had some trouble working out what was going on with dimmers in OH3 - check this post for a working solution with MQTT (though via zigbee2mqtt).

The crucial bit for me was the extra configuration step starting at:

We have to make one small adjustment to the Item created for the Dimmer Channel:

Thank you both, both your solutions worked fine :slight_smile: