If you have a Sonos Connect (or Amp, or Port) like me, and you connect it to your home theater receiver, you might’ve run into the issue that it’s not really plug and play. You can start music with the Sonos app, but it will not power most receivers automatically, especially when you connect it through an optical cable for example.
Sonos has a nice feature in their apps as well where you can set the volume of the Connect to passthrough, which means it will not actually set the output volume of the Connect, but we can still read that volume from the Sonos API.
That’s why I’ve made a blueprint that does the following:
Switches a media_player entity, like your receiver, to the right source when you start playing.
Turns off your receiver if it’s still set to the Sonos source after you stop playing music.
Pauses Sonos playback if you turn off your receiver or switch it to another source.
Synchronises the volume you adjust in Sonos with that same media_player.
Synchronises the volume setting of the media_player back to the Sonos, for example when you twist the volume knob.
Works great between my Sonos Connect (gen 2) and Denon AVR-X1600H. Not tested with anything else, please let me know how well it works for your setup!
There’s a configurable buffer delay for the volume synchronisation so they don’t keep adjusting each other. 1 second works for me, but you might want to put in a higher value if you notice weird behaviour with the volume. Or you can just turn it off if you don’t need it, or like the output adjustment of the Connect itself. (Which I don’t recommend, because it reduces audio quality.)
great work!
Tried the blueprint with sonos connect(v2) and Marantz Mcr603.
What worked:
switch on the receiver when playing music over sonos.
there is a one-time-sync between volume of sonos connect and marantz. Any further changes of volume on either device doesnt do anything.
any idea?
sonos connect is in volume pass-through mode
sonos devices are connected via sonos net
what im doing wrong?
==update==
got it working
Thanks for creating this. I am using a Sonos Port with Marantz receiver. I created a few automations myself, but yours seems cleaner. There are only two things that don’t seem to be working with yours that do with mine…
Powering on the AVR when I start playing Sonos in the zone that is plugged into the AVR.
Setting a max volume on the AVR. Your sync volume implementation is much better than mine, but it makes the assumption that I actually want to go to 100% on my AVR. My AVR gets loud for the room it’s in, and it would be great to add an option to cap the volume. I.E. 100% in Sonos is only 70% of my AVR, and then we just scale the volume.
I’m new to using Github… I’m new to Home assistant… I did get a YAML working, though. Should I try to push changes to yours? Thanks!
Thanks for the suggestions! I actually had a volume scaling functionality in there, but it turned out to be a bad idea as I ran into multiple issues:
It’s very hard to sync properly due to calculation differences with floating points.
How would you handle a volume set higher on either source outside of the scale?
What if the scale doesn’t translate 1 to 1? For the volume property of a media_player this is always the case as the implementation should cover it.
Trying to fix those things meant a lot of jumping around in volume, and there is a better way! I currently solve this by setting a volume limit in the SONOS app itself, which I think is a much cleaner solution anyway.
I don’t use multiple zones myself, so I’m not entirely sure how that would work properly, and won’t be able to test it. As for pushing your changes, it’s a gist on GitHub so it’s not really built for collaboration, but I could setup a repository if there’s enough interest!
Haha! Yes! I set the volume limit in the Sonos app. Wow I didn’t realize you could do this with a Sonos port. That’s amazing!
Fixed!
One remaining issue - it does not turn my Marantz receiver on / off. Any ideas how to troubleshoot that? Volume sync works great so I know it’s communicating properly w/ the device.
Odd this was working great with my Denon AVR-S960H, and it used to power on automatically, not it doesn’t do it at all. Any tips on how to debug this? Thank you!
Would it theoretically be possible to add media_player.turn_on when the Sonos is playing and the Receiver is turned off? I tried to do this, but I’m a total noob regarding blueprints and yaml scripts in general
I made some updates to the gist which should make it work again!
Sorry for the lack of updates, but I didn’t receive any notifications, and wasn’t aware people were still using this.
@Qonstrukt , THANK YOU for the update! It now turns on my AVR as expected. Follow up question re: volume control.
Why is 500ms the lowest I can select? It’s laggy. In my other room, I have it set up with the following YAML. Possible to implement something like that in yours? Great work!
Thank you for the automation. But I have the problem when the Sonos is playing and the receiver is switched on, the volume jumps to 0. If I disable the automation, I don’t have the problem.
@Qonstrukt I can’t for the life of me get this to work. I can control both my AVR and my Connect individually through home assistant, just no automatically with your automation. Are there any updates to this?
Hey there! This has stopped working for me. Is it working for others? I can still manually control my Denon AVRs and my Sonos devices from Home Assistant, but this blueprint doesn’t seem to work for me.Would love to hear from others!