MPD Play/Pause automation

File

Home made webradio on Toniebox is the ultimate thing. We have different music playlists on one stream, and also a concurrent stream with audio book. While on music playlists it is just fine to have it runing 24/7, on audio books it would be very annoying to not start over where you have stopped last time.

So why not just force pausing the mpd-stream when Tonie is taken away from Toniebox and (re)start playback again when Tonie is back on top of the box…?! No problem with home assistant and its automation feature.

Setup

Automation

When you have made the above setup…boom…you are good to go :smiley:
So this is my automation to toggle start playing the mpd stream when Tonie is put on specific Boxes:

alias: mpd to start playback the audio book playlist
description: ""
trigger:
  - platform: mqtt
    topic: teddyCloud/box/<boxid>/TagValid
    payload: <tag id>
  - platform: mqtt
    topic: teddyCloud/box/<another_boxid>/TagValid
    payload: <tag id>
condition: []
action:
  - service: media_player.media_play
    entity_id: media_player.audio_books
mode: single

And here is the pause event:

alias: mpd to pause audio book playlist
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.<some_box_entity_name>_tag_valid
    from: <tag id>
    to: ""
  - platform: state
    entity_id:
      - sensor.<another_box_entity_name>_tag_valid
    from: <tag id>
    to: ""
condition: []
action:
  - service: media_player.media_pause
    entity_id: media_player.audio_books
mode: single

Conclusion

As we use a lot of audio books…its great to never miss a part of the story and no need of skip or seek the story. Also on music based webradio it safes some traffic. Why streaming when nobody consumes the stream.

Also: just imageine what other thing would be possible…slap the box to play next title of playlist? Or just switch through list of webstream by tilt the box? No need for work arounds like mentioned here (although i like that thing).

Have fun :slight_smile:

1 Like

This is awesome! I’m hoping to expand on a similar idea, but instead link custom tonies to Home Assistant routines, so when a story begins, or a song plays, you can have a routine to turn the lights off or into a different scene mode.

Sure - imagine is the only limit. Since there is an integration for jellyfin as well…puting a Star Wars Tonie on the box could (re)start the movies…trigger an “ambient scene” for lights …or start “colorloop” effects when music party get started :smiley:

1 Like

Just as an addition, slap the box to play next track in playlist:

alias: mpd next track
description: ""
trigger:
  - platform: state
    entity_id:
      - event.<some_box_entity_name>_knock_forward
condition:
  - condition: state
    entity_id: sensor.<some_box_entity_name>_tag_valid
    state: <tag id>
action:
  - service: media_player.media_next_track
    entity_id: media_player.audio_books
mode: single

And backward of course, when slapped the left side:

alias: mpd prev track
description: ""
trigger:
  - platform: state
    entity_id:
      - event.<some_box_entity_name>_knock_backward
condition:
  - condition: state
    entity_id: sensor.<some_box_entity_name>_tag_valid
    state: <tag id>
action:
  - service: media_player.media_previous_track
    entity_id: media_player.audio_books
mode: single
1 Like

YES!!! That’s exactly the idea of what i’m looking to build up.