A bridge between OSC and MQTT
Go to file
2023-04-23 10:46:37 -05:00
.github/workflows Fix config path name, add dockerfile, add workflow. 2023-04-23 10:46:37 -05:00
.gitignore Fix config path name, add dockerfile, add workflow. 2023-04-23 10:46:37 -05:00
config.go Fix config path name, add dockerfile, add workflow. 2023-04-23 10:46:37 -05:00
Dockerfile Fix config path name, add dockerfile, add workflow. 2023-04-23 10:46:37 -05:00
flags.go First commit 2023-04-20 22:36:51 -05:00
go.mod First commit 2023-04-20 22:36:51 -05:00
go.sum First commit 2023-04-20 22:36:51 -05:00
License.txt First commit 2023-04-20 22:36:51 -05:00
main.go First commit 2023-04-20 22:36:51 -05:00
README.md Fix config path name, add dockerfile, add workflow. 2023-04-23 10:46:37 -05:00
relay.go Fix config path name, add dockerfile, add workflow. 2023-04-23 10:46:37 -05:00

osc-mqtt-bridge

A bridge between Open Sound Control (OSC) and MQTT, allowind bidirectional communication. The main purpose of this tool is to provide a way to talk to devices that support OSC via MQTT messages for automation.

Example configuration

relays:
  - mqtt_host: 10.0.0.2
    mqtt_port: 1883
    mqtt_client_id: osc_mqtt_bridge
    mqtt_user: mqtt
    mqtt_password: PASSWORD
    mqtt_topic: osc/behringer_wing
    osc_host: 10.0.0.3
    osc_port: 2223
    osc_bind_addr: 0.0.0.0
    log_level: 2

Configuration specification

Relay

  • mqtt_host: Hostname of the MQTT broker.

  • mqtt_port: Port of the MQTT broker.

  • mqtt_client_id: MQTT client ID of this relay.

  • mqtt_user: User name used for MQTT authentication.

  • mqtt_password: Password used for MQTT authentication.

  • mqtt_topic: Topic where MQTT messages are pushed and received.

    Set topic to osc/example and the following topics will be setup.

    • osc/example/cmd/$OSC_CMD - Any commands received on OSC will publish here.
    • osc/example/send/$OSC_CMD - Any commands pushed via MQTT will be forwarded to OSC.
    • osc/example/bundle - OSC Bundle messages.
    • osc/example/bundle/send - Send OSC Bundle messages.
    • osc/example/status - Configuration is published on startup.
    • osc/example/status/check - Request status.

  • mqtt_disable_config_send: Disables the config send.

  • osc_host: Hostname for OSC client connection.

  • osc_port: Port for OSC client connection.

  • osc_bind_addr: Bind address of the OSC server.

    To have bidirectional mode, you must specify at least this, OscHost, and OscPort defined.

  • osc_bind_port: Port of the OSC server. Defaults to OscPort if specified.

  • osc_disallow_arbritary_command: Disallows pushing to arbritary commands to the cmd topic.

  • commands: Pre-defined commands to relay.

    This is an array with the following variables.

    • command: The command path to send.
    • mqtt_topic: Absolute MQTT topic to subscribe.
    • mqtt_sub_topic: Sub topic off relay MQTT topic to subscribe. osc/example/$SUB_TOPIC
    • disallow_payload: Rather or not to disallow payload to be relayed.
    • default_payload: Payload to send if no payload is provided via MQTT or if DisallowPayload is true. This is an array of strings/integers/timestamps/bools.

  • osc_subscriptions: OSC Comamnds to send at regular intervals. Useful for OSC servers that offers data subscriptions.

    This is an array with the following variables.

    • command: The command to send every interval.
    • payload: Payload to send. This is an array of strings/integers/timestamps/bools.
    • interval: How often to call the command.

  • log_level: How much logging.

    • 0 - Errors
    • 1 - MQTT and OSC receive logging.
    • 2 - MQTT and OSC send logging.
    • 3 - Debug

MQTT Message Example

Mute Behringer Wing channel 1
Topic: osc/behringer_wing/send/ch/1/mute
Payload: ["1"]

Behringer Wing get info
Topic: osc/behringer_wing/send/?
Payload:

Build

go build

Golang 1.19 and below are known to have issues, 1.20 works.

Config file location

Same directory as the binary, in your home directory at ~/.config/osc-mqtt-bridge/config.yaml, or under etc at /etc/osc-mqtt-bridge/config.yaml.

Docker

I have made docker images for this product as I use docker for home assistant in my environment and wanted to keep with the existing scheme for services that are used with home assistant.

Build Image

docker build --tag osc-mqtt-bridge .

Run

docker run --volume ./config:/etc/osc-mqtt-bridge --publish 2223:2223/udp osc-mqtt-bridge

Docker compose