OpenHAB sends float instead of int to MQTT-Broker (1.000000)

Since the new update, OpenHAB is sending my int-values as float-values to the mqtt-broker.
It worked before but now it’s suddenly broken.

Items

Number example001 " " {channel="mqtt:topic:broker001:smarthome:example001"}
Switch example002 " " {channel="mqtt:topic:broker002:smarthome:example002"}

Things

Type number : example001 [stateTopic="smarthome/example001/status", commandTopic="smarthome/example001/status"]
Type switch : example002 [stateTopic="smarthome/example002/status", commandTopic="smarthome/example002/status", on="1", off="0"]

Rules

rule "dev001"
  when
    Item dev001 received update
  then
      example001.sendCommand(1)
      example002.sendCommand(ON)
end

Result in MQTT

smarthome/example001/status=1.000000
smarthome/example002/status=1

What changed or what did I do wrong?

From what old version to what new version?

I don’t know which old version but I is probably from the end of 2019.
New version: 2.5.3

Related

2 Likes

Thank you, rossko57!
I marked this reply as the “solution” because in my case (int) it is a bit different to the existing topic.

Transferred to my issue
formatBeforePublish="%.0f"
or
formatBeforePublish="%d"

Things

Type number : example001 [stateTopic="smarthome/example001/status", commandTopic="smarthome/example001/status", formatBeforePublish="%.0f"]

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