Example Automation to play an Spotify Album on an Sonos Speaker

Example Automation to play an Spotify Album on an Sonos Speaker using an SLIX-L Tag
to work (in my case) with IKEA Symfonisk Speaker and SLIX-L Tag from “RFIDFriend”

This automation is part my Demo Video that was shown at the 37C3 Talk

This automation requiers an running “TeddyCloud” Server, at least one connected Toniebox, HomeAssistant, Spotify HA Integration, MQTT Connection between TeddyCloud and HA

alias: TeddyCloud Spotify Album
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.teddycloud_box_beere_tag_valid
condition: []
action:
  - if:
      - condition: state
        entity_id: sensor.teddycloud_box_example_tag_valid
        state: E00403501111111
    then:
      - service: media_player.play_media
        target:
          entity_id: media_player.wohnzimmer
        data:
          media_content_id: >-
            spotify://babef54eaf49983da4552d148a3310f4/spotify:album:6CxHMH6mIKm1JDJRbAYNvH
          media_content_type: spotify://album
        metadata:
          title: F.E.A.R. (Deluxe Edition)
          thumbnail: https://i.scdn.co/image/ab67616d0000b273ecfe53afbe054e8c7b38cb46
          media_class: album
          children_media_class: track
          navigateIds:
            - {}
            - media_content_type: spotify://library
              media_content_id: spotify://babef54eaf49983da4552d148a3310f4
            - media_content_type: spotify://current_user_followed_artists
              media_content_id: >-
                spotify://babef54eaf49983da4552d148a3310f4/current_user_followed_artists
            - media_content_type: spotify://artist
              media_content_id: >-
                spotify://babef54eaf49983da4552d148a3310f4/spotify:artist:4RddZ3iHvSpGV4dvATac9X
            - media_content_type: spotify://album
              media_content_id: >-
                spotify://babef54eaf49983da4552d148a3310f4/spotify:album:6CxHMH6mIKm1JDJRbAYNvH
    else:
      - service: media_player.media_stop
        data: {}
        target:
          entity_id: media_player.wohnzimmer
mode: single

This automation triggers once the Tag with the UID (provided by TeddyCloud via MQTT) “E00403501111111”, once the Tag is placed on the Box the Album starts to play on the IKEA Symfonisk and stops once the Tag is removed.

Currently trying to get this working. Almost there, but I’ve got an issue in my setup:

  • I’m using a Creative Tonie
  • Good: When I place the Tonie onto the Box I get the automation triggered and music starts playing
  • Good: When I remove the Tonie while the creative audio is still playing on the box the automation gets triggered and music stops playing
  • Bad: When I wait a while (Creative Tonie ends playing its audio) and I remove the Tonie from the box the automation does NOT get triggered.

I noticed that the Content Audio Id first changes from Unknown to the Id of the media I’ve recorded. When I remove the Tonie while this is playing it changes back to Unknown. But when I leave the Tonie on the box, as soon as my recorded audio is finished the Content Audio Id changes to something else. When I now remove the Tonie the Id stays as it is.

Values for Tag Valid are changing in a similar manner: When I remove the Tonie during my recorded audio plays the value changes back to Unknown. But when the recorded audio is finished the Tag Valid won’t change anymore.

My usecase would be to have a Creative Tonie announce what’s going to be played and then play the media on a Sonos until the Tonie is removed again.

Is this some known behavior from Creative Tonies?

We need to use the RTNL messages we get for that. After the content ended the box plays a system sound (which was recently changed to an empty sound)

We have RTNL messages for playing and pause and then placement of the tag, but not for the removal.

So you may check the RTNL messages if there is something we could improve there. If there is something, I encourage you to open an issue on GitHub.

You use the “Content Audio ID” as trigger, i noticed the value for my Boxes is “System sounds en-gb - Clingclong (finished audio)” once the Toniebox playback is finished.

As far as i can tell atm the “tag_valid” and the “playback” Sensor are keeping the value even the Box is off, so the only Value you could use to trigger the “stop spotify playback” would be the “Content Audio ID” Sensor

So you may check the RTNL messages if there is something we could improve there. If there is something, I encourage you to open an issue on GitHub.

I found some RTNL messages that could be what we’re searching for, but I have no idea how to continue from that. Opened an issue: https://github.com/toniebox-reverse-engineering/teddycloud/issues/131

so the only Value you could use to trigger the “stop spotify playback” would be the “Content Audio ID” Sensor

I’d like to stop playing when the Tonie is removed, not when the audio from the Creative Tonie is finished. My idea would be to have the Creative Tonie just say something short like announcing what is going to be played, i.e. “Now playing: Foobar and Friends”. Then the Toniebox is silent and Sonos plays the Spotify playlist. Sonos stops playing when the Tonie is removed (this could be hours later).

Thats why i use the “Tag Valid” Sensor to get the current UID. Specific UID Starts Spotify, No UID stops Spotify.

Remember, that the Box will shutdown when there is No Playback for a specific time. Then you have No way to Trigger the Stop Event when you remove the Tonie.

Remember, that the Box will shutdown when there is No Playback for a specific time.

You are right, my idea falls apart with the box falling asleep :confused:

A simple soulution could be to add an Long “muted” Audiofile after your announcement, this way the Box keeps playing.