mqtt_client.py: connect to mixer on demand

This commit is contained in:
coon 2025-10-02 22:12:45 +02:00
parent b17b26a326
commit b61f9ca299

View file

@ -13,7 +13,7 @@ class MqttClient:
MQTT_COMMAND_TOPIC = "livingroom/voc/allen_heath_qu16_mixer" MQTT_COMMAND_TOPIC = "livingroom/voc/allen_heath_qu16_mixer"
def __init__(self, mixer_ip): 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) self.client = mqtt.Client(callback_api_version=mqtt.CallbackAPIVersion.VERSION2)
def mqtt_autodiscovery(self): def mqtt_autodiscovery(self):
@ -48,11 +48,13 @@ class MqttClient:
j = json.loads(payload) j = json.loads(payload)
mixer = Mixer(self.mixer_ip)
match j["command"]: match j["command"]:
case "scene_recall": case "scene_recall":
self.mixer.scene_recall(j["args"]["scene_id"]) mixer.scene_recall(j["args"]["scene_id"])
case "shutdown": case "shutdown":
self.mixer.shutdown() mixer.shutdown()
def run(self, hostname): def run(self, hostname):
self.client.on_connect = self.on_connect self.client.on_connect = self.on_connect