Compare commits

..

2 commits

View file

@ -2,20 +2,44 @@
import argparse import argparse
import json import json
import time
import paho.mqtt.client as mqtt import paho.mqtt.client as mqtt
import mixer import mixer
from mixer import Mixer from mixer import Mixer
MQTT_SERVER_PORT = 1883 MQTT_SERVER_PORT = 1883
MQTT_TOPIC = "homeassistant/device/mixer" MQTT_DISCOVERY_TOPIC = "homeassistant/button/mixer/config"
MQTT_COMMAND_TOPIC = "livingroom/voc/allen_heath_qu16_mixer"
m: Mixer = None m: Mixer = None
def mqtt_autodiscovery(client):
j = json.dumps(
{
"name": "Reset Settings",
"command_topic": MQTT_COMMAND_TOPIC,
"command_template": '{"command": "scene_recall", "args": {"scene_id": 0}}',
"device": {
"name": "Mischpult",
"model": "Qu-16",
"manufacturer": "Allen & Heath",
"suggested_area": "livingroom",
"identifiers": "Mischpult",
},
"unique_id": "mischpult_reset_settings",
}
)
client.publish(MQTT_DISCOVERY_TOPIC, payload=j, qos=0, retain=False)
def on_connect(client, userdata, flags, reason_code, properties): def on_connect(client, userdata, flags, reason_code, properties):
print(f"Connected: {reason_code}") print(f"Connected: {reason_code}")
client.subscribe(MQTT_TOPIC) client.subscribe(MQTT_COMMAND_TOPIC)
mqtt_autodiscovery(client)
def on_message(client, userdata, msg): def on_message(client, userdata, msg):
@ -36,6 +60,18 @@ def main():
parser = argparse.ArgumentParser(description="Allen & Heath Qu MQTT Remote Control") parser = argparse.ArgumentParser(description="Allen & Heath Qu MQTT Remote Control")
parser.add_argument("mixer_ip", help="IP of the mixer") parser.add_argument("mixer_ip", help="IP of the mixer")
parser.add_argument("mqtt_hostname", help="IP of the MQTT broker") parser.add_argument("mqtt_hostname", help="IP of the MQTT broker")
subparsers = parser.add_subparsers(
dest="command", required=True, help="Available commands"
)
subparsers.add_parser("shutdown", help="Shut down the mixer")
scene_parser = subparsers.add_parser("scene_recall", help="Recall a specific scene")
scene_parser.add_argument(
"scene_number", type=int, choices=range(0, 100), help="Scene number to recall"
)
args = parser.parse_args() args = parser.parse_args()
print(f"Mixer IP: {args.mixer_ip}, MQTT broker hostname: {args.mqtt_hostname}") print(f"Mixer IP: {args.mixer_ip}, MQTT broker hostname: {args.mqtt_hostname}")