I may write a Python version of scanning the DiscoHAT I/O pins when time permits. Here is the script in bash that worked for the lamp switch on/off and for the doorbell.
Python is called here for controlling the QLC+ through the OSC interface.
The first python script is for toggling the state of the lamp (lamp.py):
The second script is for the doorbell (ding.py):
As you can see it does not really matter what you send to the liblo interface as long as it is different for every button. In QLC+ you click on the button and open properties to "learn" the external OSC commands.
Controlling dbus applications
QLC+ is not the only program supporting remote commands. A very nice music player called Clementine can also be controlled in python.
Here we ask for the title and the artist:
import dbus # Clementine lives on the Session bus session_bus = dbus.SessionBus() # Get Clementine's player object, and then get an interface from that object, # otherwise we'd have to type out the full interface name on every method call. player = session_bus.get_object('org.mpris.clementine', '/Player') iface = dbus.Interface(player, dbus_interface='org.freedesktop.MediaPlayer') # Call a method on the interface metadata = iface.GetMetadata() print metadata["title"] print metadata["artist"]
We could also ask it to play the next tune by: