Trying to figure out how to attach MQTT to an item

Hi,
I’m very new to this. I got my arduino setup and connected to a mqtt broker and also set up that broker in openHAB and it connects and everything. The issue is I can’t figure out how to connect up MQTT to an item. I tried it in multiple different ways looking around on google none of which seemed to work. I think it might be related to the broker part of it but I’m not sure how the MQTT data is formatted. (as in like whats the > vs. < or what does command:*:default do/mean and how does it get sent out to MQTT). The MQTT topic that should get on or off should be “desk/rgb-lights/switch”. I’ve tested it with MQTT.fx and it does work correctly without openHAB.
If anyone could help that would be great :smiley:

Group:Switch:OR(ON, OFF)        Lights      "All Lights [(%d)]"

Switch DeskLight "Desk Light" (Lights) ["Lighting"] {alexa="Switchable",mqtt=">[broker:desk/rgb-lights/switch:command:ON:default]",expire="30s,command=OFF"}

Your syntax for MQTT is for v1 of the MQTT binding. Which version of the MQTT binding do you actually have installed?

I have version 2.5.7.

Good, so we’ll need to adjust the item definition so that it connects to the channel of your desk light thing.

Why is the desk light thing showing offline? Can you show how it is configured?

Heres the Config or I believe is the config


Did you create these in paperUI? Did you link your on/off channel already via PaperUI to an item? Can you show us the configuration of the on/off channel?

The on/off channel is connected to an item. Heres the linked item config

Right, but that doesn’t answer any of the questions.

In general, if your thing is correctly setup, and your channels are subscribed to the correct topics, then you link your item as follows:

Switch MySwitch "MySwitch" { channel="mqtt:broker:84138e77:light-switch" }

I just figured out why… I had it connected to a different item which wasn’t set up in the items file so it wasn’t hooked up to the correct item. Now it works correctly and everything is working good :smiley: Thanks for your help!