pyatv icon indicating copy to clipboard operation
pyatv copied to clipboard

What happened to the idle state in home assistant?

Open aleszczynskig opened this issue 3 years ago • 4 comments

What do you need help with?

Hi,

Previously my Apple TV reported a state of idle when in menu screens (and when showing skip intro buttons in apps) in Home Assistant. With the latest version in HA 2022.02 there are only two states, playing and paused. Has the idle state been removed? I previously used the idle state in automations to detect between a genuine pause which would raise the lights after 5 seconds and a menu or skip button which would raise the lights after 30 seconds. I can no longer make this distinction and am hoping this is a bug or there is an alternative way I can detect the difference.

Thanks for any help in advance.

aleszczynskig avatar Feb 23 '22 20:02 aleszczynskig

I'm having the same issue. Not sure when it started occurring.

stephenmetzger avatar Mar 01 '22 01:03 stephenmetzger

Also interested in this. I have the same issue. I was using a check for having gone to idle for at least 11 seconds (the time those annoying intro buttons stay up) before raising the lights, where as pause would turn them up right away. Now I can't find another way to distinguish and I have to either live with the lights bouncing up and down (and not always successfully at that), or waiting 11 seconds after I paused for the lights to come back on - which is quite a long time to wait actually...

abuchanan920 avatar Apr 25 '22 01:04 abuchanan920

Looking into the code - it seems this is directly reported from the AppleTV via the MRP protocol. Previously there was some unknown state that was mapping to 'idle' and now they seem to be reporting 'paused' when those buttons are up. Presumably this started happening in some recent-ish TvOS release.

Probably the two places to look in order to see what I mean: The MRP protobuf definition: https://github.com/postlund/pyatv/blob/671c24a0b98346e5605e86d080af24a442d485ea/pyatv/protocols/mrp/protobuf/Common.proto#L70 and the logic for using it is at https://github.com/postlund/pyatv/blob/e8ae99be766370ef36543210105abe8c2dbcf611/pyatv/protocols/mrp/player_state.py

Short version is that the chances of being able to do something in pyatv to fix it seem grim...

abuchanan920 avatar Apr 25 '22 02:04 abuchanan920

Interesting I still the old behavior on HD Apple TV (model A1625) running the latest tvOS 15.4.1. The TV where it no longer reports as idle is a brand new 4K Gen2 (also running latest tvOS). So this looks like it make be model dependent behavior (at least in the current os version)

abuchanan920 avatar Apr 25 '22 02:04 abuchanan920

@aleszczynskig Can you test with latest HA release? A lot has happened some you opened the issue, so want to verify problem still exists.

postlund avatar Jul 13 '23 07:07 postlund

I will do some testing this evening and report back. I have noticed since HA 2023.7 that both idle and standby states have appeared which is positive. I haven’t tested which states are reported during the various use cases though so this will be the focus of my testing tonight.

aleszczynskig avatar Jul 13 '23 11:07 aleszczynskig

I've done some testing and the idle status seems to be working as before, i.e. when in menus or the home screens, at least in terms of media playback. So this issue seems to be resolved.

One small difference I have noted, though I have only tested this with the TV+ app is that when the apps are displaying buttons, like Skip Recap or Skip that the status remains as playing in HA and doesn't change to idle like it did previously. This is actually better in my opinion. I appreciate this is likely due to changes by Apple and not pyatv.

I can now reimplement my automation to turn on the lights immediately when pausing as the status correctly displays as paused.

FYI - for any future readers, this is fixed in HA 2023.07 at the time of writing.

I believe this issue is fixed so I'll close it.

aleszczynskig avatar Jul 13 '23 20:07 aleszczynskig