Bose Soundtouch - Source selection & presets

Bose Soundtouch - Source selection & presets

After integrating the Bose sound system - I found it a bit weird that the source switching wasn’t enabled by default. I kinda understand why now after digging through the APIs …- but it’s not an insurmountable issue that couldn’t be coded up in future. I also wanted to select my preset favourites (1-6) and that standard integration didn’t work for me out the box.

I figured there was a way to get it all working without digging in the standard integration, and I was right. I just couldn’t find an all in one guide. I hope that someone who’s a bit better (well - a developer) would be happy to take my learnings and update the standard integration. If someone who’s got a bit more time could write a custom-component out of my stuff?

Until then - here’s my all in one guide using standard components for changing source (TV, Spotify & Amazon Prime Music) and selecting presets 1->6. It does however require a bit of digging into how stuff’s set up in your environment.

Attributes you will need: tenacity, a brain, patience and troubleshooting.

Specific information you’ll need to substitute into the appropriate places in config:

  • IP address of your Bose Soundtouch device
  • spotify ID
  • email address you signed up for amazon with

URLs to get information to help you out after you’ve got your Bose Soundtouch’s IP address (substitute soundtouch-lounge for the ip address):

http://soundtouch-lounge:8090/info
http://soundtouch-lounge:8090/sources
http://soundtouch-lounge:8090/now_playing

If you want more than play button, preset buttons 1->6, spotify, amazon prime music and TV sources, have fun:
Bose API documentation: https://developer.bose.com/guides/bose-soundtouch-api/bose-soundtouch-api-reference (you’ll need a developer account - a few minutes to register)

Without further ado, here’s my set-up which I hope you can copy, paste and edit in a few minutes to get it all working (sans personal info?):

configuration.yaml


shell_command: # can place this into a !include shell_command.yaml
    #soundtouch - preset selectors (use release for selecting - press for setting preset to current playing)
    bose_preset_1_press: curl -X POST -H 'application/xml;charset=utf-8'  -d '<?xml version="1.0" ?><key state="press" sender="Gabbo">PRESET_1</key>' http://<soundtouch ip address>:8090/key
    bose_preset_1_release: curl -X POST -H 'application/xml;charset=utf-8'  -d '<?xml version="1.0" ?><key state="release" sender="Gabbo">PRESET_1</key>' http://<soundtouch ip address>:8090/key

    bose_preset_2_press: curl -X POST -H 'application/xml;charset=utf-8'  -d '<?xml version="1.0" ?><key state="press" sender="Gabbo">PRESET_2</key>' http://<soundtouch ip address>:8090/key
    bose_preset_2_release: curl -X POST -H 'application/xml;charset=utf-8'  -d '<?xml version="1.0" ?><key state="release" sender="Gabbo">PRESET_2</key>' http://<soundtouch ip address>:8090/key

    bose_preset_3_press: curl -X POST -H 'application/xml;charset=utf-8'  -d '<?xml version="1.0" ?><key state="press" sender="Gabbo">PRESET_3</key>' http://<soundtouch ip address>:8090/key
    bose_preset_3_release: curl -X POST -H 'application/xml;charset=utf-8'  -d '<?xml version="1.0" ?><key state="release" sender="Gabbo">PRESET_3</key>' http://<soundtouch ip address>:8090/key

    bose_preset_4_press: curl -X POST -H 'application/xml;charset=utf-8'  -d '<?xml version="1.0" ?><key state="press" sender="Gabbo">PRESET_4</key>' http://<soundtouch ip address>:8090/key
    bose_preset_4_release: curl -X POST -H 'application/xml;charset=utf-8'  -d '<?xml version="1.0" ?><key state="release" sender="Gabbo">PRESET_4</key>' http://<soundtouch ip address>:8090/key

    bose_preset_5_press: curl -X POST -H 'application/xml;charset=utf-8'  -d '<?xml version="1.0" ?><key state="press" sender="Gabbo">PRESET_5</key>' http://<soundtouch ip address>:8090/key # used for setting if called on its own ... long press
    bose_preset_5_release: curl -X POST -H 'application/xml;charset=utf-8'  -d '<?xml version="1.0" ?><key state="release" sender="Gabbo">PRESET_5</key>' http://<soundtouch ip address>:8090/key # used for press & release function

    bose_preset_6_press: curl -X POST -H 'application/xml;charset=utf-8'  -d '<?xml version="1.0" ?><key state="press" sender="Gabbo">PRESET_6</key>' http://<soundtouch ip address>:8090/key
    bose_preset_6_release: curl -X POST -H 'application/xml;charset=utf-8'  -d '<?xml version="1.0" ?><key state="release" sender="Gabbo">PRESET_6</key>' http://<soundtouch ip address>:8090/key

    bose_play_press: curl -X POST -H 'application/xml;charset=utf-8'  -d '<?xml version="1.0" ?><key state="press" sender="Gabbo">PLAY</key>' http://<soundtouch ip address>:8090/key
    bose_play_release: curl -X POST -H 'application/xml;charset=utf-8'  -d '<?xml version="1.0" ?><key state="release" sender="Gabbo">PLAY</key>' http://<soundtouch ip address>:8090/key
    #soundtouch - source selectors
    bose_amazon_music: curl -X POST -H 'application/xml;charset=utf-8' -d '<?xml version="1.0" ?><ContentItem source="AMAZON" type="tracklist" location="library/playlists/A1F83G8C2ARO7P_3AB01FSVTHAY/#playable" sourceAccount="<your.email@address>"></ContentItem>' http://<soundtouch ip address>:8090/select #why can't I resume without specifying a 'location' aka track/playlist?
    bose_tv_source: curl -X POST -H 'application/xml;charset=utf-8' -d '<?xml version="1.0" ?><ContentItem source="PRODUCT" sourceAccount="TV"></ContentItem>' http://<soundtouch ip address>:8090/select
    bose_spotify: curl -X POST -H 'application/xml;charset=utf-8' -d '<?xml version="1.0" ?><ContentItem source="SPOTIFY" type="uri" sourceAccount="<account ID>"></ContentItem>' http://<soundtouch ip address>:8090/select #documentation on bose api was missing 'type="URI"' for restarting web streaming services

