Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Automatically naming Bose Soundtouch presets in Shortcuts #284

Closed
schneekluth opened this issue Apr 14, 2020 · 20 comments
Closed
Labels
enhancement New feature or request

Comments

@schneekluth
Copy link

Hello @kalkih,

first of all thank you for implementing multi room features for the Bose Soundtouch integration. Great feature.

I use 4 Soundtouch devices with the shortcuts settings to quickly start playing predefined playlists:

image

These shortcuts are also exposed by the speakers API when you call http://IP_OF_SPEAKER/presets and they have the name and even an URL to the cover art in it:

bose_api

Would it be possible for mini-media-player to read and display the names of the presets automatically? Maybe even use the cover art in a shortcut button?

I am asking because I don't use lovelace.yaml mode in hass and have to edit these presets 4 times in the GUI. It would be a handy feature if the presets change automatically.

@kalkih kalkih added the enhancement New feature or request label Apr 14, 2020
@kalkih
Copy link
Owner

kalkih commented Apr 14, 2020

Hey,
Glad you like the group management feature!

Unfortunately not going to implement this one, it would be a platform specific feature, and I try to stay away from adding those.

Would indeed be a cool feature though, feel free to fork this card and extend it as you like with e.g. platform specific features like this, I'm sure more people would be interested in this as well, could become "mini-bose-player" 😉

@kalkih kalkih closed this as completed Apr 14, 2020
@jpearce73
Copy link

What about a method that can be called to update a button's text?
Then people can write their own automation to push the information across

@kalkih
Copy link
Owner

kalkih commented Apr 14, 2020

Please elaborate, how would that work?
I don't really get what you mean by calling a method, this card is just a frontend and has no "persistent state", it doesn't function like components/integrations which usually expose service calls and store data.

You should be able to achieve something similar with the help of config-template-card) though.

@jpearce73
Copy link

I am thinking that a button could be given a content string and expanded like a template or the markdown card
https://www.home-assistant.io/lovelace/markdown/

Then you could pull the state or an attribute off an entity you create or have a media platform (such as soundtouch) export the text for the 6 buttons as a property to include in the markdown.

@schneekluth
Copy link
Author

I like the idea of @jpearce73. What about you @da-anda? I am sure you have enough of homeassistant pull requests but maybe you have an idea. Unfortunately I cannot code at all but if there is anything else when it comes to testing stuff I am glad to help out. Maybe one could integrate the currently stored presets in the attributes of each player?

@kalkih
Copy link
Owner

kalkih commented Apr 14, 2020

I am thinking that a button could be given a content string and expanded like a template or the markdown card

You can already do that with the help of config template card. I don't really want to add templating to the card as there are solutions that solves that problem just fine already.

@jpearce73
Copy link

I agree with Kalkih.
Duplicating functionality that exists elsewhere is a bad idea (unless its prohibitively difficult to use).
We should look into the template card and try to use that to solve the problem, maybe contribute an example back to Kalkih can add it to the documentation page.

Maybe start by sharing your lovelace yaml for the sound touch here and I can try and help you.

@schneekluth
Copy link
Author

Here is the yaml file for the media player shown in the screenshot in first post:

type: 'custom:mini-media-player'
artwork: full-cover-fit
entity: media_player.soundtouch_room2
group: true
hide:
  shuffle: true
  source: false
  volume: false
icon: 'mdi:speaker-wireless'
name: Bose Room2
power_color: true
shortcuts:
  column_height: 30
  align_text: left
  buttons:
    - icon: 'mdi:numeric-1-box'
      id: 1
      name: Deepmix Moscow
      type: playlist
    - icon: 'mdi:numeric-2-box'
      id: 2
      name: I can haz We3kend?
      type: playlist
    - icon: 'mdi:numeric-3-box'
      id: 3
      name: Anrüchige Frauen
      type: playlist
    - icon: 'mdi:numeric-4-box'
      id: 4
      name: Tagesschau 100s
      type: playlist
    - icon: 'mdi:numeric-5-box'
      id: 5
      name: Mix der Woche
      type: playlist
    - icon: 'mdi:numeric-6-box'
      id: 6
      name: Autobahn bei Nacht
      type: playlist

@jpearce73
Copy link

jpearce73 commented Apr 17, 2020

OK this is a proof of concept

Using the config-template-card we can put attributes from media_player.soundtouch (or any other platform) into our button names. And they update as the attribute changes.

image

=> So to get the final solution you are seeking I will need to enhance the soundtouch library and add exported attributes for the button presets and then those could be used in the template.

Give me a bit of time for that... but I like the idea of it too.
Here is the full YAML for my proof of concept.

type: 'custom:config-template-card'
name: Templated SoundTouch
entities:
  - media_player.soundtouch_kitchen
