On-Off Apple TV 4K

I’m trying this configuration, but I can’t turn off the Apple TV

- id: off_tv
  alias: Off TV
  description: offTV
  trigger:
  - platform: device
    type: turned_off
    entity_id: remote.apple_tv_4k
    domain: remote
  condition: []
  action:
  - wait_for_trigger:
      - platform: device
        type: turned_off
        entity_id: switch.apple_tv_4k
        domain: switch
  mode: single

The Apple TV cannot be turned off. She will go to stamby after a few minutes.

1 Like

Can be turned off with two keys home and select. But I don’t know how to programmatically hold down the home key for 2 seconds

lounge_appletv_poweroff:
  alias: Power off TV
  sequence:
    - service: remote.send_command
      target:
        entity_id: remote.apple_tv_4k
      data:
        delay_secs: 3
        command:
          - home
          - select

This is from a lovelace card, not an automation, but the media_player.turn_off service call works with apple TV.

    hold_action:
      action: call-service
      service: media_player.turn_off
      target:
        device_id:
          - #your apple tv's device id.

It’ll go to ‘standby’ but that is off. Also, your code won’t turn it off, you’re waiting for a trigger, not taking an action.

There is the option home_hold that you can use.

Check the docs for more info about it.

apple_tv_sleep:
  alias: "Make the Apple TV sleep"
  sequence:
    - service: remote.send_command
      target:
        entity_id: remote.lounge_appletv
      data:
        delay_secs: 1
        command:
          - home_hold
          - select
    - service: media_player.turn_off
      target:
        entity_id: media_player.lounge_appletv

This is the way over Bluetooth Remote with tvOS17:

“home_hold” trick doesn’t work for current tvOS 17.2 neither.

Instead, the “Sleep Now” item in Settings app will do the trick.

  - service: media_player.select_source
    target:
      entity_id: media_player.appletv 
    data:
      source: Settings
  - service: remote.send_command
    target:
      entity_id: remote.appletv 
    data:
      delay_secs: 0.7
      hold_secs: 0
      command:
        - menu
        - menu
        - menu
        - menu
        - menu
        - top_menu
  - service: media_player.select_source
    target:
      entity_id: media_player.appletv 
    data:
      source: Settings
  - service: remote.send_command
    target:
      entity_id: remote.appletv 
    data:
      num_repeats: 12
      delay_secs: 0.7
      hold_secs: 0
      command: down
  - service: remote.send_command
    target:
      entity_id: remote.appletv
    data:
      command: select

The media_player: Turn Off service works by itself, no need to pretend to manipulate the remote control.