Apple tv remote implementation

Is there a master list somewhere of all the commands you can send to the Apple TV?

Yes, under the Apple TV integration docs.

They are looked up dynamically, so there’s no proper list. But you can use this as a reference:

All keys like left, home, menu etc. works but not the ones starting with set_ (they are implemented using other constructs in Home Assistant).

I just wanted to share my remote for others out there. Mine is meant to be a full-screen tab on my mobile dashboard. After some though, I opted to forego the media player with cover-art to increase screen real estate.

cards:
  - cards:
      - type: custom:button-card
        entity: remote.boaty_mcboatface
        name: Menu
        icon: mdi:menu
        show_icon: true
        show_name: true
        tap_action:
          action: call-service
          haptic: heavy
          service: remote.send_command
          service_data:
            command: menu
            entity_id: remote.boaty_mcboatface
        hold_action:
          action: none
        styles:
          card:
            - height: 90px
          icon:
            - color: white
          label:
            - color: white
      - type: custom:button-card
        entity: remote.boaty_mcboatface
        name: Home
        icon: mdi:home
        show_icon: true
        show_name: true
        tap_action:
          action: call-service
          haptic: heavy
          service: remote.send_command
          service_data:
            command: home
            entity_id: remote.boaty_mcboatface
        hold_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: home_hold
            entity_id: remote.living_room
        styles:
          card:
            - height: 90px
          icon:
            - color: white
          label:
            - color: white
    type: horizontal-stack
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        entity: remote.boaty_mcboatface
        name: Sleep
        icon: mdi:sleep
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: suspend
            entity_id: remote.boaty_mcboatface
        hold_action:
          action: none
        styles:
          card:
            - height: 90px
          icon:
            - color: white
          label:
            - color: white
      - type: custom:button-card
        entity: remote.boaty_mcboatface
        name: Volume up
        icon: mdi:volume-plus
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          haptic: heavy
          service: remote.send_command
          service_data:
            command: volume_up
            entity_id: remote.boaty_mcboatface
        hold_action:
          action: none
        styles:
          card:
            - height: 90px
          icon:
            - color: yellow
          label:
            - color: white
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        entity: remote.boaty_mcboatface
        name: Play/Pause
        icon: mdi:play-pause
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          haptic: heavy
          service: remote.send_command
          service_data:
            command: play_pause
            entity_id: remote.boaty_mcboatface
        hold_action:
          action: none
        styles:
          card:
            - height: 90px
          icon:
            - color: green
          label:
            - color: white
      - type: custom:button-card
        entity: remote.boaty_mcboatface
        name: Volume down
        icon: mdi:volume-minus
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          haptic: heavy
          service: remote.send_command
          service_data:
            command: volume_down
            entity_id: remote.boaty_mcboatface
        hold_action:
          action: none
        styles:
          card:
            - height: 90px
          icon:
            - color: yellow
          label:
            - color: white
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        entity: remote.boaty_mcboatface
        hold_action:
          action: none
        icon: mdi:rewind-10
        name: Skip Back
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: skip_backward
            entity_id: remote.boaty_mcboatface
        styles:
          card:
            - height: 50px
          icon:
            - color: orange
          label:
            - color: white
      - type: custom:button-card
        entity: remote.boaty_mcboatface
        hold_action:
          action: none
        icon: mdi:fast-forward-10
        name: Skip forward
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: skip_forward
            entity_id: remote.boaty_mcboatface
        styles:
          card:
            - height: 50px
          icon:
            - color: orange
          label:
            - color: white
  - type: custom:button-card
    color_type: blank-card
    styles:
      card:
        - height: 0px
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        color_type: blank-card
        styles:
          card:
            - height: 50px
            - padding: 1%
      - type: custom:button-card
        entity: remote.boaty_mcboatface
        hold_action:
          action: none
        icon: mdi:arrow-up
        name: Up arrow
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: up
            entity_id: remote.boaty_mcboatface
        styles:
          card:
            - height: 130px
          icon:
            - color: white
          label:
            - color: white
      - type: custom:button-card
        color_type: blank-card
        styles:
          card:
            - height: 50px
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        entity: remote.boaty_mcboatface
        hold_action:
          action: none
        icon: mdi:arrow-left
        name: Left arrow
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: left
            entity_id: remote.boaty_mcboatface
        styles:
          card:
            - height: 130px
          icon:
            - color: white
          label:
            - color: white
      - type: custom:button-card
        entity: remote.boaty_mcboatface
        hold_action:
          action: none
        icon: mdi:apple
        name: Select
        show_icon: false
        show_name: true
        tap_action:
          action: call-service
          haptic: heavy
          service: remote.send_command
          service_data:
            command: select
            entity_id: remote.boaty_mcboatface
        styles:
          card:
            - height: 130px
          icon:
            - color: white
          label:
            - color: white
            - text-size: 12px
      - type: custom:button-card
        entity: remote.boaty_mcboatface
        hold_action:
          action: none
        icon: mdi:arrow-right
        name: Right arrow
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: right
            entity_id: remote.boaty_mcboatface
        styles:
          card:
            - height: 130px
          icon:
            - color: white
          label:
            - color: white
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        color_type: blank-card
        styles:
          card:
            - height: 50px
      - type: custom:button-card
        entity: remote.boaty_mcboatface
        hold_action:
          action: none
        icon: mdi:arrow-down
        name: Down arrow
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: down
            entity_id: remote.boaty_mcboatface
        styles:
          card:
            - height: 130px
          icon:
            - color: white
          label:
            - color: white
      - type: custom:button-card
        color_type: blank-card
        styles:
          card:
            - height: 50px