scripts.yaml


  # soundtouch - preset selector
  bose_preset_1:
    alias: Soundtouch Preset 1
    description: "Switches to pre-set 1 station"
    sequence:
      #Release
      - service: shell_command.bose_preset_1_release
        alias: Release button 1
      - event: LOGBOOK_ENTRY
        event_data:
          name: Lounge - preset 1 switch
          message: Lounge sound to Radio BBC1
          entity_id: media_player.soundtouch_300_living_room
          domain: media_player

  # soundtouch - preset selector
  bose_preset_2:
    alias: Soundtouch Preset 2
    description: "Switches to pre-set 2 station"
    sequence:
      #Release
      - service: shell_command.bose_preset_2_release
        alias: Release button 2
      - event: LOGBOOK_ENTRY
        event_data:
          name: Lounge - preset 2 switch
          message: Lounge sound to Radio Preset 2
          entity_id: media_player.soundtouch_300_living_room
          domain: media_player
          
  # soundtouch - preset selector
  bose_preset_3:
    alias: Soundtouch Preset 3
    description: "Switches to pre-set 3 station"
    sequence:
      #Release
      - service: shell_command.bose_preset_3_release
        alias: Release button 3
      - event: LOGBOOK_ENTRY
        event_data:
          name: Lounge - preset 3 switch
          message: Lounge sound to Radio BBC3
          entity_id: media_player.soundtouch_300_living_room
          domain: media_player

  # soundtouch - preset selector
  bose_preset_4:
    alias: Soundtouch Preset 4
    description: "Switches to pre-set 4 station"
    sequence:
      #Release
      - service: shell_command.bose_preset_4_release
        alias: Release button 4
      - event: LOGBOOK_ENTRY
        event_data:
          name: Lounge - preset 4 switch
          message: Lounge sound to Radio BBC4
          entity_id: media_player.soundtouch_300_living_room
          domain: media_player

  # soundtouch - preset selector
  bose_preset_5:
    alias: Soundtouch Preset 5
    description: "Switches to pre-set 5 station"
    sequence:
      #Release
      - service: shell_command.bose_preset_5_release
        alias: Release button 5
      - event: LOGBOOK_ENTRY
        event_data:
          name: Lounge - preset 5 switch
          message: Lounge sound to Radio BBC5
          entity_id: media_player.soundtouch_300_living_room
          domain: media_player
  # soundtouch - preset set
  # use the press function without calling release on the specified preset number


  # soundtouch - preset selector
  bose_preset_6:
    alias: Soundtouch Preset 6
    description: "Switches to pre-set 6 station"
    sequence:
      #Press 
      - service: shell_command.bose_preset_6_press
        alias: Press button 6
      #Release
      - service: shell_command.bose_preset_6_release
        alias: Release button 6
      - event: LOGBOOK_ENTRY
        event_data:
          name: Lounge - preset 6 switch
          message: Lounge sound to Radio BBC6
          entity_id: media_player.soundtouch_300_living_room
          domain: media_player    
    #source switch

  # soundtouch - TV selector
  bose_souce_tv:
    alias: Soundtouch TV Source
    description: "Switches to pre-set 6 station"
    sequence:
      #Press 
      - service: shell_command.bose_tv_source
        alias: Press TV button
      - event: LOGBOOK_ENTRY
        event_data:
          name: Lounge - TV Switch
          message: Lounge sound to TV
          entity_id: media_player.soundtouch_300_living_room
          domain: media_player

  # soundtouch -  Spotify selector
  bose_souce_spotify:
    alias: Soundtouch resume spotify play
    description: "Switches to spotify source and plays"
    sequence:
      #Press 
      - service: shell_command.bose_spotify
        alias: Press Spotify button
      #Press play
      - service: shell_command.bose_play_release
        alias: Press button play
      #Release play
      - service: shell_command.bose_play_release
        alias: Release button play
      - event: LOGBOOK_ENTRY
        event_data:
          name: Lounge - Spotify Switch
          message: Lounge sound to Spotify
          entity_id: media_player.soundtouch_300_living_room
          domain: media_player
          
  # soundtouch - Amazon music selector
  bose_souce_amazon:
    alias: Soundtouch resume Amazon play
    description: "Switches to spotify source and plays"
    sequence:
      #Press 
      - service: shell_command.bose_amazon_music
        alias: Press Amazon button
      #Press play
      - service: shell_command.bose_play_release
        alias: Press button play
      #Release play
      - service: shell_command.bose_play_release
        alias: Release button play
      - event: LOGBOOK_ENTRY
        event_data:
          name: Lounge - Amazon Switch
          message: Lounge sound to Amazon
          entity_id: media_player.soundtouch_300_living_room
          domain: media_player

Lovelace UI yaml file


# a new tab for media - the full one contains my tv too, hence the icon. :)
## media 
  - title: Media
    icon: mdi:video-vintage
    path: media
    cards:
    ## bose soundtouch
      - cards:
        #source selection
          - entities:
                #type: glance
            #tv source
              - type: entity-button
                entity: script.bose_souce_tv
                icon: mdi:television
                icon_height: 50px
                name: TV Source
                show_name: true
                tap_action: 
                  action: call-service
                  service: script.bose_souce_tv 
               #spotify source
              - type: entity-button
                entity: script.bose_souce_spotify
                icon: mdi:spotify
                icon_height: 50px
                name: Spotify
                show_name: true
                tap_action: 
                  action: call-service
                  service: script.bose_souce_spotify
               #amazon
              - type: entity-button
                entity: script.bose_souce_amazon
                icon: mdi:amazon
                icon_height: 50px
                name: Amazon Prime Music
                show_name: true
                tap_action: 
                  action: call-service
                  service: script.bose_souce_amazon         
            show_state: false
            type: glance  
        #preset selection row a
          - entities:
                #type: glance
              #Preset 1
              - type: entity-button
                entity: script.bose_preset_1
                icon: mdi:numeric-1-box-outline
                icon_height: 50px
                name: Preset 1
                show_name: true
                tap_action: 
                  action: call-service
                  service: script.bose_preset_1 
              #Preset 2
              - type: entity-button
                entity: script.bose_preset_2
                icon: mdi:numeric-2-box-outline
                icon_height: 50px
                name: Preset 2
                show_name: true
                tap_action: 
                  action: call-service
                  service: script.bose_preset_2
              #Preset 3
              - type: entity-button
                entity: script.bose_preset_3
                icon: mdi:numeric-3-box-outline
                icon_height: 50px
                name: Preset 3
                show_name: true
                tap_action: 
                  action: call-service
                  service: script.bose_preset_3
            show_state: false
            type: glance 
        #preset selection row b
          - entities:
                #type: glance
              #Preset 4
              - type: entity-button
                entity: script.bose_preset_4
                icon: mdi:numeric-4-box-outline
                icon_height: 50px
                name: Preset 4
                show_name: true
                tap_action: 
                  action: call-service
                  service: script.bose_preset_4 
              #Preset 5
              - type: entity-button
                entity: script.bose_preset_5
                icon: mdi:numeric-5-box-outline
                icon_height: 50px
                name: Preset 5
                show_name: true
                tap_action: 
                  action: call-service
                  service: script.bose_preset_5
              #Preset 6
              - type: entity-button
                entity: script.bose_preset_6
                icon: mdi:numeric-6-box-outline
                icon_height: 50px
                name: Preset 6
                show_name: true
                tap_action: 
                  action: call-service
                  service: script.bose_preset_6
            show_state: false
            type: glance 
          #custom card experiment
            #- type: custom:button-card
            #  icon: mdi:spotify
            #  action: service
            #  service:
            #    domain: rest_command
            #    action: lounge_soundbar_spotify
            #- type: custom:button-card
            #  icon: mdi:television
            #  action: service
            #  service:
            #    domain: rest_command
            #    action: lounge_soundbar_tv
            #    data: 
            #standard bose media player contorl
          - entity: media_player.soundtouch_300_living_room
            name: Living room soundbar
            type: media-control
        title: Bose
        type: vertical-stack

