diff --git a/mixer.py b/mixer.py index e8c36d5..db17af8 100755 --- a/mixer.py +++ b/mixer.py @@ -46,6 +46,12 @@ class Mixer: self.qu_midi_channel = self.get_system_state().midi_channel self.daw_midi_channel = self.qu_midi_channel + 1 + def __del__(self): + # This final recv is used to keep the connection open a bit. + # If socket connection is closed to early, previous command may not be executed: + self.recv_sys_ex() + + ALLEN_HEATH_ID = [0x00, 0x00, 0x1A] QU_MIXER = [0x50, 0x11] MAJOR_MINOR = [0x01, 0x00] diff --git a/mqtt_client.py b/mqtt_client.py index e132ca8..4f2485b 100755 --- a/mqtt_client.py +++ b/mqtt_client.py @@ -13,7 +13,7 @@ class MqttClient: MQTT_COMMAND_TOPIC = "livingroom/voc/allen_heath_qu16_mixer" def __init__(self, mixer_ip): - self.mixer = Mixer(mixer_ip) + self.mixer_ip = mixer_ip self.client = mqtt.Client(callback_api_version=mqtt.CallbackAPIVersion.VERSION2) def mqtt_autodiscovery(self): @@ -48,11 +48,13 @@ class MqttClient: j = json.loads(payload) + mixer = Mixer(self.mixer_ip) + match j["command"]: case "scene_recall": - self.mixer.scene_recall(j["args"]["scene_id"]) + mixer.scene_recall(j["args"]["scene_id"]) case "shutdown": - self.mixer.shutdown() + mixer.shutdown() def run(self, hostname): self.client.on_connect = self.on_connect