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
|
@ -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