Callbacks¶
Reacting to state changes rather than polling for them.
Callbacks¶
Subclass MxrCallbacks to receive notifications when device or bay state changes:
class MyCallbacks(mx_remote.MxrCallbacks):
def on_device_config_complete(self, dev):
print(f"Device ready: {dev.serial} ({dev.name})")
def on_bay_registered(self, bay):
print(f"Bay found: {bay.bay_label}")
def on_video_source_changed(self, bay, video_source):
print(f"{bay.user_name} video source -> {video_source.user_name}")
def on_audio_source_changed(self, bay, audio_source):
print(f"{bay.user_name} audio source -> {audio_source.user_name}")
def on_volume_changed(self, bay, volume):
print(f"{bay.user_name} volume: {volume}")
def on_power_changed(self, bay, power):
print(f"{bay.user_name} power: {power}")
def on_device_online_status_changed(self, dev, online):
print(f"{dev.serial} {'online' if online else 'offline'}")
mx = mx_remote.Remote(callbacks=MyCallbacks())
Available callback methods:
Method |
Trigger |
|---|---|
|
any device property changed |
|
any bay property changed |
|
device configuration updated |
|
all device configuration received |
|
device went online/offline |
|
temperature readings changed |
|
new bay discovered |
|
video routing changed |
|
audio routing changed |
|
volume or mute status changed |
|
CEC power status changed |
|
user-assigned bay name changed |
|
signal detect status changed |
|
fault status changed |
|
hidden status changed |
|
PoE power status changed |
|
HDBaseT link status changed |
|
signal type changed |
|
hotplug detect changed |
|
CEC device detected/lost |
|
audio return channel status changed |
|
remote control key press received |
|
remote control action received |
|
virtual link created |
|
virtual link removed |
|
bay mirroring changed |
|
bay filtering changed |
|
EDID profile changed |
|
remote control type changed |
|
amplifier zone settings changed |
|
amplifier Dolby settings changed |
You can also register per-device and per-bay callbacks:
def on_device_changed(device):
print(f"{device.serial} updated")
def on_bay_changed(bay):
print(f"{bay.bay_label} updated")
device.register_callback(on_device_changed)
bay.register_callback(on_bay_changed)
# to unregister:
device.unregister_callback(on_device_changed)
bay.unregister_callback(on_bay_changed)