mqtt_client.py: connect to mixer on demand
This commit is contained in:
parent
b17b26a326
commit
5d39ab08f2
2 changed files with 11 additions and 3 deletions
6
mixer.py
6
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]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue