pyatv
pyatv copied to clipboard
volume and set_volume doesn't work
Describe the bug
The commands volume and set_volume doesn't work for me. If I use the companion or airplay protocol no errors show up but nothing happen.
-
atvremote --id DC56E74FE734 --companion-credentials c66a968278b2d609.... set_volume=10.0 doesn't change the volume
-
atvremote --id DC56E74FE734 --companion-credentials c66a968278b2d609.... volume always return 0.0
-
atvremote --id DC56E74FE734 --companion-credentials c66a968278b2d609.... volume_up works
-
atvremote --id DC56E74FE734 --companion-credentials c66a968278b2d609.... volume_down works
Error log
How to reproduce the bug?
atvremote --id DC56E74FE734 --companion-credentials c66a968278b2d609c3f17.... set_volume=10.0 --debug > pyatv.log atvremote --id DC56E74FE734 --companion-credentials c66a968278b2d609c3f17.... volume --debug >> pyatv.log
What is expected behavior?
setup the volume and get the current volume
Operating System
Linux Debian Bullseye
Python
3.9
pyatv
0.10.3
Device
Apple TV 4, tvOS 15.6, Apple TV 4K, tvOS 15.6
Additional context
nothing to say
This should be fixed in master
, but it's not released yet. Would be great if you could verify that!
Ok I will test it tomorrow. 👍
This should be fixed in
master
, but it's not released yet. Would be great if you could verify that!
I am a little bit confused, which branch i should test? I am running the latest master branch v. 0.10.3 and there it doesn't work.
@postlund Really no volume setting works on any of the branches:)
Hm. So it looks like @postlund pushed a change to try to fix this, but that was back in August and it was released as 0.10.3 (before this issue was created). I wonder if that change ended up breaking things in some circumstances, or if maybe it didn't fix the original problem in all circumstances?
There is a bug report over in the Home Assistant repo where someone when through and gave some examples of when/where it worked/didn't which may be worth reviewing. He did some code following and noted:
After working through the code some more, I wondering if VOLUME_DID_CHANGE messages are no longer being sent (or received)?
Let's hope it will be a fix soon. I've just installed pyatv to be able to sync sonos - homepods volume. I've tried to get volume and it is always returning 0.0
I was asked about how #2006 relates to this issue, so I'll document my thoughts here.
The original issue appears to be about getting and setting volume on an Apple TV, this is a known problem with the Apple TV in certain speaker setups. In my case with an Apple TV connected through HDMI to a TV with a sound bar connected over ARC, and CEC volume in settings, the Apple TV reports 0.0 volume and doesn't react to set_volume. In this case the Lock screen widget in iOS also shows a UI with only step up and step down controls (as seen in this image from reddit).
There may be setups in which the Apple TV reports volume (HomePod stereo pair?), though I haven't witnessed it myself. I believe the device reports this as volumeCapabilities = Absolute or Relative (https://github.com/postlund/pyatv/blob/master/pyatv/protocols/mrp/protobuf/VolumeControlAvailabilityMessage.proto#L14-L15) though I haven't really tested it.
If you get 0.0 volume on a fresh connection (eg. using atvremote with the volume command) you're probably in this situation, and that's just how the Apple TV works.
The issue discussed https://github.com/home-assistant/core/issues/76117 is different. It's about a timeout error when sending commands. Some cases of that issue were resolved by #1815 and some other cases can be resolved by #2006 . But these affect only set_volume.
Timeout errors from volume_up and volume_down, are different and they happen because those commands don't seem to work at all right now. The key commands sent don't seem to do anything, but it works from iOS, so pyatv is doing something differently. I don't know more about this, since I just noticed this issue.
@corrpel's issue where Homepod volume is always 0.0, can occur if you set the HomePod to play through another Airplay speaker, but not itself. Otherwise HomePod volume reporting works quite well (for me), especially so in pyatv 0.12.0.
@michalmo Thanks for the details! The biggest issue I run into right now is the https://github.com/home-assistant/core/issues/76117 bug cause by set_volume not working. It's an integral part of notification automations (TTS/sounds) to ensure that the alert is audible. Appreciate your work on this in general. 🍻
Should be fixed by now!