pyatv icon indicating copy to clipboard operation
pyatv copied to clipboard

volume and set_volume doesn't work

Open iPhilBln opened this issue 2 years ago • 4 comments

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

pyatv.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

iPhilBln avatar Sep 10 '22 16:09 iPhilBln

This should be fixed in master, but it's not released yet. Would be great if you could verify that!

postlund avatar Sep 15 '22 17:09 postlund

Ok I will test it tomorrow. 👍

iPhilBln avatar Sep 15 '22 22:09 iPhilBln

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.

iPhilBln avatar Sep 16 '22 18:09 iPhilBln

@postlund Really no volume setting works on any of the branches:)

earlywaff avatar Oct 01 '22 19:10 earlywaff

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)?

JonLaliberte avatar Feb 01 '23 20:02 JonLaliberte

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

corrpel avatar Feb 27 '23 19:02 corrpel

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 avatar May 24 '23 21:05 michalmo

@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. 🍻

JonLaliberte avatar May 25 '23 15:05 JonLaliberte

Should be fixed by now!

postlund avatar Jul 11 '23 04:07 postlund