MQTT Setup and Configuration

Question: (this is what has been confusing me most about MQTT)

In the “MQTT Topics & Best Practices - MQTT Essentials: Part 5,” it says the topic is open/freeform with some structural considerations (topic level separators). Their examples are:

myhome/groundfloor/livingroom/temperature
USA/California/San Francisco/Silicon Valley
5ff4a2ce-e485-40f4-826c-b1a5d81be9b6/status
Germany/Bavaria/car/2382340923453/latitude

In “openHAB - Tasmota,” their examples are:

stat/tasmota_TH/POWER
tele/tasmota_TH/SENSOR
cmnd/tasmota-E8A6E4/POWER

Your configuration suggestion is:

stat/FietBulb01/POWER
cmnd/FietBulb01/POWER

Where do these topic formats come from? Do you structure them this way because it makes sense to YOU, or are you pulling them from you anal orifice? Are these like a command structure that NEEDS to be structured this way? Are the topic words you are using have specific definitions/meanings, or do they just clarify things in YOUR mind, so you can keep everything straight?
None of this is explained ANYWHERE. I really want to understand this. So far, all the documentation has done is to confuse me. This is the issue I have been having for the last several weeks as I have been poring over documentation and videos. SOMEONE could have said something like, "You CAN stucture your topic like: “myhome/groundfloor/livingroom/temperature,” but I recommend: “cmnd/FietBulb01/POWER” for clarity and specificity.

Also, where do cmnd, stat, and tele come from. And… what the hell is tele? Again, not explained ANYWHERE.

I can’t answer any of that, Todd, because you’ve done more reading than I have. :wink: I maintain that I was just very lucky to figure out MQTT on my first attempt, and that’s after walking away from it a few times. Same as openHAB, it’s like learning a foreign language. So while you’re trying to wrap your head around the concepts, you’re also having to learn the important words and phrases.

And of course, it then comes down to something that was so obvious that it’s hiding in plain sight. I’ve definitely been there and done that.

Anyway, I’m glad you got it working. On to the next challenge!

I’m one of those sick individuals that like to understand all the intricacies of things I do. When I was in college, I got a ‘C’ in my advanced COBOL class because I was still asking questions at the end of the class. The lowest grade I got at that school. Knocked me down to a 3.67 GPA. :rage:

1 Like

How do you sort your photos in folders an what is the best practice for folder structure in linux.

What colour should we paint the bike shead?

Tasmota uses. Cmnd short for command and others.

Homie has done some standard.

The reason why I did do such a detailed posts is because you had done your reasearch and were overfrustrated at the issue and we have all been there.

I think I might write a neew tutorial for oh3

So as I’m understanding it, the “cmnd//POWER” is kind of a loosely agreed upon standard? That way we all know what we’re talking about. I realize it CAN be different, but a certain percentage of people have agreed that “cmnd//POWER” as a loose standard. Would that be a safe assumption?

Seems safe to me. I think it’s like acronyms in an organization. I work at a university where every faculty/department/service has a four-letter code, and people toss them around like everyone obviously knows what they mean. But no, I don’t expect a random person off the street to know that OREG means “Office of the Registrar” or SAFA means “Student Awards & Financial Aid”.

And yes, I know it’s even worse in the military where they’re intentionally trying to make the acronyms as confusing as possible. :wink:

To summarize, short-hand terms are great for the few people who know what they mean, and confusing as hell for everyone who doesn’t.

Speaking of the military, When I first got to my agency, one of the guys took me down to T-Comm to meet the guys down there. One of the guys used to be a Photographers Mate in the Navy. I used to be an Electronics Warfare Technician in the Navy. Well we got to talking and started throwing around a lot of the military terms. The guy who took me down there got lost in the language and decided leaving was the best option. I always get a kick out of that… :rofl:

Our configuration suggestion wasn’t ours - it’s the Tasmota default settings for Full Topic which you changed, and which are shown on the configuration page itself, just next to the relevant field.

No, it’s just how Tasmota is setup by default. This is all Tasmota specific. It’s not a global standard. And it’s all described on the Tasmota site: MQTT - Tasmota

For commands: MQTT - Tasmota

Examples featuring all three prefixes:

Information about Full Topic, warning about removing %prefix% (as you did), and short description about the three prefixes:

