home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.26k stars 29.85k forks source link

Media Player source: is "radio station name" when playing back TuneIn #125310

Open klingbing opened 1 week ago

klingbing commented 1 week ago

The problem

Previously (before the Bluesound integration was moved to UI) the attribute source: was "TuneIn" when a TuneIn radio station was played which corresponds to <service>TuneIn</service> in the Bluesound API.

The source: has now changed to being "Radio Station name" instead of "TuneIn".

Would it be possible to either fix/revert this change or maybe expose an attribute service: or input to the Bluesound media player entity?

The use case behind my request is the following:

I am using physical pushbuttons to control my Bluesound media players, one of these buttons is a "NEXT" button. In the automation triggering the "NEXT" button results in two different actions depending on currently playing source or service (TuneIn or Spotify):

  1. If source is TuneIn then call rest command http://192.168.1.16:11000/Preset?id=+1
  2. If source is Spotify then call
    metadata: {}
    data: {}
    target:
    entity_id: media_player.esszimmer
    action: media_player.media_next_track

What version of Home Assistant Core has the issue?

core-2024.9

What was the last working version of Home Assistant Core?

core-2024.7.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Bluesound

Link to integration documentation on our website

https://www.home-assistant.io/integrations/bluesound/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 week ago

Hey there @thrawnarn, @louischrist, mind taking a look at this issue as it has been labeled with an integration (bluesound) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `bluesound` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign bluesound` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


bluesound documentation bluesound source (message by IssueLinks)

LouisChrist commented 1 week ago

Yes i introduced a breaking change in 2024.8 regarding the sources. My intention was to fix the source selection. TuneIn was a selectable source, but selecting it did not work. Therefore i removed everything that is not selectable on its own and added presets to the list of selectable sources. With presets it is now possible to create one that plays a TuneIn radio station and select it from the sources.

Now to your problem. To be consistent i also changed the currently selected source. It now shows one of the elements of the selectable list if possible(a preset in your case) and if nothing from the list matches the service TuneIn. You should be able to test this by selecting a radio station manually(maybe one that is not part of any preset).

I think there are multiple solutions:

  1. If you do not change the preset names often: You can change your condition to check if the source is one of your preset names(state condition with multiple values).
  2. If the presets change often: You could prefix them. For example with Preset:. And then change your condition to check for that prefix(with a template condition).
  3. You can get rid of the rest command and use the media_player.select_source action. You would have to do a big choose where you define the order of your preset manually.
  4. I could add a new entity(or attribute) to the integration which indicates the currently selected service.
klingbing commented 6 days ago

Thank you for your detailed response.

Yes i introduced a breaking change in 2024.8 regarding the sources.

Apols, I must have overread that one.

It now shows one of the elements of the selectable list if possible(a preset in your case) and if nothing from the list matches the service TuneIn. You should be able to test this by selecting a radio station manually(maybe one that is not part of any preset).

I can confirm, if I play back a TuneIn radio station that is not in my presets the media playerssource attribute switches to TuneIn

I think there are multiple solutions:

  1. If you do not change the preset names often: You can change your condition to check if the source is one of your preset names(state condition with multiple values).
  2. If the presets change often: You could prefix them. For example with Preset:. And then change your condition to check for that prefix(with a template condition).
  3. You can get rid of the rest command and use the media_player.select_source action. You would have to do a big choose where you define the order of your preset manually.
  4. I could add a new entity(or attribute) to the integration which indicates the currently selected service.

Thank you for providing me with those! Further to 1. and 2.: I could also check for „Source is not Spotify“ which works as long as I only use Spotify or TuneIn presets.

Further to 3.: the benefit of using the rest command http://ip:11000/Preset?id=+1 is that the media player will cycle the presets, e.g. if I hit the rest command when playing the last preset it will skip to preset 1 (or whatever is your first preset).

Further to 4.: Preferred (attribute is fine)! ;)

Or as an alternative, if feasible, solution 5., you could consider implementing the functionality of being able to skip presets using media_player.media_next_track (http://ip:11000/Preset?id=+1) and media_player.media_previous_track (http://ip:11000/Preset?id=-1 ) when one of the presets is currently playing. A functionality I have always been missing in BluOs and am now able to solve here in HA. Another benefit: The next/previous track buttons in the mediaplayer actually have a (imho expected) functionality instead of doing nothing when clicked while playing a preset. Let me know what you think and if I should set up a feature request for this.

Again thanks for your help.