Send MQTT Topic from linux terminal

Hardware: raspberry pi 3
OS: openhabianpi-raspbian-201804031720-gitdba76f6-crc9e93c3eb.img.xz
java: openjdk version “1.8.0_152”
openHAB version: 2.4.0-1

sitemap

sitemap default label=“My first sitemap”
{
Frame label=“Kitchen” {
Switch item=Kitchen_Light label=“Kitchen Lamp”
}
}

items

Switch Kitchen_Light “Kitchen Light” { channel=“mqtt:topic:4e88d0c8:kitchen_lamp” }

Generic MQTT Thing
Channel

    Kitchen Lamp
    mqtt:topic:4e88d0c8:kitchen_lamp
    Switch

mqtt.cnf

mosquitto.url=tcp://192.168.0.101:1883
mosquitto.clientId=myhome
mosquitto.qos=1
mosquitto.retain=true
mosquitto.async=false
mosquitto.user=openhabian
mosquitto.pwd=pass

When I try to send topic message from terminal to my test Kitchen Light topic nothing is happened in basigUI and Paper UI

When try to change my Kitchen_Switch from basicui i recieved events log in openhab event log

2019-03-06 22:42:14.594 [ome.event.ItemCommandEvent] - Item ‘Kitchen_Light’ received command ON

2019-03-06 22:42:14.608 [nt.ItemStatePredictedEvent] - Kitchen_Light predicted to become ON

2019-03-06 22:42:14.617 [vent.ItemStateChangedEvent] - Kitchen_Light changed from OFF to ON

And my question is: How can i send command (message topic) from outside - terminal in linux, my own android app or other raspberry pi or arduino nano or D1 mini

You don’t show the Channel config, but I suspect you are either missing or have a typo in the incoming topic.

Typically a light will have two topics. One command topic that external clients publish to (i.e. openHAB and your terminal client) to control the light. The other is a state topic that the device publishes to when ever it changes state (i.e. on or off).

So you would publish from the terminal to the command topic, the device will turn on (or off), the device will publish that it turned on (or off) to the state topic, OH will see that message and update the Items accordingly.

In my case openhab service should be restart. The channel config was copy paste from Paper UI.

Now i successfully show 2 switches and 1 text and all 3 items successfully received message from external device (in my case linux terminal and android app mqtt client)

10x for helping