Device and power state are not aligned
See original GitHub issueDescribe the bug
Device and power states are managed independently by pyatv. Unfortunately, the power state is a bit unreliable and it sometimes happens that it reports Off
even though something is playing. One such case is when using the Apple TV as an AirPlay receiver, only to receive and play audio but not use any screen as output. The power state more or less mirrors if there is a monitor on or not (which is not totally true either because turn_on
with Companion will cause the power state to be reported on On
even if no screen is on). So it’s a pickle…
My suggestion is to at least change power state to on when something is playing as that makes more sense. It will potentially trigger lots of changes between on and off whenever media plays or not, so that’s the flipside of this.
Error log
No response
How to reproduce the bug?
Stream audio to an Apple TV without having the TV turned on: pyatv shall report Off
as power_state
but still provide a playing state.
What is expected behavior?
Power state should be reported as On
.
Operating System
Any
Python
Other
pyatv
any
Device
Apple TV 4 and later
Additional context
Reported here: https://github.com/postlund/pyatv/issues/1333#issuecomment-961279579
Issue Analytics
- State:
- Created 2 years ago
- Comments:25 (15 by maintainers)
I know, that’s the problem. Trying to bend the universe here… As the feature is in there now, I would prefer to just keep it there and try to improve the situation as much as I can and people will have to live with a few oddities. Maybe it can be further improved over time as well. I’ll use that as my goal, but might have to change direction later on.
I think I know the issue, just need to come up with a test for it. The
device_state
solely depends on what the media player framework in the Apple TV says is currently playing. There are situations where the Music app remains active and paused, like a “default state”. So even you aren’t actively choosing what to play, something else might keep it looking like it is playing.I would have preferred an optional flag for power management (or to not implement it at all actually), but I got run over on that because people are too keen on that feature unfortunately. It makes the code in the integration a bit…ugly… So I’ll have to think about this a bit.
But things should work rather OK as long as power state is updated correctly according to play state. So I think some additional work is needed to fix that. I didn’t think too much about it before, but this situation should never happen:
As long as
device_state
is not idle, the power state must be totally ignored and it doesn’t seem to be. So I guess I need to go bug hunting here.And yes, CEC is a total buggy sack of… yeah. It is a standard that has not been very well treated, mainly by manufacturers I guess.