NEWBIE MQTT Config Help Needed

On paper does your MQTT show online ?

Yes, it’s online.

@joashmgn you have most probably installed MQTT2.4 however @allen is posting items Setup for MQTT1! The Setup is totaly differnt!!

all my mqtt is setup in text based. I don’t use the embedded MQTT broker.

I’m open to doing it that way.

My Item :

Switch   FamilyRoom_Light         "Light"         <light>         (FamilyRoom, gLight)            {mqtt=">[flatcntr:LeefVertrek/relay/0/set:command:*:MAP(],<[flatcntr:LeefVertrek/relay/0:state:MAP(]"}
Switch   FamilyRoom_Pargola_Light        "Pargola Light"         <light>         (FamilyRoom, gLight)  {mqtt=">[flatcntr:LeefVertrek/relay/2/set:command:*:MAP(],<[flatcntr:LeefVertrek/relay/2:state:MAP(]"}
Switch   FamilyRoom_Fan           "Fan"           <fan_ceiling>   (FamilyRoom, gFan)              {mqtt=">[flatcntr:LeefVertrek/relay/1/set:command:*:MAP(],<[flatcntr:LeefVertrek/relay/1:state:MAP(]"}
Number   FamilyRoom_Temperature   "Temperature"   <temperature>   (FamilyRoom, gTemperature)

If I understand what you’re saying here, I need to update the channel on the item file to reflect the channel I’ve set in the Generic MQTT Thing?

@joashmgn you have most probably installed MQTT2.4 however @allen is posting items Setup for MQTT1 ! The Setup is totaly differnt!!

I do have MQTT2.4 installed

yes I am running mqtt1. I battled with 2.4. maybe I can get mine to run as well . :sweat_smile:

have a look at the following Post.

@allen I’ll have a look, but that may lead to more information overload. I’ve been going at this for a while, and my limited experience doesn’t allow me to intuitively see what I need to change to suit my needs.

Suggestion, I/we could walk you through the setup of one of your sonoff switches, that way you should be able to do the others.
Please state which way you prefer, setup via PaperUi or via files?
Please show a screenshot showing the mqtt page of one sonoff switch.

P.S. Sorry for the short and abrupt answer earlier, I had to an oncoming appointment.

I’d greatly appreciate the help @opus.

Based on all the reading I’ve done the files option would be the better way as it will give me the most control, not so?

Both give you the same control! Take your pick, post the screenshot and I’ll write you through later tonight.

Let’s go with files.

I’ll probably try to replicate the process afterwards in PaperUI for another one of the switches just to see if/how it will work.

Here’s the screenshot:

Apparently I’m at my daily limit for replies as a new user but I’ll follow along any instructions given later tonight.

My guess is the first thing you are missing and not understand is the thing that represents the broker connection. It needs to be created as a bridge and all things representing the items should connect to it.
As you have already installed the embedded broker you should use it. I haven’t used it, so my example migth have a problem on that point. You need to set your correct IP for the host of this broker ( since it is the embedded one, the IP of the system your openhab instance is running on). The name “myUnsecureBroker” can be set differently!
The sonoff is represented by “mything” ( again you can set an own name). The device has two channels ( a switch called lamp and a string called Version).
Since you configured your sonoff non-standard, I am not sure on the state- and commandTopics, the “/Lights” might not be needed.

 Bridge  mqtt:broker:myUnsecureBroker [ host="", secure=false ] {

        Thing topic mything {
         Type switch : lamp "Switch" [ stateTopic="stat/Lights/TVLights1/POWER", commandTopic="cmnd/Lights/TVLights1/POWER" , on="ON", off="OFF" ]
         Type string : Version [stateTopic="stat/Lights/TVLights/STATUS2", transformationPattern="JSONPATH:$.StatusFWR.Version"]

Save this in a .things file in the things directory, you need to restart openhab ( that is a known bug, already solved in the snapshot version).

Use PaperUI to see the correct channel definition which is needed in the items file ( within the { } after “channel=”. You can copy the syntax on PaperUI.

Let’s see how far you are getting with this.

??? I hope you did not miss understand me. Your question could be answered by anybody at any time, however I had to finish another task before writing back to you.

[Edit:] Missed the word “Bridge” in the .thing file example!!

i recommend Node-red , i am also a noob i was not able to understand MQTT till I have seen it work with Node red, also you will find tons of benefits, i still use OH as my Hub, but node-red give me a powerful rule engine, that can perform complex tasks on is own, for example, i use it to send my IOS notifications

i am a big fan of node red , i think its the best way for non-programmers to get some real work done

@opus I have the bridge up and running, at least that’s my understanding from the MQTTfx readouts when I toggle the switch, both manually and via the Sonoff WebUI - see screenshot below:

Based on the MQTTfx output, I’m thinking that I need to adjust the string line of the code to

Type string : Version [stateTopic="stat/Lights/TVLights/RESULT", transformationPattern="JSONPATH:$.StatusFWR.Version"]

Would that be correct?

The next part that has me stumped is defining the item itself. Based on further reading I’ve put the following as the item:

Switch Test_LED "LED Test" <wallswitch> {channel="mqtt<systemBroker:embedded-mqtt-broker:mything:lamp"}

But it’s yielding this error in the log:

Is the next step go to PaperUI and set up the channel?

In order to get the version info you need to send the …Status2 and not …/Result!
Your syntax for the item is again like version1 and therefor false.
Go into PaperUI and expand the thing representing this sonoff switch, under the channel the correct and only syntax is shown which you need to paste in the curly brackets behind “channel=”.

Screenshot from my system:

You see the three channels ( 2 switches!), underneath the bold type the channel is printed which can easily copied by the symbol behind it.
Paste that into one of your items like
The error shown points to the sonoff.items file containing “mqtt<systembroker” , the “<” is in question.
Please post the contents of that file.

Additionally, you did have the embedded broker with your first post. Only if the broker thing (I named it “myUnsecureBroker”) is online we are one step further!

I found a failure in my posted example (missed the word “Bridge”, already edited). When saving with this change a Restart is required.

Here’s the corresponding screenshot from my system:

I’ve changed the code back to /STATUS2, and copied this (mqtt:topic:embedded-mqtt-broker:mything:lamp) and put it into the item file.

Switch Test_LED "LED Test" <wallswitch> {channel="mqtt:topic:embedded-mqtt-broker:mything:lamp"}

I found a failure in my posted example (missed the word “Bridge”, already edited). When saving with this change a Restart is required.

I picked up on this error and made the necessary adjustment but I actually didn’t restart the OpenHAB service afterwards. Will restart now.

Looking good so far, PaperUI shows the Thing and shows that the channels are connnected to items (the dot is filled).
Is your broker Thing online as well?

Is your broker Thing online as well?

Yes. See below: