postlund / pyatv

A client library for Apple TV and AirPlay devices
https://pyatv.dev
MIT License
838 stars 91 forks source link

Home_hold not working anymore #2286

Open mirceadb7 opened 7 months ago

mirceadb7 commented 7 months ago

Describe the bug

The Apple TV integration home_hold command is not correct, it’s command behavior like home command, it isn’t any difference. on the last update when sending home_hold command the upper right menu will pop-up, now, on 2023.11.1 will send the home_hold command but the Apple TV only receives a home command. In my automation I need home_hold to pop-up the upper menu and switch to Home app into a camera live feed

Error log

<place log here>

How to reproduce the bug?

service: remote.send_command
data:
  num_repeats: 1
  delay_secs: 0.4
  hold_secs: 0
  command: home_hold
target:
  entity_id: remote.kitchen

What is expected behavior?

Popup the upper menu on apple tv

Operating System

macOS

Python

3.6

pyatv

0.8.2

Device

Apple TV 4K 17.1 OS

Additional context

The issue has appeared on the latest Home Assistant version. core-2023.11.1

apostoladriann commented 7 months ago

Can confirm the same issue here as well. Same setup as mirceadb7.

Currently running this work around script to turn off the apple tv

alias: Apple TV - off
sequence:
  - service: media_player.select_source
    data:
      source: Settings
    target:
      entity_id: media_player.apple_tv_4k
  - service: remote.send_command
    data:
      command: down
      num_repeats: 14 <<- this is to make sure the selection goes to the end of the settings menu where the “sleep now” function is
      delay_secs: 0.2
    target:
      entity_id: remote.apple_tv_4k
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: remote.send_command
    data:
      command: select
    target:
      entity_id: remote.apple_tv_4k
mode: single
mirceadb7 commented 7 months ago

Can confirm the same issue here as well. Same setup as mirceadb7.

Currently running this work around script to turn off the apple tv

alias: Apple TV - off
sequence:
  - service: media_player.select_source
    data:
      source: Settings
    target:
      entity_id: media_player.apple_tv_4k
  - service: remote.send_command
    data:
      command: down
      num_repeats: 14 <<- this is to make sure the selection goes to the end of the settings menu where the “sleep now” function is
      delay_secs: 0.2
    target:
      entity_id: remote.apple_tv_4k
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: remote.send_command
    data:
      command: select
    target:
      entity_id: remote.apple_tv_4k
mode: single

To turn off Apple TV, use suspend comand.

apostoladriann commented 7 months ago

Thanks, will test, seems like a more straight forward approach :) i appreciate the info.

However, remote home_hold is for a fact broken since core-2023.11.1. It acts like a regular remote home command since then.

mirceadb7 commented 6 months ago

@postlund Do you have any update on the fix ? 🙏

postlund commented 6 months ago

@mirceadb7 Can you check if atvremote ... home=2 works as expected? I will deprecate home_hold and it should not be used anymore.

mirceadb7 commented 6 months ago
service: remote.send_command
target:
  entity_id: remote.kitchen
data:
  num_repeats: 1
  delay_secs: 0.4
  hold_secs: 0
  command: home=2

Failed to call service remote.send_command. Unknown error
postlund commented 6 months ago

It is not implemented in Home Assistant yet, there's a PR for it I think.

mirceadb7 commented 6 months ago

It is not implemented in Home Assistant yet, there's a PR for it I think.

PR? What is PR?

postlund commented 6 months ago

It is not implemented in Home Assistant yet, there's a PR for it I think.

PR? What is PR?

Pull Request. It's how you suggest code changes on github. I believe it will be merged for the next release, but I'm not 100% certain though. So easiest way to test is with atvremote.

mirceadb7 commented 6 months ago

I can test it but I don’t know how

stp6778 commented 5 months ago

You need to update remote.py

cd /usr/src/homeassistant/homeassistant/components/apple_tv
mv remote.py remote.py.ref
wget https://raw.githubusercontent.com/home-assistant/core/0f1d4f310340c0e20c00bf33dbcd78c491506da5/homeassistant/components/apple_tv/remote.py

And then you can test

service: remote.send_command
target:
  device_id: ...
data:
  num_repeats: 1
  delay_secs: 0.4
  hold_secs: 2
  command: home
mirceadb7 commented 5 months ago

cd /usr/src/homeassistant/homeassistant/components/apple_tv in usr folder i have : bin, lib, local, share, include, libexec and sbin @stp6778 i’m using ha yellow.

stp6778 commented 5 months ago

@mirceadb7 I'm using a docker container and I don't know how home assistant runs on macOS You need to search a file named remote.py where you've installed homeassistant, something like : find /srv/homeassistant -name remote.py or goes inside the virtual environment to find the remote.py file Sorry but a macOS user should provide a better help than me

mirceadb7 commented 5 months ago

@mirceadb7 I'm using a docker container and I don't know how home assistant runs on macOS You need to search a file named remote.py where you've installed homeassistant, something like : find /srv/homeassistant -name remote.py or goes inside the virtual environment to find the remote.py file Sorry but a macOS user should provide a better help than me

I dont have HA installed on MAC, i have Home Assistant Yellow.

stp6778 commented 5 months ago

Ok, can you execute the command : find / -name remote.py

mirceadb7 commented 5 months ago

Yes, but no apple_tv remote. → / find / -name remote. py /homeassistant/custom_components/samsungtv_smart/re mote. py → /homeassistant/custom_components/sonoff/remote.py

stp6778 commented 5 months ago

Seems you are not connected as root...

You can try create : /homeassistant/custom_components/apple_tv and copy all files from : https://github.com/home-assistant/core/tree/dev/homeassistant/components/apple_tv

and replace remote.py by : https://raw.githubusercontent.com/home-assistant/core/0f1d4f310340c0e20c00bf33dbcd78c491506da5/homeassistant/components/apple_tv/remote.py

and restart home assistant

mirceadb7 commented 5 months ago

Tried mkdir apple_tv, copying from github, replacing remote.py, restarting but it didnt work, send home for 2 seconds doesnt do anything else from sending home. Maybe HA installed in Yellow its different from docker container.

stp6778 commented 5 months ago

I just check on my server and custom components need a version key : there is a error message in home assistant log file ; [homeassistant.loader] The custom integration 'apple_tv' does not have a version key in the manifest file and was blocked from loading. See https://developers.home-assistant.io/blog/2021/01/29/custom-integration-changes#versions for more details

This message disappear after adding "version": "0.0.0", in the file : /homeassistant/custom_components/apple_tv/manifest.json

and custom component loads successfully [homeassistant.loader] We found a custom integration apple_tv which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

mirceadb7 commented 5 months ago

On Apple tvOS 17.2 when you press de power button short the upper menu will appear, so it doesn’t have to be home_hold.