But see, that’s my point. Unless you happened to find the Tasmota specs, you wouldn’t know what the standards are. When I read through it, they still didn’t explain it very well. They could have said something like, “The Tasmota standards for Tasmota devices are as follows:…” Most of the other documentation states the topic is a freeform field. Even something like saying that different vendors have different standards in how they want the topic formatted would help.
Now that I know, I know where to look for information. Hopefully others will see this and not go through a similar frustration.

What do you mean with this? You decided to use Tasmota, so surely you looked on their website? No “happened to find” about it! The information which you stated you couldn’t find ANYWHERE is right there on the single MQTT documentation page of the software you used!

Why would the Tasmota documentation on the Tasmota website say that? The documentation is about Tasmota.

We need to be careful about the word ‘documentation’ here. I assume you mean the official documentation for Tasmota, MQTT and openHAB, which are the only authoritative resources. Everything else is just someone’s opinion, just like this post!

Anyway, your next device integration will be a doddle compared to this experience. Ultimately, the main problem here was that your Tasmota connection to the MQTT broker wasn’t properly setup.

Just be sure to give your next device a unique topic in the Tasmota MQTT configuration.

For this first device, you initially had a color channel which you presumably copied from somewhere - was that a guide for the same bulb?

I pulled the color configuration from the OpenHAB documentation. It’s not working. I’m looking at the Tasmota docs to see how to configure it. It’s a bit confusing because they don’t really give any examples. I looked at the console and got some ideas, so it’s a bit of trial and error.

Can you show us this? Ideally copy and paste from the console into code fences here, because reading and testing from a screenshot is a pain…!

Use the Tasmota device’s main page to change the colour, then flip to the console and copy/paste everything!

Oh, and don’t forget to watch MQTT Explorer too - hopefully this will confirm some of the MQTT specific stuff you’re seeing in the Tasmota console.

Here you go:

08:40:06 MQT: stat/FietBulb01/POWER = OFF
08:40:12 MQT: stat/FietBulb01/RESULT = {"POWER":"OFF"}
08:40:12 MQT: stat/FietBulb01/POWER = OFF
08:40:48 MQT: stat/FietBulb01/RESULT = {"POWER":"ON"}
08:40:48 MQT: stat/FietBulb01/POWER = ON
08:40:49 MQT: stat/FietBulb01/RESULT = {"POWER":"ON"}
08:40:49 MQT: stat/FietBulb01/POWER = ON
08:41:02 MQT: stat/FietBulb01/RESULT = {"POWER":"ON","Dimmer":88,"Color":"000000E07C","HSBColor":"0,0,0","White":88,"CT":277,"Channel":[0,0,0,88,49]}
08:41:02 MQT: stat/FietBulb01/RESULT = {"POWER":"ON","Dimmer":100,"Color":"000000FF8D","HSBColor":"0,0,0","White":100,"CT":277,"Channel":[0,0,0,100,55]}
08:41:05 MQT: tele/FietBulb01/STATE = {"Time":"2020-12-10T08:41:05","Uptime":"0T02:40:19","UptimeSec":9619,"Heap":30,"SleepMode":"Dynamic","Sleep":10,"LoadAvg":56,"MqttCount":2,"POWER":"ON","Dimmer":100,"Color":"000000FF8D","HSBColor":"0,0,0","White":100,"CT":277,"Channel":[0,0,0,100,55],"Scheme":0,"Fade":"OFF","Speed":1,"LedTable":"OFF","Wifi":{"AP":1,"SSId":"Ben 2.4","BSSId":"88:EF:16:AF:DD:DF","Channel":11,"RSSI":70,"Signal":-65,"LinkCount":1,"Downtime":"0T00:00:08"}}
08:41:05 MQT: stat/FietBulb01/RESULT = {"POWER":"ON","Dimmer":60,"Color":"0000009955","HSBColor":"0,0,0","White":60,"CT":277,"Channel":[0,0,0,60,33]}
08:41:11 MQT: stat/FietBulb01/RESULT = {"POWER":"ON","Dimmer":60,"Color":"997A7A0000","HSBColor":"0,20,60","White":0,"CT":277,"Channel":[60,48,48,0,0]}
08:41:14 MQT: stat/FietBulb01/RESULT = {"POWER":"ON","Dimmer":60,"Color":"9999990000","HSBColor":"0,0,60","White":0,"CT":277,"Channel":[60,60,60,0,0]}
08:41:18 MQT: stat/FietBulb01/RESULT = {"POWER":"ON","Dimmer":62,"Color":"9E9E9E0000","HSBColor":"0,0,62","White":0,"CT":277,"Channel":[62,62,62,0,0]}
08:41:19 MQT: stat/FietBulb01/RESULT = {"POWER":"ON","Dimmer":42,"Color":"6B6B6B0000","HSBColor":"0,0,42","White":0,"CT":277,"Channel":[42,42,42,0,0]}
08:41:22 MQT: stat/FietBulb01/RESULT = {"POWER":"ON","Dimmer":54,"Color":"8A8A8A0000","HSBColor":"0,0,54","White":0,"CT":277,"Channel":[54,54,54,0,0]}
08:41:22 MQT: stat/FietBulb01/RESULT = {"POWER":"OFF"}
08:41:22 MQT: stat/FietBulb01/POWER = OFF
08:41:23 MQT: stat/FietBulb01/RESULT = {"POWER":"ON"}
08:41:23 MQT: stat/FietBulb01/POWER = ON
08:41:27 MQT: stat/FietBulb01/RESULT = {"POWER":"ON","Dimmer":75,"Color":"BFBFBF0000","HSBColor":"0,0,75","White":0,"CT":277,"Channel":[75,75,75,0,0]}
08:41:29 MQT: stat/FietBulb01/RESULT = {"POWER":"OFF"}
08:41:29 MQT: stat/FietBulb01/POWER = OFF
08:41:29 MQT: stat/FietBulb01/RESULT = {"POWER":"ON"}
08:41:29 MQT: stat/FietBulb01/POWER = ON
08:41:31 MQT: stat/FietBulb01/RESULT = {"POWER":"ON","Dimmer":100,"Color":"FFFFFF0000","HSBColor":"0,0,100","White":0,"CT":277,"Channel":[100,100,100,0,0]}
08:41:36 MQT: stat/FietBulb01/RESULT = {"POWER":"ON","Dimmer":100,"Color":"000000DA25","HSBColor":"0,0,0","White":100,"CT":203,"Channel":[0,0,0,85,15]}
08:41:39 MQT: stat/FietBulb01/RESULT = {"POWER":"ON","Dimmer":100,"Color":"000000C738","HSBColor":"0,0,0","White":100,"CT":229,"Channel":[0,0,0,78,22]}
08:41:42 MQT: stat/FietBulb01/RESULT = {"POWER":"ON","Dimmer":77,"Color":"000000992B","HSBColor":"0,0,0","White":77,"CT":229,"Channel":[0,0,0,60,17]}
08:41:43 MQT: stat/FietBulb01/RESULT = {"POWER":"ON","Dimmer":66,"Color":"0000008325","HSBColor":"0,0,0","White":66,"CT":229,"Channel":[0,0,0,51,15]}
08:41:47 MQT: stat/FietBulb01/RESULT = {"POWER":"ON","Dimmer":57,"Color":"0000007120","HSBColor":"0,0,0","White":57,"CT":229,"Channel":[0,0,0,44,13]}
08:46:05 MQT: tele/FietBulb01/STATE = {"Time":"2020-12-10T08:46:05","Uptime":"0T02:45:19","UptimeSec":9919,"Heap":30,"SleepMode":"Dynamic","Sleep":10,"LoadAvg":99,"MqttCount":2,"POWER":"ON","Dimmer":57,"Color":"0000007120","HSBColor":"0,0,0","White":57,"CT":229,"Channel":[0,0,0,44,13],"Scheme":0,"Fade":"OFF","Speed":1,"LedTable":"OFF","Wifi":{"AP":1,"SSId":"Ben 2.4","BSSId":"88:EF:16:AF:DD:DF","Channel":11,"RSSI":74,"Signal":-63,"LinkCount":1,"Downtime":"0T00:00:08"}}

G that makes it easy to integrate try

Install JSONPATH and REGEX transformation