type: vertical-stack

6 Likes

Hi, are there plans to implement the swipe input? I’m aware that ‘up’ exists but there are some functions that require the swipe (or I’m too dumb to figure out how to make ‘up’ work as a swipe up).

As an example, if I send a movie to plex on the apple tv, the movie plays, but the consequence is that it seems to crap out the plex interface and hide my library as well as overlay text onto other text. If I use the apple tv remote to press home twice, then left, then swipe up with the touchpad I can ‘force quit’ the app selected (in this instance, plex). Then when I open plex again, it’s all good/working as intended.

This is what I currently have in a script:

alias: TEST - Apple TV Force Close Applications
sequence:
  - service: remote.send_command
    data:
      command:
        - home
      num_repeats: 2
      delay_secs: 0.2
    target:
      device_id: (appletv)
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: remote.send_command
    data:
      command:
        - left
    target:
      device_id: (appletv)

So I can send the double-tap remote command to open the app switcher, then navigate left, but then I can’t get swipe up to work. I’ve tried holds, delays, repeats, no dice.

Adding the ‘up’ remote.send_command at the end doesn’t work in the same swipe up manner that you’d expect.
‘up’ works perfectly when in the homescreen tile interface, just not as a swipe up during the app-switcher.

Failing that, if someone knows how to automate the force-quit of apps I’m all ears.
Thanks in advance.

Feature request: AppleTV remote → skip ahead 15 seconds.

Is it possible to trigger a native command to skip ahead a few seconds (like when clicking the right side of the AppleTV trackpad while media is playing)? Same for skip-back a few a seconds.

I have rigged together a workable solution by calculating timecodes and setting the playhead. This works in most cases. Some applications (YouTubeTV) break my solution. Do you have advice on how I may (1) improve my solution below, or (2) how to use the built-in “skip-ahead” / “skip-back” commands?

Thank you.

varEntity = msg.data.entity_id;
varPosition = msg.data.attributes.media_position;
varCurrenttime = msg.myepoch;
varLastupdated = msg.data.attributes.media_position_updated_at;
varLastupdated = Date.parse(varLastupdated);
varPosition = varCurrenttime / 1000 - varLastupdated / 1000 + varPosition - 15;
varPosition = Math.round(varPosition);
msg.payload = {"entity_id":varEntity};
msg.payload.data = {"seek_position":varPosition};

return msg;
1 Like

Has anyone got a prettier version of this to select any of your commonly used apps on the AppleTV?

type: conditional
conditions:
  - entity: remote.living_room
    state: 'on'
card:
  type: grid
  cards:
    - type: picture
      image: https://upload.wikimedia.org/wikipedia/commons/3/3e/Disney%2B_logo.svg
      tap_action:
        action: call-service
        service: media_player.select_source
        service_data:
          source: Disney+
        target:
          entity_id: media_player.living_room
    - type: picture
      image: https://upload.wikimedia.org/wikipedia/commons/3/35/Nficon2016.png
      tap_action:
        action: call-service
        service: media_player.select_source
        service_data:
          source: Netflix
        target:
          entity_id: media_player.living_room
      hold_action:
        action: none
    - type: picture
      image: >-
        https://upload.wikimedia.org/wikipedia/commons/e/e3/Amazon_Prime_Logo.svg
      tap_action:
        action: call-service
        service: media_player.select_source
        service_data:
          source: Prime Video
        target:
          entity_id: media_player.living_room
      hold_action:
        action: none
    - type: picture
      image: >-
        https://upload.wikimedia.org/wikipedia/commons/c/c4/BBC_iPlayer_2021_%28Alt%29.svg
      tap_action:
        action: call-service
        service: media_player.select_source
        service_data:
          source: BBC iPlayer
        target:
          entity_id: media_player.living_room
      hold_action:
        action: none
    - type: picture
      image: https://upload.wikimedia.org/wikipedia/commons/9/9d/AppleMusic_2019.svg
      tap_action:
        action: call-service
        service: media_player.select_source
        service_data:
          source: Music
        target:
          entity_id: media_player.living_room
      hold_action:
        action: none
    - type: picture
      image: https://upload.wikimedia.org/wikipedia/commons/f/f0/Plex_vector_logo.svg
      tap_action:
        action: call-service
        service: media_player.select_source
        service_data:
          source: Plex
        target:
          entity_id: media_player.living_room
      hold_action:
        action: none
  square: true
  columns: 4
