Setpoint MQTT for hometop 2

Heya

This is a follow up question to my initial question you can find -> here

I am now migrating to the mqtt 2.5 binding and therefore I need to switch to the things and channel business.
Reading values works fine- yet again it is the question how I can write a specific value to the MQTT topic:

in MQTT1 my item looked like this:

Number Temperature_Setpoint "Zieltemperatur [%.1f °C]" <temperature> {mqtt="<[mosquitto:hometop/ht/hc1_Tdesired:state:default],>[mosquitto:set/hometop/ht/hc1_Tdesired:command:*:${command},heizen]"}

And the sitemap looked like this:

Setpoint item=Temperature_Setpoint minValue=25 maxValue=35 step=0.5

For MQTT2 I was thinking of sth. like:

	Thing topic Temperature_Setpoint  "Zieltemperatur" {
Channels:
    Type number : temperature "Temperature" [stateTopic="hometop/ht/hc1_Tdesired",commandTopic="set/hometop/ht/hc1_Tdesired" ,"${command},heizen"]
	
}	

Which obviously does not work. (using the same sitemap entry)

The tricky bit is, that I need to grab the numeric value and add “heizen” and send it to the topic.

Type number : temperature "Temperature" [stateTopic="hometop/ht/hc1_Tdesired",commandTopic="set/hometop/ht/hc1_Tdesired" , formatBeforePublish="%s,heizen"

I’m not quite sure what formatting you need in your specific case - are they comma separated? Either way, it’s formatBeforePublish you want! The %s will get filled in by your command.

Thank you very much for you suggestion.
formatBeforePublish might be the thing actually - Yet I need to figure out the right syntax and/or escaping. So far it does break my thing configuration.

What exactly is the message that needs to be sent? Can you provide an example in between code fences?

On the command line the following signal would work:

mosquitto_pub -d -t set/hometop/ht/hc1_Tdesired -m "29.5,heizen"

Maybe try

formatBeforePublish="\"%s,heizen\""

This helps a bit - the .things file is still working correctly. Yet nothing is sent to the topic - I had an oder fiddle to try and work out the right syntax - but so far without any luck.

You may be hitting the known bug where openHAB doesn’t properly load the Things file after it is saved. Try restarting openHAB.

No luck so far. If anyone has an idea… it MQTT is pretty hard to debug… I did not find a way to analyze the payload to see what is actually going on…

Install the 3rd party MQTT Explorer - this subscribes to all MQTT topics, and should let you see what openHAB is or isn’t doing.

I have left the problem for a while - but now as I upgraded to OH3 is is pressing again.

The previously suggested hints have led to nowhere unfortunately. The mqtt explorer shows nothing - and I still have not figured the correct way to form the message via a thing file.

There are actually two commands I would like to realise: the first might be a bit easier:

mosquitto_pub -d -t set/hometop/ht/hc1_Tniveau -m "frost" 

currently my thing looks like this and I tried to hardcode the value “heizen”:

	Thing topic HeizungMQTTModus  "Heizmodus" {
    Channels:
        Type number : temperature "Heizmodus" [stateTopic="hometop/ht/hc1_Tniveau", commandTopic="set/hometop/ht/hc1_Tniveau",formatBeforePublish="-m \"heizen\""]
    }

but this does not work at all. Any help would be much appreciated.

Go back a step. Have no formatting or transformation at all in your channel, so it just publishes the basic number.
After editing Things file, restart the binding or reboot.
Command the linked Number Item with a number - what do you get in your MQTT Explorer or mosquitto_sub ?

After fiddeling with this for far too long - I went for the cheap solution. Now I just use the exec binding to send the working mosquitto_sub command to my broker.
I don’t really like it - but it works and there are only so many hours in a day…