Here’s a picture for proof of life:

Looking forward to seeing where this goes. :slight_smile:

5 Likes

check out the mini-media-player custom card, over which it’s really easy to at least select presets

type: 'custom:mini-media-player'
entity: media_player.soundtouch
shortcuts:
  buttons:
    - data:
        entity_id: media_player.soundtouch
        media_content_id: 1
        media_content_type: PLAYLIST
      id: media_player.play_media
      name: 1
      type: service
    - data:
        entity_id: media_player.soundtouch
        media_content_id: 2
        media_content_type: PLAYLIST
      id: media_player.play_media
      name: 2
      type: service
    - data:
        entity_id: media_player.soundtouch
        media_content_id: 3
        media_content_type: PLAYLIST
      id: media_player.play_media
      name: 3
      type: service
    - data:
        entity_id: media_player.soundtouch
        media_content_id: 4
        media_content_type: PLAYLIST
      id: media_player.play_media
      name: 4
      type: service
    - data:
        entity_id: media_player.soundtouch
        media_content_id: 5
        media_content_type: PLAYLIST
      id: media_player.play_media
      name: 5
      type: service
    - data:
        entity_id: media_player.soundtouch
        media_content_id: 6
        media_content_type: PLAYLIST
      id: media_player.play_media
      name: 6
      type: service
  columns: 6
source: icon
2 Likes

@Bergals thank you very much for posting this. The ability to (automatically) select source has been a frustration for me since I got these speakers. If I was listening to music and didnt return the source (with the remote) to tv afterwards, my wife would come try watch tv and offcourse no sound, etc… thank you.

1 Like

You are welcome @juan11perez Glad it helped someone other than just me. :wink:

Ah cool, I had that installed - but didn’t get the presets working on it. Your stuff helped me get it working.

One of the other challenges - custom cards don’t always render or render well on Mobile. I’m mucking about with Ariela and the HA Client app on android. While I prefer the look and combustibility of this custom card - its lack of render-ability isn’t working out as well for me as I’d like.

Thank you for your work!!! , everything works perfectly for me
the address: http://soundtouch-ip:8090/sources and http://soundtouch-ip:8090/sources are very important to configure the sources, I had to change “TV” to “AUX” and I had to delete all < > that surrounded the Ip address and my email address amazon music.

I could also add a bluetooth source and a playlist from my soundtouch music library

I think it will now be possible to ask google assistant to launch playlists thanks to scripts created

3 Likes

Great to hear @Divalz

… voice assistants should be one of my next projects for it. :smiley:

Any update on getting google assistant to work with SoundTouch?

And is this still the best way to control the SoundTouch speakers from HA?

how can i run in with python ?

If you integrate google (or siri or alexa), it should work - but asking the Assistant to run a script just requires the right phrasing. It worked for me with light scripts I’d set up (‘Hey google, run I’ve arrived home’) if memory serves worked. It was a bit hit and miss if the voice assistant chose to use it.

Sorry, not a python expert person… but I assume you can search for “python rest” and then use the same calls I used in these scripts.

Thanks, really like this integration and support! Had some struggles with getting Spotify working. Seems to be a little mistake in the scripts.yaml (?) , both Press and Release services refers to shell_command.bose_play_release. This will not make Spotify start. Therefore, you’ve you change ‘shell_command.bose_play_release’ to ‘shell_command.bose_play_press’ in Press Play, scripts.yaml. Got it working now. Thanks again for your work.

The SoundTouch integration already has support for activating any one of the 6 presets via a service call. You do not need to do cURL.

@pdg82 This was posted prior to the soundtouch integration being a built in addition to HomeAssistant. I believe they used what I had above as the basis for the integration - so in theory! We don’t have to worry about what I went through above. :smiley:

… and I should play with it and update the way I’ve integrated my soundtouch!

1 Like

I just developed a new SoundTouchPlus custom component if you’re interested. It can easily be installed via HACS as well. More information can be found in this forum post.

1 Like