1 Like

@benjmd Last I looked, there is no “swipe” specific commands available. However, if you are looking to use them for the purpose of killing apps, I know that double tapping the up button will perform the same as a swipe action. This is what I do on my dashboard and Harmony remote. Beyond this I would assume it would work, but I can’t confirm.

@a-a-ron There is already the ability to skip back and forward 10 seconds by sending the skip_backward and the skip_forward commands.

I’m using something like this.
Struggling to remove the boarders and padding around the buttons of the streaming icons but I am getting there slowly. My code looks like this

hide:
  power: true
  volume: true
idle_view:
  when_standby: true
shortcuts:
  buttons:
    - image: /local/channels/Netflix.png
      id: Netflix
      type: source
    - image: /local/channels/DisneyPlus.png
      id: Disney+
      type: source
    - image: /local/channels/AppleTV.png
      id: TV
      type: source
    - image: /local/channels/Stan.png
      id: Stan
      type: source
    - image: /local/channels/Plex.png
      id: Plex
      type: source
    - image: /local/channels/Binge.png
      id: Binge
      type: source
    - image: /local/channels/ABCiView.png
      id: ABC iview
      type: source
    - image: /local/channels/PrimeVideo.png
      id: Prime Video
      type: source
  column_height: 20
  columns: 8
source: full
entity: media_player.living_room_apple_tv
type: custom:mini-media-player
icon: mdi:arrow-up-bold
show_name: false
show_state: false
size: 10%
styles:
  card:
    - margin: 0px
    - padding: 0%
    - height: 155px
    - border: 0%
    - box-shadow: none
tap_action:
  action: call-service
  haptic: medium
  service: remote.send_command
  service_data:
    command: up
    entity_id: remote.living_room_apple_tv
name: Living room

2 Likes

Doesn’t, thanks for the suggestion :slight_smile:

OMG I need this so I can remotely control my AppleTV when i’m not at the house. Sometimes my guest log themselves out of my Netflix account and I need to be able to control the device from afar.

I’m a n00b when it comes to Home Assistant. What do I need to do to get this remote interface to work with my AppleTV? Would truly appreciate any pointers!

I’m curious, is this javascript code you wrote for a custom button card?

Not entirely sure if your version isnt working out of the box anymore due to changes in the yaml syntax but I got it fixed (at least for me)

I changed the start to the following:

type: vertical-stack
cards:
  - show_name: false
    show_icon: true
    entity: remote.wohnzimmer

And removed type: vertical-stack at the end

Sadly I didnt get the commands to work.
Im using an Apple TV integrated into a sony bravia tv and an homepod mini

Both get the following error message when pressing any button:
Fehler beim Aufrufen des Diensts remote/send_command. left is not supported
To english translated: Error when calling the service remote/send_command. left is not supported

Same for right, select, up, down and so on…

Not sure if the integration isnt working anymore in the newest version of home assistant (2023.2.5) or if I am missing something.

Never the less here is my updated full blueprint for an lovelace card:
Instead of the XXXXXXXX give your entity name

