Controlling MUSE Relay Ports with Python Code
Technical Support Guide
Brand:
- AMX
Models:
- MU-1000
- MU-1300
- MU-2300
- MU-3300
Overview:
The below Python code controls a relay port on a MUSE controller. It contains code that energizes a relay port when a button is pressed and then disengages the relay port when it is released.
from mojo import context
context.log.info('Sample Python program')
#Creates the objects for the controller (idevice), touch panel (dvTP), and CE-REL8 (dvREL8)
dvTP = context.devices.get("AMX-11241")
idevice = context.devices.get("idevice")
dvREL8 = context.devices.get("CE-REL-AB245D")
#Creates simple variables that access the first relay port on both the idevice and CE-REL8
dvRelay1 = idevice.relay[0]
dvREL1 = dvREL8.relay[0]
#This function processes button events for Port 1 Button 1 on the touch panel
#The value of the relay is tied to the state of the button, while the button is pressed the relay will engage, when the button is released it will disengage
def Relay1(event):
dvRelay1.state.value = event.value
dvREL1.state.value = event.value
#Creates a watch for Port 1, Button 1
dvTP.port[1].button[1].watch(Relay1)
# leave this as the last line in the Python script
context.run(globals())