Sending commands to MQTT broker

Hi,
I would like to set the GPIO output pin #2 on a ESP8266 which is connected to OpenHAB3 over MQTT. As MQTT-borker I am using mosquitto.

In OpenHAB3 I created a thing ESP_1 and channel ESP_1_command, which is associated with the MQTT-topic ESP_1/cmd.
I can test the MQTT communication with mosquitto_pub -t ESP_1/cmd -m GPIO,2,1 and in the ESP log I can see that the GPIO is set.

In OH3 the next step was to link a switch item to this channel and to place this switch on the GUI .
It is working, I can toggle the state of the switch on the GUI, but at the end only a message “ON” or “OFF” is sent to the MQTT-topic, which is clearly not recogized by the ESP8266.

It should be in the following way:
a change of the switch state to ON should send an MQTT-message GPIF,2,1 and
a change of the switch state to OFF should send an MQTT-message GPIF,2,0.

Is there a way in OH3 to convert the state ON and OFF of the switch-item into the correct MQTT-message? From the discussions I read I get the impression at least in OH1 that there existed a way how to do this.

Or would be a better solution to define a RULE, but then the linking of the switch-item to the Command channel would not make sense.

I would be happy, if anyone could give me some advice.

Br,
Ernst

Yes there is. How did you set this up? If it’s via the UI, check the custom on/off fields for your Channel…

Solved, the ON- and OFF command can be set in the channel definition.