You don’t “call” it.
You interact with MQTT topics in two ways: subscribe (listen for messages published to a topic) and publish (send message to topic). As you have discovered you can manipulate topics you SUBSCRIBE to using wildcards. Technical restrictions aside you could have hundreds of clients/scrips SUBSCRIBED to a topic for any MESSAGES published to the topic, and each of those can then react as they wish.
For example, let’s say I have a motion sensor in the living room that PUBLISHES a MESSAGE to Home/Living Room/Motion/Detected
when motion is detected. The sensor doesn’t care if anything is SUBSCRIBED at all, nor does it care what happens as a result of it publishing, it’s just publishing. “Hey, just letting you know I’ve detected motion in the living room. If you hear this, do what you like”.
There may be absolutely no clients/scripts SUBSCRIBED, and that’s fine. Equally, there might be several. I could have a light script SUBSCRIBED: “Ah, motion. The light isn’t on and it’s dark in here. I’ll turn the light on”. I could have a security script SUBSCRIBED: “Ah, there’s motion in the living room, and nobody is home. I will notify the owner”. The security script could SUBSCRIBE to all motion sensors using a wildcard for the room Home/+/Motion/Detected
: “Ah, there’s motion in the garden, but the owner isn’t home and doen’t need to know this as it’s probably a bird” OR “Ah, there’s motion in the garden, the owner is home and it could be that pesky cat again”.
Looking back at the Rhasspy question, the hotword triggers Rhasspy to PUBLISH to hermes/asr/startListening
with a MESSAGE. Rhasspy is SUBSCRIBED to that topic for any MESSAGES published and runs some code. There’s no reason you cannot set up 10x scripts SUBSCRIBED to that topic too, each running different code when it’s published to. You’re not PUBLISHING to it, you’re SUBSCRIBING to it, for any messages that have been published to it and taking action as appropriate.
You can PUBLISH to these MQTT topics too, they’re not restricted to a process. You could trigger Rhasspy to wake by pressing a button if you wanted, as well as a hotword. Program a button to PUBLISH to hermes/hotword/<wakewordId>/detected
with a MESSAGE as outlined in the Rhasspy documentation and you’ve got yourself a wake button.
A non technical example would be: you start a group chat with 4 friends about catching a film this evening. The topic is “catching a film this evening”, the message is “the time, film and location”. The subscribers are those who accept the group chat. You are PUBLISHING the message to that topic. Friend 1 doesn’t have signal and sadly doesn’t receive the message (loosely MQTT QoS), friend 2 receives the message and agrees to come, friend 3 ignores you as he’s decided the message isn’t relevant to him as it’s a horror film and friend 4 declines due the time.
Back to Rhasspy. You could listen for StartListening messages to prepare to create a WAV file, then listen for relevant audioFrames, and lastly StopListening to finalise/process/handle the file as you so wish - or something to that effect.
I hope this has helped. I really recommend you do some reading into MQTT. I’m more than happy to provide some sources if you’d prefer but there’s a wealth of material out there if you search. If you have specific questions then reach out.