Migrating MQTT1 items to MQTT2.4 items

i have followed your guide and cant not seem to make it work… I have a test sonoff basic item:

Switch mqtt6 "mqtt6"   {mqtt=">[broker:/ESP_Easy_6/gpio/12:command:ON:1],>[broker:/ESP_Easy_6/gpio/12:command:OFF:0],<[broker:/ESP_Easy_6/relay/state:state:MAP(onoff.map)]"}

i use a simple transformation 1=on and 0=off
that with old mosquito binding work like a charm.
Trying to migrate it to the new way but it doesnt work at all.This is my channel


What am i doing wrong?After i save i get “Status: OFFLINE - COMMUNICATION_ERROR java.lang.Exception: No MQTT client”

You did everything right. This is a know bug fixed in oh 2.5 snapshot.

1 Like

Hi all,

I have also moved to MQTT V2 (OH 2.4)
What I have problem with is for my Osram Lightify Lamp. I’m not able to create a transformation that send values from a Slider as MQTT command like this:
{“brightness”:“value”}
Value is from 0 to 100 as a numeric value.

General communication to this Items is not a issue, e.g. a Switch for turning On/OFF works well.

I tried several times to create a Numeric channel but I’m not able to set a JSON Transformation.
Where could I setup such a tranformation for outgoing values?!?
And how could I define that the MQTT JSON is send as described above?

Thanks a lot

You can’t. This is a feature coming with OH 2.5 after Christmas :slight_smile:

This is already possible. Have you read the documentation? You can use the output pattern. It is not a transformation as defined by OH, but can add suffix and prefix to a string. And that is what you need here. Along the line of {“brightness”:“%s"} should do it.

@David_Graeff

That’s it! Thanks!
Sometimes the easiest way seems not the right…or sometimes you can’t see the forest for the trees. :wink:

Many Thanks to your and the community for that awsome support and help!

1 Like

Hello all, I’ve been following all the tips and I’m struggling to migrate from MQTT1 to MQTT2. But I have some doubts:

  • do I need to delete the file MQTT.cfg after I finish all these procedures?
  • if I configure the MQTT Broker at Paper UI, it means that I don’t need to write a configuration file at Broker.things, is that right? And if I write the parameters at one file a Broker.things, so I don’t need even to install the MQTT Binding??

Thanks so far if you could help me on these questions

Paulo

Deleting a cfg file will not delete the configuration. You need to remove the cache as well.

If you don’t install a binding, you can’t use the functionality. Or what do you mean with your second question?

I’m confused on your text. If I write the broker.thing file do I still need to install and configure the mqtt binding? Can I do both (write the file and configure binding)? Or maybe I’ll be setting up 2 Mqtt brokers if I configure the broker using file and the binding?

broker.thing file:

mqtt:broker:mySecureBroker [ host="192.168.0.41", secure=true, certificatepin=true, publickeypin=true ]
mqtt:broker:myUnsecureBroker [ host="192.168.0.42", secure=false ]

mqtt:broker:myAuthentificatedBroker [ host="192.168.0.43",secure=true, username="user", password="password" ]

mqtt:broker:pinToPublicKey [ host="192.168.0.44
1 Like

Please read documentation! Choose either mqtt1 or mqtt2, don’t mix them if you are already confused. In both cases you MUST install the corresponding binding. Of course. That’s logic. You can’t turn your computer on and expect it to work if there is no operating system installed. I really don’t understand your question I guess.

1 Like

Thank you for your answer @David_Graeff! My question is: after I install the binding, if I do the text configuration at .thing, it would be the same if I do the graphical configuration at Paper UI? If I do both, will I have a conflict??

Paulo

You should either create a broker and the device things via PaperUI OR via file.

2 Likes

Hello and happy holidays!

After reading all that I could (and a lot of trial and error), I managed to migrate my v1 mqtt items to v2.4. However, I couldn’t find an option for not auto-updating the item’s state when sending a command (like autoupdate=“false” in the old configuration). Is that possible?
I’m using text configuration.

I was using it in scenarios where I wanted feedback from the module (switch, light, water-heater etc.) in order to know that the command worked (and maybe start a timer or update the icon).

Thanks!

Autoupdate can still be used just as before, e.g:

Switch Item_Name "Label" { channel="mqtt:topic:topic_name:channel", autoupdate="false" }
2 Likes

Didn’t try that :blush:
Thanks a lot!

hello

if i have this

{ autoupdate="false", mqtt="&gt; 
[mosquitto:broadlink/tv/room/lg/on:command:ON:play-0d43b4efb79f],&gt; 
[mosquitto:broadlink/tv/room/lg/off:command:OFF:play-0d43b4efb79f]"}

broadlink/tv/room/lg/on
broadlink/tv/room/lg/off

2 diffrentt commands for on/off and also need to send this “play-0d43b4efb79f” how can i do this?

thanks

You can’t, not yet. The commandTopic doesn’t accept transformations yet.
You could use the action and a rule instead

I dont understand why to releaseadd-on that is not yet can replace the old one. why not to wai t until it will have full support for all the option in the mqtt1

You can continue to use the (old) mqtt1 binding. Just select to show the legacy bindings in PaperUI and install the old one again!

Mqtt2 is feature complete, the author which is me, was implementing transformation as they are on purpose. Some people changed my mind and outgoing transformations will come. (With a big warning of their performance impact)

i made it :slight_smile: ,i have succefully migrate all my sonoff devices to mqtt2.4.Now i need a litle help with some items that use json tranformation.The item type that is working with mqtt1 is

Number:Temperature OctoprintPrinterHotEndTemp		"Nozzle temp [%.1f °C]"     <temperature>	(gOctoprint)	{mqtt="<[broker:octoprint/temperature/tool0:state:JSONPATH($.actual)]"}

i create a new generic mqtt thing ,choose broker,create number channel and in state field i put

/octoprint/temperature/tool0

i am not sure what to put at the input tranformation field to make it work…
edit:nevermind ,i got it right :slight_smile:

1 Like