type: vertical-stack
cards:
  - entity: media_player.XXXXXXXX
    type: media-control
  - cards:
      - cards:
          - show_name: false
            show_icon: true
            entity: remote.XXXXXXXX
            hold_action:
              action: none
            icon: mdi:arrow-left
            name: Left arrow
            tap_action:
              action: call-service
              service: remote.send_command
              data:
                command: left
                num_repeats: 1
                delay_secs: 0.4
                hold_secs: 0
              target:
                entity_id: remote.XXXXXXXX
            type: button
          - entity: remote.
            hold_action:
              action: none
            icon: mdi:apple
            name: Select
            show_icon: true
            show_name: false
            tap_action:
              action: call-service
              service: remote.send_command
              service_data:
                command: select
                entity_id: remote.XXXXXXX
            type: button
          - entity: remote.XXXXXXXX
            hold_action:
              action: none
            icon: mdi:arrow-right
            name: Right arrow
            show_icon: true
            show_name: false
            tap_action:
              action: call-service
              service: remote.send_command
              service_data:
                command: right
                entity_id: remote.XXXXXXXX
            type: button
        type: horizontal-stack
      - cards:
          - entity: remote.XXXXXXXX
            hold_action:
              action: none
            icon: mdi:arrow-up
            name: Up arrow
            show_icon: true
            show_name: false
            tap_action:
              action: call-service
              service: remote.send_command
              service_data:
                command: up
                entity_id: remote.XXXXXXXX
            type: button
          - entity: remote.XXXXXXXX
            hold_action:
              action: none
            icon: mdi:menu
            name: Menu
            show_icon: true
            show_name: false
            tap_action:
              action: call-service
              service: remote.send_command
              service_data:
                command: menu
                entity_id: remote.XXXXXXXX
            type: button
          - entity: remote.XXXXXXXX
            hold_action:
              action: none
            icon: mdi:arrow-down
            name: Down arrow
            show_icon: true
            show_name: false
            tap_action:
              action: call-service
              service: remote.send_command
              service_data:
                command: down
                entity_id: remote.XXXXXXXX
            type: button
        type: horizontal-stack
      - type: horizontal-stack
        cards:
          - type: button
            tap_action:
              action: call-service
              service: remote.send_command
              service_data:
                command: home
                entity_id: remote.XXXXXXXX
            hold_action:
              action: call-service
              service: remote.send_command
              service_data:
                command: home_hold
                entity_id: remote.living_room
            show_icon: true
            show_name: false
            entity: remote.XXXXXXXX
            icon: mdi:home
            name: Home
          - type: button
            tap_action:
              action: call-service
              service: remote.send_command
              service_data:
                command: suspend
                entity_id: remote.XXXXXXXX
            show_icon: true
            show_name: false
            entity: remote.XXXXXXXX
            name: Sleep
            icon: mdi:sleep
            hold_action:
              action: none
          - type: button
            tap_action:
              action: call-service
              service: remote.send_command
              service_data:
                command: volume_up
                entity_id: remote.XXXXXXXX
            hold_action:
              action: none
            show_icon: true
            show_name: false
            entity: remote.XXXXXXXX
            name: Volume up
            icon: mdi:volume-plus
      - type: horizontal-stack
        cards:
          - type: button
            tap_action:
              action: call-service
              service: remote.send_command
              service_data:
                command: play_pause
                entity_id: remote.XXXXXXXX
            hold_action:
              action: none
            show_icon: true
            show_name: false
            entity: remote.XXXXXXXX
            name: Play/Pause
            icon: mdi:play-pause
          - type: button
            tap_action:
              action: call-service
              service: remote.send_command
              service_data:
                command: next
                entity_id: remote.XXXXXXXX
            hold_action:
              action: none
            show_icon: true
            show_name: false
            entity: remote.XXXXXXXX
            icon: mdi:skip-next
            name: Next
          - type: button
            tap_action:
              action: call-service
              service: remote.send_command
              service_data:
                command: volume_down
                entity_id: remote.XXXXXXXX
            hold_action:
              action: none
            show_icon: true
            show_name: false
            entity: remote.XXXXXXXX
            name: Volume down
            icon: mdi:volume-minus
    type: vertical-stack

2 Likes

Thanks you so much, its working perfectly for me :slight_smile:

What devices are you using it on?

Apple TV 4K A1842 with TV OS 16.3.2

1 Like

Hello guys, is there a way i can use by pressing one of the buttons on my siri remote as a trigger?

Hi guys. I’m trying to configure my dashboard to include shortcuts to commonly used apps in Apple TV like Netflix and Disney. I’m aware it’s been stated at the top of this topic that it’s not possible to launch apps, however I can launch apps using the media player card IF the apple TV is on:

image

This gives me hope that it’s possible to put a card with all my favorite apps and have it open on the TV (as long as it is turned on already). Can anybody help on how to go about this?

Is there any way I can see the commands sent to the TV when I navigate the media player like shown above? Maybe that way I can check how and link it to a card, perhaps?

Very new to HA so I would appreciate any help!

I thought you could use the media_player.select_source service with the source being the app name and to launch an app.

this worked perfectly! thank you