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
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
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
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.
First of all, thanks for the great idea.
However, I still have a few questions…
I think I have everything installed and running. I don’t quite understand how MPD works yet, but I suspect I’m overcomplicating it…
My question is quite simple, because I don’t understand what is meant by “”, “TagValid”, and “”.
-
List item If I understand correctly, “TagValid” can be found in MQTT in HA under the TonieBox. It’s a rather long string of characters, but it has nothing to do with the MAC of the box.
-
List item Is “” the MAC of the TonieBox, just without the “:”? Then “tag id” would be the MAC of the RFID chip, correct?
Yes, all information needed can be found in HA on the mqtt site for each toniebox.
The <boxid>
is ment to be the mac of your box. Since this is to be entered as a topic for a mqtt listener, as a nature how mqtt topic can be read, you might want to replace it with the mqtt wildcard #
.
The <tagid>
is ment to be the rfid chip identifier, w/o :
.
Maybe check out some mqtt basics to get more insight how mqtt actually works. With that, you can easily understand and adapt mqtt automations in HA. With that said, „TagValid“ is not a place holder for anything, but part of the topic under which TC is broadcasting the tag identifier of latest placed rfid chip on a specific toniebox.