From 3e123bc75180badd8d2bf1e56ef0ff799637b19e Mon Sep 17 00:00:00 2001 From: coon Date: Thu, 25 Sep 2025 20:59:28 +0200 Subject: [PATCH 1/4] move MIXER_PORT into Mixer class --- mixer.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mixer.py b/mixer.py index a9d758b..77f001f 100755 --- a/mixer.py +++ b/mixer.py @@ -6,12 +6,11 @@ import mido from enum import Enum -MIXER_PORT = 51325 - class Mixer: - def __init__(self, ip, port): - self.sock = socket.create_connection((ip, port)) + def __init__(self, ip): + self.MIXER_PORT = 51325 + self.sock = socket.create_connection((ip, self.MIXER_PORT)) ALLEN_HEATH_ID = [0x00, 0x00, 0x1A] QU_MIXER = [0x50, 0x11] @@ -207,7 +206,7 @@ def main(): args = parser.parse_args() print(f"IP: {args.ip}") - mixer = Mixer(args.ip, MIXER_PORT) + mixer = Mixer(args.ip) if args.command: print(f"Command: {args.command}") From 0f3ab79bdb85afc0bdc33be25d51d3f3ac0cba6c Mon Sep 17 00:00:00 2001 From: coon Date: Thu, 25 Sep 2025 21:04:43 +0200 Subject: [PATCH 2/4] make mido parser a class var --- mixer.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mixer.py b/mixer.py index 77f001f..7ed3639 100755 --- a/mixer.py +++ b/mixer.py @@ -11,6 +11,7 @@ class Mixer: def __init__(self, ip): self.MIXER_PORT = 51325 self.sock = socket.create_connection((ip, self.MIXER_PORT)) + self.mido_parser = mido.Parser() ALLEN_HEATH_ID = [0x00, 0x00, 0x1A] QU_MIXER = [0x50, 0x11] @@ -28,18 +29,16 @@ class Mixer: GET_METER_DATA_RESPONSE = 0x13 def recv_sys_ex(self, response_msg_filter: SysExMessageId = None): - p = mido.Parser() - while True: data = self.sock.recv(1024) if not data: break - p.feed(data) + self.mido_parser.feed(data) - if p.pending(): - msg = p.get_message() + if self.mido_parser.pending(): + msg = self.mido_parser.get_message() print(vars(msg)) From 238aada4a19e54fc78aeafe2f1cc81ca9633cb25 Mon Sep 17 00:00:00 2001 From: coon Date: Thu, 25 Sep 2025 21:17:51 +0200 Subject: [PATCH 3/4] use MQTT credentials from mqtt_client.py --- hass_button_emulator.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hass_button_emulator.py b/hass_button_emulator.py index 49231e8..9ec98c2 100755 --- a/hass_button_emulator.py +++ b/hass_button_emulator.py @@ -4,9 +4,7 @@ import time import paho.mqtt.client as mqtt import json -MQTT_SERVER_ADDRESS = "localhost" -MQTT_SERVER_PORT = 1883 -MQTT_TOPIC = "homeassistant/device/mixer" +import mqtt_client def on_connect(client, userdata, flags, reason_code, properties): @@ -22,13 +20,13 @@ client = mqtt.Client(callback_api_version=mqtt.CallbackAPIVersion.VERSION2) client.on_connect = on_connect client.on_message = on_message -client.connect(MQTT_SERVER_ADDRESS, MQTT_SERVER_PORT, 60) +client.connect(mqtt_client.MQTT_SERVER_ADDRESS, mqtt_client.MQTT_SERVER_PORT, 60) client.loop_start() -j = json.dumps({"command": "scene_recall", "args": {"scene_id": 42}}) +j = json.dumps({"command": "scene_recall", "args": {"scene_id": 0}}) # j = json.dumps({'command': 'shutdown'}) -client.publish(MQTT_TOPIC, payload=j, qos=0, retain=False) +client.publish(mqtt_client.MQTT_TOPIC, payload=j, qos=0, retain=False) time.sleep(2) From cd65e57b67125d3afe79784edefd6afadd4b14ed Mon Sep 17 00:00:00 2001 From: coon Date: Thu, 25 Sep 2025 22:00:40 +0200 Subject: [PATCH 4/4] add comment with link to A&H midi spec --- mixer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mixer.py b/mixer.py index 7ed3639..5012533 100755 --- a/mixer.py +++ b/mixer.py @@ -6,6 +6,8 @@ import mido from enum import Enum +# For Allen & Heath Qu MIDI protocol documentation see: +# https://www.allen-heath.com/content/uploads/2023/06/Qu_MIDI_Protocol_V1.9.pdf class Mixer: def __init__(self, ip):