Warning

This is the documentation the latest work-in-progress version of MPF!

This is the documentation for MPF 0.56, which is the “dev” (next) release of MPF that is a work-in-progress. This is probably ok, and means you’ll be on the latest, cutting-edge version of MPF.

However, if you want a more stable version, select the v:stable version from the lower-left corner of this page, which is the most recent version that is not getting new updates.

If you are new to MPF, we have recently rewritten the installation process which only applies to this “latest” 0.56, so you probably want to stay here because the prior installation process doesn’t work on the latest OS and Python versions.

How to use MPF with OSC Devices or Hardware

Related Config File Sections
hardware:
osc:
switches:
lights:

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
This example is tested to be valid MPF config. However, it is not integration tested.
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.