punxaphil / custom-sonos-card

Home Assistant custom lovelace sonos card
180 stars 19 forks source link

Request: Add predefined volume per speaker in the Sonoscard #127

Closed MNLFDF closed 1 year ago

MNLFDF commented 1 year ago

I know it’s possible to group predefined speakers in the living room and put them under a button.

But what I miss is the ability to set a predefined volume per speaker as well. For example my homecinema speakers get the volume 3, the kitchen volume 9, erker volume 5, tafel volume 4. I never can set the starting volume anywhere. Now I use the “Soro” app for apple shortcuts to do this, but would be great if the Sonos card could do this as well. Then I can skip on app again.

Can this being add at the V6 version which you are developing now?

punxaphil commented 1 year ago

Great suggestion! Will look into this

punxaphil commented 1 year ago

@MNLFDF I have created a beta with a suggestion on how to solve this. Instead of presetting a volume level, you can now work with ratios. That will be more versatile and match whatever you set as volume on the base player.

Example config:

type: custom:sonos-card
volumeRatios:
  - basePlayer: media_player.biljardrum
    adjustedPlayer: media_player.master_suite
    ratio: 0.5

This example would mean that "Master Suite" player always will have 50% volume of "Biljardrum" player.

Let me know how it works for you!

https://github.com/johanfrick/custom-sonos-card/releases/tag/v6.6-beta1

MNLFDF commented 1 year ago

@johanfrick Sounds like a plan, but doesn’t solve my startup volume. My Homecinema configuration is part of the living room/kitchen group when I start listening to the radio. But… when I watched TV, the Homecinema config has a volume of 13-14. Way too loud for the radio. When I listen to radio stations, that volume need to be starting at 3. Now I use a separate app to set the group and the start volume.

This are my speakers within the group and their start volume (which basically stays at this volume whole day).

Homecinema (Beam + 2 Sonos One) 3 TV (separate Sonos One Stereo set) 3 Erker (Play:1) 5 Tafel (One) 3 Keuken (Symfonisk bookshelf) 11

How would you set this starting volume with “Ratio’s” like you have in Beta 6.6? When I want this config a bit louder at this moment, all numbers will go +1.

punxaphil commented 1 year ago

You make a good point. I'll give it another think

punxaphil commented 1 year ago

Please try this new beta: https://github.com/johanfrick/custom-sonos-card/releases/tag/v6.6-beta2 Example conf:

type: custom:sonos-card
predefinedGroups:
  - name: Upstairs
    entities:
      - media_player.biljardrum
      - media_player.badrum_nere
      - media_player.kontor
      - media_player.vardagsrum
  - name: Indoors
    entities:
      - id: media_player.biljardrum
        volume: 10
      - id: media_player.hall
        volume: 5
MNLFDF commented 1 year ago

Did a quick test and all volumes are set right. You nailed it 😆 Will test more tomorrow. Thanks for this. Now I can get rid of all other extra apps.

I don’t know if this is possible already, but can you also set a predefined radio station when selecting a group? So, volumes and a predefined radio station, or other music from the favorites list?

punxaphil commented 1 year ago

https://github.com/johanfrick/custom-sonos-card/releases/tag/v6.6-beta3

predefinedGroups:
  - name: Kök&Hall
    media: Legendary
    entities:
      - id: media_player.kok
        volume: 10
      - id: media_player.hall
        volume: 5

Note: this only works if the media is in your sonos favorites list.

MNLFDF commented 1 year ago

This works also thanks 🙏 This is really a game changer for me.

punxaphil commented 1 year ago

https://github.com/johanfrick/custom-sonos-card/releases/tag/v6.6-beta5 It is now possible to change volume and media settings with the graphical editor.

Would appreciate if you tested this one as well, even if you only use yaml config.

MNLFDF commented 1 year ago

I installed beta5 and all my presets (groups+volume settings) were gone (yaml settings). To be clear: not visible at the place where I can press the buttons to group speakers. The yaml code itself was still there.

Don’t know if this a intentional behavior?

Back to beta 3 and the yaml code is read again and the predefined groups are back. I did see the GUI option tho, but don’t have the time now to play with this. I kept beta3 for this moment, because it works good.

punxaphil commented 1 year ago

Understandable. If you find time though it would be great. I hope you appreciate the time I spent to build this 😄

MNLFDF commented 1 year ago

Archive.zip Hi, yes like I already said, this new addition is a game changer!

I looked at Beta 5 this morning. It doesn’t go like expected. Like I said, it doesn’t show the already available groups at the group settings (normal mode). When I go to “Edit” mode, Entities, I see the predefined groups, but when I click on one, all settings are empty. Then I start editing one, I don’t see the name I give it previously (so I type it again), then I want to add speakers to the group. This doesn’t select any speaker. I simply don’t get them selected. And when I look at the Yaml afterwards is see empty fields.


  - name: Alleen Woonkamer
    entities:
      - id: media_player.tv
        volume: 3
      - id: media_player.homecinema
        volume: 3
      - id: media_player.erker
        volume: 4
      - id: media_player.tafel
        volume: 3
  - name: ''
    media: ''
    entities:
      - player: media_player.keuken

I changed the “kitchen” (Keuken) and “Alleen Woonkamer” isn’t show on the group list (Normal mode) but is available at the “Entities” tab in edit mode, but after saving the changed “Kitchen”, it is still not visible in normal mode. (Can you still follow this) 😉

p.s. Even at Beta 3 GUI Editing, something goes wrong. When I want to edit a predefined group with the GUI, it shows [object:Object] as entity for the selected speaker. When I add one extra entity, only that new added speaker is showed at the Yaml.

p.s.2 I added some screenshots for beta3 and beta5 ( sorry I wrote beta6 on the screenshots).

punxaphil commented 1 year ago

Thanks! I believe I have fixed all the mentioned bugs in the UI editor now. Would appreciate if you can check it as well? 🙏 v6.6-beta6

MNLFDF commented 1 year ago

Unfortunately still having the problem all predefined groups went gone with beta 6. The information is still in the Yaml tho.

IMG_2397 IMG_2398

punxaphil commented 1 year ago

Can you try create them again? From ui? I've done some renaming of config variables.

MNLFDF commented 1 year ago

I saw you used another way to add the players to the group? Instead of “ID” now you use “Player”? Is it because of that it won’t “see” the previous defined groups?

When I change “ID” to “Player” in the Yaml, they are recognized by Beta 6. After that change, I can change the config of those too with the GUI.

IMG_2399

punxaphil commented 1 year ago

Yes

punxaphil commented 1 year ago

So all good then? 😄

MNLFDF commented 1 year ago

Everything is working now.

punxaphil commented 1 year ago

Released: https://github.com/johanfrick/custom-sonos-card/releases/tag/v6.6