Thing

    Thing mqtt:topic:FietBulb01 "FietBulb01 Label" (mqtt:broker:mqtt)  {
	Channels:
	  Type switch : masterstandswitch "Master Stand" [ stateTopic="stat/FietBulb01/POWER", commandTopic="cmnd/FietBulb01/POWER", on="ON",	off="OFF"	]
      Type string : Version       [stateTopic="tele/FietBulb01/INFO1", transformationPattern="JSONPATH:$.Version"]
      Type number : RSSI          [stateTopic="tele/FietBulb01/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
      Type string : WifiDowntime  [stateTopic="tele/FietBulb01/STATE", transformationPattern="JSONPATH:$.Wifi.Downtime"]
      Type number : LoadAvg       [stateTopic="tele/FietBulb01/STATE", transformationPattern="JSONPATH:$.LoadAvg"]
      Type number : Uptime        [stateTopic="tele/FietBulb01/STATE", transformationPattern="JSONPATH:$.UptimeSec"]
      Type string : Result        [stateTopic="stat/FietBulb01/RESULT"]
      Type color  : colorHSB      [stateTopic="stat/FietBulb01/RESULT", commandTopic="cmnd/FietBulb01/HSBColor", transformationPattern="REGEX:(.*HSBColor.*)∩JSONPATH:$.HSBColor"]

}

Items example auto generated

Switch   FietBulb01LabelMasterstandswitch   "Master stand"   {channel="mqtt:topic:FietBulb01:masterstandswitch"}
String   FietBulb01LabelVersion                {channel="mqtt:topic:FietBulb01:Version"}
Number   FietBulb01LabelRSSI                   {channel="mqtt:topic:FietBulb01:RSSI"}
String   FietBulb01LabelWifiDowntime           {channel="mqtt:topic:FietBulb01:WifiDowntime"}
Number   FietBulb01LabelLoadAvg                {channel="mqtt:topic:FietBulb01:LoadAvg"}
Number   FietBulb01LabelUptime                 {channel="mqtt:topic:FietBulb01:Uptime"}
String   FietBulb01LabelResult                 {channel="mqtt:topic:FietBulb01:Result"}
Color    FietBulb01Color "Color "              {channel="mqtt:topic:FietBulb01:colorHSB"}

Sitemap

sitemap FietBulb label="FietBulb " {

Default item=FietBulb01LabelMasterstandswitch
Default item=FietBulb01Color

      
}

Hi James,

Sorry for the long delay. I entered in you configuration (some parameters changed to fit my setup) and it is working. Minor details poking at me, but I can control the color of the bulb. I’m assuming that a lot of the parameters such as RSSI, Downtime, etc., are for later troubleshooting/information?

Thanks again for all your help. I think I’m beginning to get a small idea of how MQTT works… :upside_down_face:

Thats excellent news

In my example I left out the dimmer for you to achieve on your own.

These can be used or ignored or used.

Now that you have the hang of it this all changes very soon when openHAB 3 is released you set it all up in the mainUI with yaml. However you can still use things files.

UID: mqtt:topic:RPI4:MYlight
label: My Light
thingTypeUID: mqtt:topic
configuration:
  payloadNotAvailable: Offline
  availabilityTopic: tele/MyLIGHT/LWT
  payloadAvailable: Online
bridgeUID: mqtt:broker:RPI4
channels:
  - id: POWER
    channelTypeUID: mqtt:switch
    label: Power Switch
    description: ""
    configuration:
      commandTopic: cmnd/MyLIGHT/POWER
      stateTopic: stat/MyLIGHT/POWER
      off: OFF
      on: ON
  - id: Uptime
    channelTypeUID: mqtt:string
    label: UP time
    description: ""
    configuration:
      stateTopic: tele/MyLIGHT/STATE
      transformationPattern: JSONPATH:$.Uptime
  - id: LoadAvg
    channelTypeUID: mqtt:string
    label: LoadAvg
    description: null
    configuration:
      stateTopic: tele/MyLIGHT/STATE
      transformationPattern: JSONPATH:$.LoadAvg
  - id: WIFI_Signal
    channelTypeUID: mqtt:string
    label: WIFI Signal
    description: null
    configuration:
      stateTopic: tele/MyLIGHT/STATE
      transformationPattern: JSONPATH:$.Wifi.Signal

I’m supposed to be REDUCING my stress levels… :grinning:

I have been playing with the dimmers, but they’re not quite doing what I want them to do. I’m not 100% sure of what some of the parameters/setting do.

Things:

Thing mqtt:topic:FietBulb01 (mqtt:broker:mqtt){
	Channels:
		Type switch : masterstandswitch "Master Stand" 		[ stateTopic="stat/FietBulb01/POWER", commandTopic="cmnd/FietBulb01/POWER", on="ON", off="OFF" ]
		Type string : 01Version	"Master Stand Version"		[stateTopic="tele/FietBulb01/INFO1", transformationPattern="JSONPATH:$.Version"]
		Type number : 01RSSI            "Master Stand RSSI"		[stateTopic="tele/FietBulb01/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
		Type string : 01WifiDowntime    "Master Stand WiFi Downtime"	[stateTopic="tele/FietBulb01/STATE", transformationPattern="JSONPATH:$.Wifi.Downtime"]
		Type number : 01LoadAvg         "Master Stand Load Avg"	[stateTopic="tele/FietBulb01/STATE", transformationPattern="JSONPATH:$.LoadAvg"]
		Type number : 01Uptime          "Master Stand Uptime"		[stateTopic="tele/FietBulb01/STATE", transformationPattern="JSONPATH:$.UptimeSec"]
		Type string : 01Result          "Master Stand Result"		[stateTopic="stat/FietBulb01/RESULT"]
		Type color  : 01Color		"Master Stand Color"		[stateTopic="stat/FietBulb01/RESULT", commandTopic="cmnd/FietBulb01/HSBColor", transformationPattern="REGEX:(.*HSBColor.*)∩JSONPATH:$.HSBColor"]
		Type dimmer  : 01CWDimmer	"Master Stand Cold White"	[stateTopic="stat/FietBulb01/RESULT", commandTopic="cmnd/FietBulb01/White", transformationPattern="REGEX:(.*White.*)∩JSONPATH:$.White"]
		Type dimmer  : 01WWDimmer	"Master Stand Warm White"	[stateTopic="stat/FietBulb01/RESULT", commandTopic="cmnd/FietBulb01/Color", transformationPattern="REGEX:(.*Color.*)∩JSONPATH:$.Color"]
}

Items:

Switch masterstandswitch "Master Stand" <lightbulb> (US_Master, Lights) ["Lighting"] { channel="mqtt:topic:FietBulb01:masterstandswitch" }
	String   01Version				{channel="mqtt:topic:FietBulb01:01Version"}
	Number   01RSSI				{channel="mqtt:topic:FietBulb01:01RSSI"}
	String   01Downtime				{channel="mqtt:topic:FietBulb01:01WifiDowntime"}
	Number   01LoadAvg				{channel="mqtt:topic:FietBulb01:01LoadAvg"}
	Number   01Uptime				{channel="mqtt:topic:FietBulb01:01Uptime"}
	String   01Result				{channel="mqtt:topic:FietBulb01:01Result"}
	Color    01Color "Master Stand Color"		{channel="mqtt:topic:FietBulb01:01Color"}
	Dimmer	 01CWDimmer "Master Stand Cold White" 	{channel="mqtt:topic:FietBulb01:01CWDimmer"}
	Dimmer	 01WWDimmer "Master Stand Warm White"	{channel="mqtt:topic:FietBulb01:01WWDimmer"}
	Dimmer	 01Dimmer   "Master Stand Dimmer"	{channel="mqtt:topic:FiedBulb01:01Dimmer"}

Sitemap:

				Frame label="Lights" {
					Switch item=Light_US_Master_Closet
					Switch item=masterstandswitch
					Switch item=masterdeskswitch
					Default item=01Color
					Slider item=01CWDimmer
					Slider item=01WWDimmer
					Slider item=01Dimmer
				}

My wife just bought some Fiet LED strips. I’m going to see about flashing them, because out of the box there isn’t much control.

I found out that the Fiet LED strips don’t have a Tasmota firmware, so that’s out. But the Fiet app isn’t too bad and it gives us a lot more control than the little remote that comes with it. It will have to do for now.

So looking at the tasmota color channel what commands is it expecting to control the device?

Color x = 1…6
1 = Set color
2 = Set color adjusted to current Dimmer value
3 = Set clock seconds hand color (Scheme 5 only)
4 = Set clock minutes hand color (Scheme 5 only)
5 = Set clock hour hand color (Scheme 5 only)
6 = Set clock hour marker color

r,g,b = set color by decimal value (0…255)
#CWWW = set hex color value for CT lights
#RRGGBB = set hex color value for RGB lights
#RRGGBBWW = set hex color value for RGBW lights
#RRGGBBCWWW = set hex color value for RGBCCT lights (5 PWM channels)
Note:
Just append an = instead of the remaining color codes, this way they wont get changed. For example a command like Color #00ff= would update the RGB part to disable red and enable geen, but would omit to update blue or any white channel.

so it need to be Color1 in you command topic