Control Android TV via HomeKit Remote app using Home Assistant

I made a simple guide that shows how to control any Android TV from your iPhone using the HomeKit Remote app.
This setup maps HomeKit button presses to Android TV commands, supporting DPAD navigation, OK, Back, Home, and Play/Pause plus full volume control - all with a single, universal automation.

:one: Prerequisites

  • Android TV or Google TV connected to Home Assistant (via the androidtv integration).
  • HomeKit Integration active in Home Assistant.
    Important: you should bridge the media_player entity to HomeKit instead of the remote entity.
    The script will automatically forward non-volume commands to the device’s remote entity.

Note: Make sure the name of the remote entity matches the media_player entity name. By default, they should be identical, so this should work for most users.


:two: Create a Central Script

Script

Create a new script and paste the following yaml:

alias: Android TV Remote Handler
description: Controlling Android TV via HomeKit Remote
mode: parallel
fields:
  remote_entity:
    description: Entity ID of the remote
    example: remote.android_tv
  key_name:
    description: Key pressed on HomeKit Remote
    example: arrow_right
sequence:
  - variables:
      remote_entity: remote.{{ remote_entity.split('.')[1] }}
      command_map:
        arrow_up: DPAD_UP
        arrow_down: DPAD_DOWN
        arrow_left: DPAD_LEFT
        arrow_right: DPAD_RIGHT
        select: DPAD_CENTER
        back: BACK
        information: HOME
  - target:
      entity_id: "{{ remote_entity }}"
    data:
      command: "{{ command_map[key_name] | default('') }}"
      num_repeats: 1
      delay_secs: 0
      hold_secs: 0
    action: remote.send_command
max: 10

:white_check_mark: What does it do?

  1. Creates a mapping between HomeKit key_name and Android TV commands (DPAD, ENTER, BACK, etc.).
  2. Automatically forwards commands to the correct remote entity derived from the media_player name.
  3. Allows multiple simultaneous executions (mode: parallel) so button presses won’t block each other.
  4. Sends the command via remote.send_command.

:three: Create a General Automation

Create a new automation and paste the following yaml:

alias: Handle Any HomeKit Remote
description: Listen to any HomeKit remote and send the command to the correct device
mode: parallel
trigger:
  - platform: event
    event_type: homekit_tv_remote_key_pressed
action:
  - service: script.android_tv_remote_handler
    data:
      remote_entity: "{{ trigger.event.data.entity_id }}"
      key_name: "{{ trigger.event.data.key_name }}"

:white_check_mark: What does it do?

  • Takes the entity_id from the event → identifies which remote/TV to target.
  • Takes the key_name from the event → identifies which button was pressed.
  • Runs the script we created earlier which handles the command.

Notes:

  • Volume buttons work in HomeKit because the media_player entity is bridged for volume.
    All other buttons (arrows, select, home, back) are sent via the remote entity derived from the media_player name.
  • Long-press actions are not supported. HomeKit does not expose long-press events for the TV Remote, so all commands are treated as single presses only.
  • This approach can be adapted to other devices (Samsung TVs, IR remotes, or any remote entity) by updating the command mapping.
    This guide only has the mapping for Android TV
3 Likes

I’m a newbie in the Home Assistant world. Actually, it’s being a couple hours since I deployed. But I just wanted to say thank you! from not knowing wth is a script or an automation to being able to control my TCL Tv with this little guide.
Thanks for creating and sharing the scripts!

1 Like

Do you use the Android TV Remote integration or the Android Debug Bridge integration for the TV?

It’s the Android TV Remote integration.
This is more stable than controlling via ADB

1 Like

Update 2
I added this line to the central script:

Now the information button will go to the home page.

For some reason, Apple hid the home button on devices that are not Apple TV, because we map the action of each button we can set that button to navigate to the home screen.

Update 3!

I updated the script – now you can also control the volume!

What was the problem?

To control the arrows, the select button, the home button, and the back button, you need to use the device’s remote entity.
But HomeKit Bridge does not allow sending volume commands through the remote.
If you use the media_player entity, volume buttons, play/pause, and power on/off work, but the rest (home, back, select, arrows) do not.

What’s the solution?

Connect the media_player entity instead of the remote to HomeKit Bridge.
When pressing one of the buttons, the script sends the command to the device’s remote entity.

How does it work?

  1. Extract the entity name, for example:
media_player.living_room_tv
  1. Take the last part (living_room_tv) and append it to the remote entity:
remote.living_room_tv

Note:

Make sure the name of the device’s remote entity matches the media_player entity name. It should be identical by default, so this should work for most users.

What to do now:

  • Remove the remote entity from the HomeKit Bridge.
  • Connect the media_player instead.
  • Update the script.

And here’s the new script:
(The guide above has also been updated)

alias: Android TV Remote Handler
description: Controlling Android TV via HomeKit Remote
mode: parallel
fields:
  remote_entity:
    description: Entity ID of the remote
    example: remote.android_tv
  key_name:
    description: Key pressed on HomeKit Remote
    example: arrow_right
sequence:
  - variables:
      remote_entity: remote.{{ remote_entity.split('.')[1] }}
      command_map:
        arrow_up: DPAD_UP
        arrow_down: DPAD_DOWN
        arrow_left: DPAD_LEFT
        arrow_right: DPAD_RIGHT
        select: DPAD_CENTER
        back: BACK
        information: HOME
  - target:
      entity_id: "{{ remote_entity }}"
    data:
      command: "{{ command_map[key_name] | default('') }}"
      num_repeats: 1
      delay_secs: 0
      hold_secs: 0
    action: remote.send_command
max: 10

I can control the TV with the HomeKit remote, but the volume buttons aren’t showing up. What could be the reason?

To resolve, thank you.

1 Like