card:
  type: 'custom:mini-media-player'
  entity: media_player.soundtouch_kitchen
  shortcuts:
    buttons:
      - icon: 'mdi:numeric-1-box'
        id: 1
        name: "${states['media_player.soundtouch_kitchen'].attributes.media_track}"
      - icon: 'mdi:numeric-2-box'
        id: 2
        name: "${states['media_player.soundtouch_kitchen'].attributes.media_album_name}"

@jpearce73
Copy link

Please try this solution.
Install this upgraded soundtouch integration into your /config/custom_components folder. This will export the preset button information.

soundtouch.zip

Install by using the add-on terminal

  1. copy soundtouch.zip to your /config folder
  2. mkdir custom_components
  3. cd custom_components
  4. tar xzvf ../soundtouch.zip

Then use lovelace code like this to put a mini-media-card inside a config-template-card. Note the expansion of the newly exported soundtouch_presets attribute.

card:
  entity: media_player.soundtouch_kitchen
  shortcuts:
    align_text: left
    buttons:
      - icon: 'mdi:numeric-1-box'
        id: 1
        name: >-
          ${states['media_player.soundtouch_kitchen'].attributes.soundtouch_presets[0]}
        type: playlist
      - icon: 'mdi:numeric-2-box'
        id: 2
        name: >-
          ${states['media_player.soundtouch_kitchen'].attributes.soundtouch_presets[1]}
        type: playlist
      - icon: 'mdi:numeric-3-box'
        id: 3
        name: >-
          ${states['media_player.soundtouch_kitchen'].attributes.soundtouch_presets[2]}
        type: playlist
      - icon: 'mdi:numeric-4-box'
        id: 4
        name: >-
          ${states['media_player.soundtouch_kitchen'].attributes.soundtouch_presets[3]}
        type: playlist
      - icon: 'mdi:numeric-5-box'
        id: 5
        name: >-
          ${states['media_player.soundtouch_kitchen'].attributes.soundtouch_presets[4]}
        type: playlist
      - icon: 'mdi:numeric-6-box'
        id: 6
        name: >-
          ${states['media_player.soundtouch_kitchen'].attributes.soundtouch_presets[5]}
        type: playlist
  type: 'custom:mini-media-player'
entities:
  - media_player.soundtouch_kitchen
name: Templated SoundTouch
type: 'custom:config-template-card'

@schneekluth
Copy link
Author

schneekluth commented Apr 21, 2020

Hey @jpearce73, sorry for the late reply. I've tested your solution. It basically works! Only one issue with the encoding like in Preset 3 where German Umlaut "Ü" is not displayed correctly:

image

I have also noted that when the title gets too long the icon somehow shrinks a bit (Preset 1 and 4) but this seems to be default behavior of the mini-media-player. @kalkih: Are you aware of the shrinking icons when title gets too long?

@jpearce73
Copy link

I'll have to differ to @kalkih for the visual stuff - probably German language knowledge too!
Looking back to your XML for item #3, I am exporting the ItemName

image

There is that German U, but it's not coming with any encoding information in the XML.

What does it look like on the Speaker Displays and inside the Bose Phone App?

@schneekluth
Copy link
Author

Speaker itself has no display. In the Bose Soundtouch App the letter is shown correctly:

Screenshot_20200422-121320

@jpearce73
Copy link

So the interesting thing is that the manually created button seems to have the U shown correctly.

Please make sure that's still the case with the templated card by making a minimal change and hardcoding button #3 with the text. We want to know if it's going wrong in the loading of the attribute from the XML, or in the display of the card within the templated card. So make a 1 line change to your templated card and hardcode button #3 that text with the U.

Please also check in the UI under Developer Tools => States tab. Find your soundtouch entity and look at the text displayed for the soundtouch_presets attribute. How's the U?

@schneekluth
Copy link
Author

Issue does not appear when name is hardcoded. The card shows the character correctly:
umlaut2
The error is already present in the states tab:
umlaut

@jpearce73
Copy link

Perfect thanks.
And I can see you've got the content off Spotify so I can try it here.
I generally get time over the weekends for this kind of play, so give me a few days...

@schneekluth
Copy link
Author

Great, thanks! I really like the way the Soundtouch integration is improving lately.

@kalkih
Copy link
Owner

kalkih commented Apr 22, 2020

Great progress!

I'll fix the icon resize issue.

@jpearce73
Copy link

OK, I have managed to fix it.
But the solution is a 1 line fix inside the libsoundtouch module to set the content to UTF-8 before parsing the XML. I am not sure how we get that upgraded because its not in the HA core and the module owner does not seem active.

CharlesBlonde/libsoundtouch#38

@kalkih - Do you know someone who can help us?

@jpearce73
Copy link

I see that libsoundtouch 0.8.0 already has this fix, so I think the things we want to do is push for HA to upgrade libsoundtouch library and possibly bring that library into local management given the original owner does not seem to be active.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants