[SOLVED] Sending outgoing MQTT messsage

  • Platform information:
    • Hardware: Raspberry 3b+
    • OS: openhabian
    • openHAB version: openHAB 2.4.0 Release Build
  • Issue of the topic: I want to send some Mqqt messages issued by some voice commands from Google Assistant.
    I have setup the embedded MQTT broker with the 2.4.0 MQTT binding and when I manually send commands via console, everything is working as intended.
mosquitto_pub -d -t winthing/keyboard/commands/press_keys -m "["CONTROL", "X"]"

When I toggle the below stated switch, nothing is happening (no mqtt message arrives).The current mqtt documentation is not mentioning outbound messages anymore. Is that still supported and if yes how do I need to do that?

  • configurations:
Switch test "test" <switch>  [ "Switchable" ] {mqtt=">[embedded-mqtt-broker:winthing/keyboard/commands/press_keys:command:ON:testmessage],>[embedded-mqtt-broker:winthing/keyboard/commands/press_keys:command:OFF:testmessage]", autoupdate="false"}

Thanks for your help.

This a mqtt config for MQTTv1
You have MQTTv2

You need to create a MQTT bridge thing in the paperUI
Configuration -> Things -> + -> MQTT Binding (The binding should scan for brokers but if it doesn’t find one select MQTT Broker) - Enter your broker parameters -> Save

Then you need to create another thing for your sonoff:
Configuration -> Things -> = -> MQTT Binding -> Add manually -> Generic MQTT Thing
Open the thing and add a switch channel

For a sonoff Tasmotta you need the the outbound: winthing/keyboard/commands/press_keys

BUT the binding will send ON of OFF, that’s it because it’s a switch

1 Like

Thanks for pointing me in the right direction, but I still can’t get it working.
I created the Generic MQTT thing and added a switch channel to it. Into the filed “MQTT command topic” I entered the topic (“winthing/keyboard/commands/press_keys”).

Then I created the following item:

Switch test "test" <switch>  [ "Switchable" ] {channel="mqtt:topic:c4c27146:entertain"}

Anything else required? So far no messages are getting send, when the switch is toggled. The MQTT Broker was already autodiscovered and added as thing.

Can you post your thing channel list and this channel config, please?

Are the below pictures what you are asking for?
Thanks for your support! :slight_smile:

Best regards

Looks ok.
Anything in the logs?

I only see the toggle event fof the switch in the logs.

2018-12-22 22:52:38.477 [ome.event.ItemCommandEvent] - Item 'test' received command ON

2018-12-22 22:52:38.487 [nt.ItemStatePredictedEvent] - test predicted to become ON

2018-12-22 22:52:38.500 [vent.ItemStateChangedEvent] - test changed from OFF to ON

2018-12-22 22:52:39.946 [ome.event.ItemCommandEvent] - Item 'test' received command OFF

2018-12-22 22:52:39.952 [nt.ItemStatePredictedEvent] - test predicted to become OFF

2018-12-22 22:52:39.965 [vent.ItemStateChangedEvent] - test changed from ON to OFF

A Rebbot of the system fixed the issue … :sweat_smile:

Will try that earlier next time.

Everything is now working as it should. :hugs: