Channel + MQTT Formatting

So sorry for such a beginner question. I am brand new to OpenHab and am very excited to get working with it.

How does one properly format both {channel =} and {mqtt =} in the same .item file for the same device? I have both working individually for my ISY (Insteon) dimmer - but I can’t get the dimmer to trigger the MQTT message when I try to combine the mqtt and channel parameters. Do you happen to have a sample config file that integrates both?

Or, am I looking at this in the wrong way?

Thanks very much.

You separate them by a comma.

However, I prefer to not mix and match bindings on one Item like this, at least until you have a lot more experience.

Instead, I would recommend using a Proxy Item and rule or rules to link the channel and MQTT together. I find this approach is easier to reason about, easier to debug, and easier to understand. Once you get it working this way you can come back and figure out how and if it can be done using just one Item.

1 Like

You are amazing. Thanks so much for your help. I believe that I did try a comma, but I will play around with it more tonight when I get home.

I will review your proxy suggestion tonight as well. I definitely want to go about this the “right” way - so thank you very much for that suggestion.

Just to confirm: {channel=} is the mechanism to tie a device (and it’s functionality) to a switch? If so, why do I see so many examples of .item configs that don’t have a {channel =} declaration in them? Are they associating these in some other fashion?

Again, thank you very much for taking the time to help a noob out.

channel= is used to link an Item to a Channel.

Only native 2.x version bindings support Things and Channels. In your case, the MQTT binding is a 1.x version binding so does not support Things and Channels and therefore has its own way to bind to an Item.

I recommend going through the Beginner’s Tutorial and Introduction and Concepts sections of the user manual. All of these concepts are explained there and you must understand them to be successful in home automation using openHAB.

1 Like

Wonderful! I will have a look at the guides that you provided.

How does one know that this is a 1.xx version binding? I installed OpenHab2 and never enabled any 1.x version options. Will this become clearer after going through the links you provided? There is no 2.x MQTT binding that I should use instead?

So sorry for these basic questions. I am actually very embarrassed for having to ask this stuff. For some reason, this is less intuitive for me than I am normally used to.

Thanks so much once again!

Home automation and openHAB are VERY complicated. It is very hard to just jump in and get running without reviewing the documents.

Hopefully, most of these questions will be answered by the docs. If not let us know so we can update the docs (and answer them for you).

You can tell the version in PaperUI:

Air Quality Binding is a 2.x version binding (2.1.0.SNAPSHOT to be precise).
Alarm Decoder Binding is a 1.x version binding (1.10.0.SNAPSHOT to be precise).

You can also tell by looking at the binding’s readme. If it doesn’t talk about Things and Channels it is a 1.x binding. If it does it is a 2.x binding.

The Bindings page lists all the bindings and has a way to hide them based on versions.

If you see a binding listed twice in the Binding’s page or in PaperUI that usually means that there is a 1.x verison and a 2.x version. In this case the 1.x version will be considered a “Legacy Binding”.

1 Like

Again, as one human to another, thank you for taking time out of your busy day to answer these mundane questions. I sincerely do appreciate it.

I did review a lot of the tutorial documents and I was still not grasping the topic very well. I believe my issue has been the lack of understanding between 1.x and 2.x techniques - and that some of the documentation was pertaining to 1.x while another was 2.x.

Thanks again. Looking forward to learning more.

Is this properly formatted? Still not sure why it does not work.

Switch mySwitch4 { channel=“isy:dimmer:MyISY:3D_CN_8:loadlevel”, mqtt=">[broker:/hall/light4:loadlevel:ON:1],>[broker:/hall/light4:loadlevel:OFF:0]" }

Is it the ON / OFF (at the end of the mqtt statements) causing the issue?

I will be reviewing the links you provided in a few hours from now.

Thanks again.

I now have it working for commands issued from a button within OpenHAB, tied to my insteon light. I had to change :loadlevel: to :command: for some reason.

However, if I update the light from the physical switch, the mqtt broker never receives that change - even though the button within OpenHab moves in sync.

Just to clarify, is it possible to have OpenHAB always send a mqtt message whenever an item’s status has changed within OpenHAB - even though the action was triggered from another device that does not have its own ability to update mqtt itself? For instance, my plan was to use OpenHAB to provide mqtt updates on behalf of my Insteon network.

You need to write a rule to publish the mqtt when the other event is received.

1 Like

Thanks so much for sending me on the right path. I have it working now through eventbus. I believe that I can use this to get started on my path.

Thanks very much for your guidance and attention. I sincerely appreciate it.