mqtt-tools / mqttwarn

A highly configurable MQTT message router, where the routing targets are notification plugins, primarily written in Python.
https://mqttwarn.readthedocs.io/
Eclipse Public License 2.0
950 stars 183 forks source link

Add example "Simple MQTT media player" #658

Closed amotl closed 1 year ago

amotl commented 1 year ago

Hi there,

@nagyrobi presented an idea for a simple MQTT media player at https://github.com/jpmens/mqtt-launcher/issues/41 the other day. This patch implements the idea on behalf of an mqttwarn configuration for its "execute" plugin. Thank you!

At https://github.com/jpmens/mqtt-launcher/issues/35, @toblie also signalled interest in such a feature for mqtt-launcher.

Until the patch is integrated, the documentation and configuration can be inspected at Simple MQTT media player » README and mqttwarn-mplayer.ini, which looks like that,

# Simple MQTT media player using mqttwarn and mplayer.
# https://mqttwarn.readthedocs.io/en/latest/examples/mediaplayer/readme.html

[defaults]
launch = execute

[config:execute]
targets = {
    'mediaplayer-play': [ 'mplayer', '-volume', '80', '[TEXT]' ],
  }

[mediaplayer/play]
targets = execute:mediaplayer-play

and will be invoked with a corresponding MQTT message like:

echo 'http://home.assistant.address:8123/api/tts_proxy/6a0efdf280bf8c79a.mp3' | \
  mosquitto_pub -t 'mediaplayer/play' -l

With kind regards, Andreas.