MQTT formatBeforePublish not working with decimal

Hi all,

I try to send a decimal payload from a SetPoint in my sitemap but the formatBeforePublish option is not working, the payload is the decimal raw. When I change the setpoint to an integer, the payload format is correct (see below) but the value is not (obviously).

Setpoint item=PoolProcessPhSetPoint minValue=6.8 maxValue=7.4 step=0.1

7.299999999999998         // strange value by the way !
Setpoint item=PoolProcessPhSetPoint minValue=68 maxValue=74 step=1



There isn’t a formatBeforePublish option in a sitemap.
Would you like to how us the Item and MQTT channel that you are having trouble with?

There is the thing :

Thing mqtt:topic:piscine "MQTT Piscine" (mqtt:broker:Mosquitto) @ "Piscine" {
	Type number :	PoolProcessPhSetPoint	"Consigne pH" 						[ stateTopic="OpenHAB/Piscine/Set2", transformationPattern="JSONPATH:$.pHSP", commandTopic="OpenHAB/Piscine/API", formatBeforePublish="{\"PhSetPoint\":%d}"]

And the item :

Number      PoolProcessPhSetPoint     "Consigne pH [%.1f]"                                                           (gPool)	{channel="mqtt:topic:piscine:PoolProcessPhSetPoint"}

OK, my mistake, rereading my post, replacing %d with %f help ! Obviously.
Sry to post for nothing :slight_smile:

1 Like