Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program arguments from payload #41

Open
nagyrobi opened this issue Dec 26, 2021 · 3 comments
Open

Program arguments from payload #41

nagyrobi opened this issue Dec 26, 2021 · 3 comments

Comments

@nagyrobi
Copy link

nagyrobi commented Dec 26, 2021

Hi @jpmens thanks for this great experiment!

I was thinking to implement a simple mqtt media player on linux which could be use to play TTS messages from Home Assistant.
It's very simple, HA renders the TTS stream as an MP3 available on its own server via http protocol, so something like
mplayer -volume 80 http://home.assistant.address:8123/api/tts_proxy/6a0efdf280bf8c79a.mp3
shot from the command line would play the sound.

The goal is to be able to get the URL from the payload because that changes every time, at every message spoken.
So with mqtt-launcher we would need a variable containing the payload to be accessed in the program & arguments part of the config. For example sending the URL above to the topic mybox/mediaplay could be decoded with a special key like @payload@:

# topic         payload value           program & arguments
"mybox/mediaplay"  :   {
                    '@payload@'        :   [ 'mplayer', '-volume', '80', '@payload@'],
                },

Or anything similar...
What do you think?

@jpmens
Copy link
Owner

jpmens commented Dec 29, 2021

Related to #35

@hurra
Copy link

hurra commented Nov 21, 2022

A solution with regular expressions and capture groups ist the most flexible here

@amotl
Copy link

amotl commented May 8, 2023

Dear @nagyrobi, @hurra, and @toblie,

thanks a stack for sharing your use cases. We added a corresponding implementation to the mqttwarn example gallery at Simple MQTT media player with mqttwarn and mplayer. Enjoy, and let us know about any issues or success stories over at the mqttwarn issue tracker.

With kind regards,
Andreas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants