Skip to content

How to use MPF with OSC Devices or Hardware

Related Config File Sections:

MPF can use the Open Sound Control (OSC) to interface with other software or hardware devices. As OSC messages are not standardized we define a few custom messages:

Incoming:

  • /sw/switch_name with the state True or False as parameter to set the state of an OSC switch in MPF
  • /event/event_name with parameters in the form key1, value1, key2, value2, ... to post events to MPF.

Outgoing:

  • /light/light_name/color with the brightness of the color as float (0-1).
  • /event/event_name with parameters in the form key1, value1, key2, value2, ... for all events configured in events_to_send in your osc config section.

This is an example:

hardware:
  platform: osc

osc:
  remote_ip: 127.0.0.1
  remote_port: 8000

  events_to_send:
    - player_score
    - some_non_osc_switch_active
    - some_non_osc_switch_inactive

lights:
  test_light1:
    channels:
      red:
        - number: light1/red
      blue:
        - number: light1/blue
      green:
        - number: light1/green
  test_light2:
    number: light2

switches:
  switch_1:
    number: 1
  switch_2:
    number: 2
  some_non_osc_switch:  # not an OSC switch but used for the events above
    number: 23
    platform: virtual

You need to install python-osc to use the OSC platform:

pip3 install python-osc

What if it did not work?

Have a look at our hardware troubleshooting guide.


Something missing or wrong? You can fix it!

This website is edited by people like you! Is something wrong or missing? Is something out of date, or can you explain it better?

Please help us! You can fix it yourself and be an official "open source" contributor!

It's easy! See our Beginner's guide to editing the docs.

Page navigation via the keyboard: < >

You can navigate this site via the keyboard. There are two modes:

General navigation, when search is not focused:

  • F , S , / : open search dialog
  • P , , : go to previous page
  • N , . : go to next page

While using the search function:

  • Down , Up : select next / previous result
  • Esc , Tab : close search
  • Enter : go to highlighted page in the results