Selection mapping to mqtt issue

Tags: #<Tag:0x00007f5ca64bfd98> #<Tag:0x00007f5ca64bfcd0> #<Tag:0x00007f5ca64bfbe0>

I have a setup:

Sitemap file:

sitemap demo label="ROOM31"
{
   Frame {
        Text label="WLED-WS2812" icon="rgb"{
            Selection item=wled_FX   icon="line" mappings=[0="Solid", 1="Blink",2="Breathe",3="Wipe"]
        }
    }
}

Items file:

Number wled_FX  "FX"  {channel="mqtt:topic:wled:W_Effect"}

Things file:

Thing mqtt:topic:wled "Wled" (mqtt:broker:689cb32c)
	{
    Channels:  
       Type number  : W_Effect    "WLED Effect" [ commandTopic="wled/80da2c/api" ]   
	}

openHAB 2.5.2 Release Build

When I use selection tool in basicUI it should send “0” or “1” or “2” or “3”
to MQTT Broker “wled/80da2c/api” topic.
BUT!!! I receive in broker “0.000000” or “1.000000” or “2.000000” or “3.000000”

Tell me plz is it an issue, or it just i did something wrong?
…No errors in logs and with openHAB 2.5.0 Release Build was OK.

Try switch instead of number… oh wait no that’s wrong, since you have multible states. Hmm
The behavior is correct since number is a float.

I think you need write a rule, see:

I’m just interesting where does it gets from “.000000” ??
Can you check selection tool with mqtt on your system? Same behavior?
And why it was OK on previous releases?
Because this problem appeared only with updating to 2.5.2 (((

ps: No need to delete your “wrong” reply, you can edit the reply/post.

Ohhh… did not read that line. Ops, silly me :face_with_hand_over_mouth:

I don’t know for sure.

Can’t reproduce your setup atm. Sorry.

I think the MQTT binding treats all Number type channels as floating point. You might be able to use the “Outgoing Value Format” field with %d or %.0f to strip off the decimal places.

Or you can use a Percentage value type channel instead which uses PercentType which only supports integers.

I’ve tried like this: “Outgoing Value Format” …in MQTT binding it calls “formatBeforePublish”, but it doesn’t help((
MQTT channels doesn’t have “Percentage” type channel, I’ve tried “Dimmer” type, but it also published like this: 1.0, 2.0, 3.0, and so on(((

image

I use configuration files to setup everything, …from the MQTT binding docs:

I think it is the same as “Percentage” type in GUI. But, like i said, it doesn’t help((

You could try an outgoing transformation or maybe use a String instead of Number. It seems you are not doing math with these, just mapping a selection. It goes out on the MQTT message as text anyway.