home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.74k stars 30.46k forks source link

Apple tvOS 15 does not update status when paused and then turns off #76781

Closed sisimomo closed 1 year ago

sisimomo commented 2 years ago

The problem

Since updating the integration for Apple TV to support tvOS 15, there is a small bug that has appeared.

If you pause a Netflix/Plex show, and then turn off the TV, Home Assistant does not update the TV status. The state always stays at "paused" for ever. image

As you can see here, the Apple TV is according to Home Assistant paused since 11:02:05 p.m. . But in reality, I turned off the TV at 11:02:30 p.m, but it was never detected in Home Assistant.

What version of Home Assistant Core has the issue?

2022.8.4

What was the last working version of Home Assistant Core?

2022.1.0

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Apple TV

Link to integration documentation on our website

https://www.home-assistant.io/integrations/apple_tv/

Diagnostics information

No "download Diagnostics" option.

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

probot-home-assistant[bot] commented 2 years ago

apple_tv documentation apple_tv source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @postlund, mind taking a look at this issue as it has been labeled with an integration (apple_tv) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

sisimomo commented 2 years ago

Hi!

Does anyone have a similar problem?

Does anyone have any idea how I could solve this problem?

Jordenjj commented 2 years ago

Does anyone have a similar problem?

I experience the same thing. Holding down the power button to switch off while content is playing does set the state to standby. First pausing does not.

Jordenjj commented 1 year ago

Any updates on this?

sisimomo commented 1 year ago

No! Sadly it didn't catch the attention of the code owner (@postlund)😱.

ooii commented 1 year ago

Having the same issue too but did not pay attention to switching it off without pausing before. At least, that's a workaround.

sephrioth commented 1 year ago

Same issue here, very annoying...

dries83 commented 1 year ago

I have/had the same issue. I was able to solve it was this sequence (for turning on/off):

`sequence:

Sequence includes syncing the correct status of my Harmony Hub remote

1liminal1 commented 1 year ago

Did anyone ever have a look at this?

sisimomo commented 1 year ago

After some research, I think the problem is with Apple and not Home Assistant.

To confirm this, I created a Home on Homekit with my Apple TV in it to see what HomeKit status displays in the situation as explained above. And unfortunately HomeKit also thinks the TV is always on :/.

sephrioth commented 1 year ago

After some research, I think the problem is with Apple and not Home Assistant.

To confirm this, I created a Home on Homekit with my Apple TV in it to see what HomeKit status displays in the situation as explained above. And unfortunately HomeKit also thinks the TV is always on :/.

Homekit always only display Paused(but possibly standby) and Playing status. In previous tvOS version, HA can reads the Standby status when Homekit shows Paused.

ibennani commented 1 year ago

I might be on the path to a solution, but more digging into this issue is necessary

Background:

I have the same problem, but sometimes you actually can tell the true state of a entity by checking it's attributes.

My try on this was to se if any of the 11 attributes changed or dissipated if the Apple TV was turned off.

For example:

I dug into the settings of my Apple TV in order to find something that could alter this behaviour, but I could not find anything

Possible solution

NOTE!!! My findings above does not apply to all the apps on the Apple TV.

I tried three of the very common ones (Youtube, Netflix and Plex) and they all show the behaviour I'm describing.

Some other common streaming apps we use in Sweden (SVT Play, Telenor Stream) does not show this behaviour: If I am watching something using these apps and then I turn off the Apple TV while watching something, The device state turns to "standby" and the 11 attributes becomes just 5.

So, the problem seems to originate from the apps, not the TV-OS. Nevertheless, if the device is turned off, the state should always change to "standby".

The only solution (that I have not tried out yet) is to put some wall plug with power measurement to be able to tell the state of the Apple-TV.

Perhaps this might help somebody else to find a solution.

sephrioth commented 1 year ago

If you are watching Youtube, and you will find the current app_id is com.google.ios.youtube in attributes. Now you back to Home, and switch to another App, for instance Netflix, you will find these attributes like app_id won't change until you start playing in Netflix.

I thought the status changed instantly in previous versions. @postlund

postlund commented 1 year ago

The app is only reflects the app currently playing, not the app that is active. That is how the protocol works, so that is expected behavior.

sephrioth commented 1 year ago

The app is only reflects the app currently playing, not the app that is active. That is how the protocol works, so that is expected behavior.

Thanks for the explanation.
But the status reflected correctly in previous versions...Is there any changes on the tvOS side?

postlund commented 1 year ago

The app is only reflects the app currently playing, not the app that is active. That is how the protocol works, so that is expected behavior.

Thanks for the explanation. But the status reflected correctly in previous versions...Is there any changes on the tvOS side?

That has never been the behavior as far as I know. If it did work like that for you before, then you got lucky in that case.

1liminal1 commented 1 year ago

I may have missed something here, but I think the issue is when you "turn off" the apple TV when playing something, it does not reflect the standby state?

sephrioth commented 1 year ago

I may have missed something here, but I think the issue is when you "turn off" the apple TV when playing something, it does not reflect the standby state?

That’s the issue.

robertjan commented 1 year ago

Same issue here, i did tested some apps:

Jordenjj commented 1 year ago

Same issue here, i did tested some apps:

  • Youtube - stuck on paused status

  • spotify - stuck on paused status

  • ViaPlay - dont change the status at all, stays on idle and gos to standby

  • Netflix - works like it should, from paused to idle to standby

  • PrimeVideo - works like it should, from paused to idle to standby

  • Videoland - works like it should, from paused to idle to standby

Plex - doesnt change status to idle

Jordenjj commented 1 year ago

UPDATE: I found that the music app also has something to do with this. When a song is 'paused' which they stay for a very long time, other apps break as well such as prime. When I've listened to a song yesterday, closing the music app improves behaviour since it doesn't fall back on the music media it was playing.

1liminal1 commented 1 year ago

I wish we could get this fixed. None of my sleep automation was working the other night. Took me ages to find that the fitness app was still open.

I seem to have to close every app, each time I turn off the apple TV. Its stupid!

stevedngo commented 1 year ago

Same issue here, i did tested some apps:

  • Youtube - stuck on paused status
  • spotify - stuck on paused status
  • ViaPlay - dont change the status at all, stays on idle and gos to standby
  • Netflix - works like it should, from paused to idle to standby
  • PrimeVideo - works like it should, from paused to idle to standby
  • Videoland - works like it should, from paused to idle to standby

Plex - doesnt change status to idle

Plex - stuck on paused status Hulu - works like it should

1liminal1 commented 1 year ago

I'm really confused by the lack on information with this. There are some 20k installs of the Apple TV integration. Why are there not more complaints? Or is this only affecting a small subset of users?

Jordenjj commented 1 year ago

I'm really confused by the lack on information with this. There are some 20k installs of the Apple TV integration. Why are there not more complaints? Or is this only affecting a small subset of users?

Im pretty sure this affects everyone. Just not everyone wants to run automations based on the apple tv status

1liminal1 commented 1 year ago

What!!! That's nuts! LOL

Yeah I guess so right. Its just so great when your lights turn on when you hit pause, Im confused more people are not into it :)

Jordenjj commented 1 year ago

What!!! That's nuts! LOL

Yeah I guess so right. Its just so great when your lights turn on when you hit pause, Im confused more people are not into it :)

You can automate that. Playing/paused states work perfectly. Its just the standby state which doesn't initiate.

1liminal1 commented 1 year ago

Oh yeah, I know. I have a lot of stuff that checks the standby state as well :( So a lot of stuff is not working for me unless I close the apps each time, thats all :)

steve28 commented 1 year ago

Oh yeah, I know. I have a lot of stuff that checks the standby state as well :( So a lot of stuff is not working for me unless I close the apps each time, thats all :)

What do you mean by closing the apps?

1liminal1 commented 1 year ago

Closing the Apple TV apps like, YouTube or Apple Fitness ect

So for example, I have a bed occupancy sensor, but it wont run the "go to sleep" sequence (Im using Node Red) if the bedroom Apple TV is in a paused or playing state. So I have to close everything every time I turn off the apple TV

1liminal1 commented 1 year ago

I'm trying to figure out an automation that will close the apps. But the documentation is pretty bad on what the remote buttons actually are.

Does anyone know how to get a double click of the TV/Control Center button?

Thanks

steve28 commented 1 year ago

I do “top_menu” twice with a 2s pause in between On Apr 21, 2023, at 8:52 PM, 1liminal1 @.***> wrote:ï»ż I'm trying to figure out an automation that will close the apps. But the documentation is pretty bad on what the remote buttons actually are. Does anyone know how to get a double click of the TV/Control Center button? Thanks

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

1liminal1 commented 1 year ago

Thanks mate,

I did try that, but it doesn't work for me. This is what I got so far, now just note I am trying to get that app menu to pop up before adding more, it does not.

    data:
      delay_secs: 2
      command:
        - top_menu
        - top_menu
        - home_hold
        - select

Could you post your YAML?

Thanks :)

steve28 commented 1 year ago

I use media_player.turn_off to actually have the ATV turn off my TV and go to sleep. I wait for it it be Idle as well.

        - service: remote.send_command
          target:
            entity_id: remote.bedroom_atv
          data:
            delay_secs: 2
            command:
              - top_menu
              - top_menu
        - wait_template: "{{ is_state('media_player.bedroom_atv', 'idle' )}}"
          timeout: "00:00:10"
        - service: media_player.turn_off
          target:
            entity_id: media_player.bedroom_atv
1liminal1 commented 1 year ago

Thanks mate,

That doesn't work for me.

But I did get some time to figure it out this afternoon. If anyone with the apple TV 4K , I found this would close off up to 3 apps.

Might want to play with the times a bit more, sometimes it would only close one and miss the others. But hope it helps someone :)

alias: "Living Room Apple TV: Sleep"
sequence:
  - service: remote.send_command
    data:
      num_repeats: 1
      delay_secs: 0.4
      command:
        - top_menu
    target:
      entity_id: remote.living_room
  - service: remote.send_command
    data:
      num_repeats: 2
      delay_secs: 0.2
      command:
        - home
    target:
      entity_id: remote.living_room
  - repeat:
      count: "3"
      sequence:
        - service: remote.send_command
          data:
            delay_secs: 0.4
            hold_secs: 0
            command:
              - left
          target:
            entity_id: remote.living_room
        - delay:
            hours: 0
            minutes: 0
            seconds: 1
            milliseconds: 0
        - service: remote.send_command
          data:
            num_repeats: 2
            delay_secs: 0.2
            command:
              - up
          target:
            entity_id: remote.living_room
  - service: remote.send_command
    target:
      entity_id: remote.living_room
    data:
      delay_secs: 2
      command:
        - home_hold
        - select
mode: single
icon: phu:apple-tv
LukeCSmith0 commented 1 year ago

Still seems to be the case. If I pause Netflix and turn the TV off, the integration state is permanently paused and will not recover, the state never updates. Only resolution was to reload the integration and it successfully picks up the state immediately. I’ve resorted to creating an automation that just reloads my AppleTV integration every 30 seconds. Not ideal but means the state is a little more trustworthy.

1liminal1 commented 1 year ago

Yeah its pretty lax of the devs to not even acknowledge this issue :( Ive seen HA devs that don't even use the integration they maintain spend their time to help people out. This... completely ignored

DoctorExitus commented 1 year ago

I have the same problem. I had many automations that checked if the aTV is on standby or not, that didn't work anymore. I found a workaround by using the "on" state of my Philips TV. It works, but the response time is much slower. While the aTV almost instantly triggers automations when turning on, the Philips TV takes up to a minute or so. Would be nice, if this issue can somehow be fixed.

Jordenjj commented 1 year ago

Ive seen HA devs that don't even use the integration they maintain spend their time to help people out. This... completely ignored

Let's not feel entitled to software someone somewhere has built for free. The integration devs do not owe you anything.

1liminal1 commented 1 year ago

This isn't about entitlement. This is about a lack of communication for one of the most used HA integrations that's broken.

I was not angry, not abusive, didn't attack anyone. Was purely expressing my disappointment for an integration that's been broken for months with out any communication.

Get off your high horse

Jordenjj commented 1 year ago

This isn't about entitlement. This is about a lack of communication for one of the most used HA integrations that's broken.

You're also not entitled to that communication. You don't know whats going on in their lives.

1liminal1 commented 1 year ago

Well thank god you're here to insert yourself into this and let us all know about our entitlement. I'm sure all those with non working automations that have been patiently waiting the 6 months this has been broken, really appreciate your efforts.

Maybe if you actually knew the dev involved, you could add something constructive to the conversation instead of being the holy lord of gaslighting morality.

But again, thank you, you're very important

postlund commented 1 year ago

Let's stop this now. I would probably be considered the main developer here (but this is a community project, literally anyone can contribute to fix bugs like these) so let me elaborate. I am sorry I have not acknowledged this issue and also some of the other bugs the integration/pyatv has. The main reason for this is because I put a lot of time into pyatv over the course of more than one year (I mean a lot, lot) and I got more or less burned out and tired of the project. I dropped it. This in conjunction with a demanding job and family life with wife and two kids took its toll and I decided to cut myself of for while. I am finding my way back slowly, but I've decided to start out with things I enjoy and helping some of my long time users (and GitHub sponsors). I will get to this bug as well and it would help a lot of someone could reproduce this with atvremote and open a new issue over at pyatv instead (as he bug is in pyatv, not Home Assistant) and include a debug log as well. I will not actively monitor this issue.

So yes, I am very sorry to all users for not dealing with issues at a more rapid pace. I will however always prioritize my health before side-time projects any given day of the week.

Jordenjj commented 1 year ago

Maybe if you actually knew the dev involved, you could add something constructive to the conversation instead of being the holy lord of gaslighting morality.

Agreed, what you're saying IS constructive.

But again, thank you, you're very important

Also very constructive.

postlund commented 1 year ago

I have investigated this further and the behavior I'm seeing is:

However... By accident I stumbled across a new event type in the Companion protocol that I think I can use to solve this. I will have to implement and test it for a bit to be sure, but looks promising. I will try to implement this as soon as I can, hopefully within a few days (but I make no promises). Progress can be followed here: https://github.com/postlund/pyatv/issues/2048

postlund commented 1 year ago

I have implemented support for system status (as mentioned in previous comment) and currently making a new release, should be ready soon. Once released it needs to be bumped into Home Assistant, hopefully it will be incorporated into the next Home Assistant release.

bdraco commented 1 year ago

fixed via https://github.com/home-assistant/core/pull/94683 in 2023.7.0