[RESOLVED] Item as a gateway MQTT <=> UDP

Hi,

I have to do a proof of concept for a connected socket.
I have to develop a “gateway” between a external MQTT and my socket.
Here is the idea:

  • My item receives a MQTT JSON (see the format below) from an external server.
  • It send an UDP packet containing the JSON received from MQTT to my socket.

When the user switch on/off the socket manually (there’s a button on it), this should happen:

  • The socket sends an UDP packet containing a JSON to openHAB.
  • The item receives that JSON from UDP and send it to MQTT (as a gateway).

I don’t know how to do that (deal with transformations, event bus, etc.).

Can you help me please ?

Thanks.

Try:

String Gateway "text [%s]" { udp="<[192.168.0.2:3000:'REGEX((.*))']", mqtt=">[broker:topic:state:default]" }

Whenever the UDP client on 192.168.0.2 port 3000 sends a string, publish it to broker on topic.

Genius. This is working perfectly.

Thank you.

1 Like