Help link mqtt publish to openhab2

i have a esp8266 set up so when i send “OPEN” or “CLOSE” in mqtt.fx it will turn the motor either forward or backwards. but i want to make it so i have a switch on the open hab ios app that when on it publishes “OPEN” and when its off it publishes “CLOSED”. can anyone help me with the code on the home.sitemap and the home.items?

Over all:

these are my home.items and home.sitemap files

home.sitemap =
"sitemap home label=“JG-SmartHouse”
Frame label=“Security”
Switch item=DEMOSW
Frame label=“JG-Room”
Switch item=JG_Light_Switch label=“Light Switch"
Switch item=JG_DoorController1 label=“Door”
Frame label=“Living Room”
Switch item=DEMOSW

home.items =
"//This is the Items File

//Demo items
Switch DEMOSW “Demo Switch”

Switch JG_Light_Switch “Ceiling Light” [ “lighting” ]

Switch JG-DoorController1 “DoorController” {MQTT=">[broker:JG-SmartHouse/utilities/JG-DoorController1:command:ON:OPEN],>[broker:JG-SmartHouse/utilities/JG-DoorController1:command:OFF:CLOSE]"}

I understand how to make a switch and an item but i dont uderstand how to make a switch publish something on mqtt. please help.

Here is one of my esp8266 that get’s and sendt info using MQTT.

Hope that works.

Switch light_adju “Adjudantvænget Light” [ “Switchable” ] {mqtt=">[broker:groundfloor/outdoor/light/setadju:command:ON:1],>[broker:groundfloor/outdoor/light/setadju:command:OFF:0],<[broker:groundfloor/outdoor/light/getadju:state:JS(lightValue.js)]"}

The lightvalue.js is a transformation, htat converts on/off to 0 and 1.

Did you read through the item and mqtt pages that @rlkoshak linked above? They give a pretty good explanation and examples.