Android TV Card - Universal Remote with Touchpad, Slider, and Keyboard Support

A universal remote card originally forked from @usernein’s tv-card for the Android TV Remote integration, but now can be customized for a wide variety of media platforms and alternative uses.

  • Customizable touchpad swipe, double tap, hold, and multi touch actions.
  • Tap, double tap, and hold action support for buttons and the touchpad, including keys, sources, service calls, lovelace navigation, URL navigation, and browser dom events.
  • Alternate momentary button/touchpad center mode for advanced usage.
  • Customizable timings for repeat on hold delay, double tap window, and time to trigger hold action.
  • Navigation tweaked to behave more like the Google TV remote.
  • Buttons, slider, and touchpad now configured via the rows key as an array of strings. You can also create sub-arrays which will create columns, and sub-sub-arrays which create rows to make more complicated remotes.
  • Built in CSS style options that apply before render.
  • Native slider that does not require additional add-ons.
  • Many more default keys and sources, with SVG icons for sources with no material design icon present in Home Assistant’s default material design icon list.
  • Send text using the Android Debug Bridge integration with three methods implemented depending on the button used:
    • keyboard: seamless live text entry.
    • textbox: bulk text entry.
    • search: Google Assistant search.
    • Also supports Fire TV, Roku, and Kodi.
  • Template support for almost all fields.

Big thanks to the authors of the cards this card was originally forked from for all the ground work they did. I’m a backend engineer by trade and wouldn’t have been able to make this beautiful customizable UI myself. I didn’t have to modify much to get it working with Android TV and it works as a great base for adding more features.

This project is now available on HACS! Search for it under frontend repositories.

22 Likes

Awesome work! I came across the original tv remote card but quickly found out it doesn’t work for my Nvidia Shield. This works just great so thanks for the mods :slight_smile:

Any plans on integrating different types of sources? Looks like out of the box the Netflix, Youtube or Spotify buttons do not work. For now I can get it to work with a definition of a custom source like

custom_sources:
  netflix:
    icon: mdi:netflix
    service: remote.turn_on
    service_data:
      activity: http://www.netflix.com/title
      entity_id: remote.shield
1 Like

I wasn’t using the streaming service buttons and hadn’t realized that they no longer work. I should definitely fix that. Logging a bug and going to work on it now.

2 Likes

Fixed!

BUT I wasn’t able to get the correct activities or test many of the new default sources. If you or anyone else knows the correct ones for the ones that don’t work please let me know so I can fix them.

If you haven’t seen it yet, check Android TV Remote - App Links/Deep Linking - Guide

1 Like

Yup, I referenced it in the v1.3.2 release notes and used your collection of deep links as a basis for the expanded list of default sources (here in android-tv-card.js). The big ones I want to fix are Hulu and Max, as I use those two regularly but wasn’t able to find their deep links within their AndroidManifest.xml files. None of Hulu’s possible options worked and Max had hex codes instead of human readable strings.

That is just awesome! Looks great even the include svg icons. I have tested Netflix, Disney+, Youtube and Prime video and all work like a charm. Thanks man. I’ll surely keep on testing and let you know if I find anything that doesn’t work.

Three buttons do not work on my Nvidia Shield but that could just be my Shield or the integration acting up but thats opening the menu, settings and button mode. According to the Android TV Remote docs it’s BUTTON_MODE, SETTINGS or MENU but not even manually calling a service with those commands work.

1 Like

Yeah unfortunately I think some of the buttons not working is a limitation of the underlying library that the integration uses or the protocol itself. I was asking about alphabetical buttons in this thread and the author of the Android TV Remote Protocol V2 Python package @tronikos said it hadn’t been reversed engineered yet. Still there is a workaround for sending text using ADB with this integration. Maybe it’ll work for your buttons too?

Thanks for the suggestion! I will deff try it out.

I was fiddling around with the buttons and there is a typo (underscore) in the play button

play: { key: 'MEDIA_PLAY_', icon: 'mdi:play' },

In version 1.3.3 somehow the buttons for the navigation_row are wrong aligned.

vs 1.3.2

1 Like

Sorry about that! I broke the navigation row buttons when I was refactoring in v1.3.3. Fixed in v.1.3.4.

1 Like

Just found this very promising bit of code.

I am wondering how difficult it would be to adapt this code for other media players like Kodi and Apple TV. I would assume many people would be interested in that?
I want to program very similar swipe gestures/touchpad remotes for all me HT gear, as I have in the current environment that I am migrating from at some point (iRule)
Any comments appreciated. Many thanks!

You should be able to use the custom_keys and custom_sources input options to do so without any code change. But feel free to fork it to make a version that works with other stream boxes natively! This project is already a fork of a fork haha. See this part of the README.. Custom keys and sources was actually already a feature in the project forked this from (although it didn’t work with swipe commands then), and a more rudimentary version existed in the card that was forked from.

1 Like

Thanks @Nerwyn . Appreciated!
I will definitely experiment with this over the coming months. It looks like a very good base to start from for a modern swipe-based GUI in HA. Many thanks!

Hello,
I am so far unable to get this working with my Apple TV and Kodi Box.
Also unable to find examples for how and where to use custom_keys

Any chance of a short bit of example code to show intended possible use, to try to get going?
Many thanks regardless.

It’s right there in the README. I don’t have an Apple TV so I can’t test it, but based on the Apple TV Home Assistant integration page I imagine that it should look something like this:

type: custom:android-tv-card
remote_id: remote.apple_tv
_row_1:
  - power
  - play
  - pause
  - menu
navigation_row: touchpad
custom_keys:
  up:
    icon: mdi:chevron-up
    key: up
  down:
    icon: mdi:chevron-down
    key: down
  left:
    icon: mdi:chevron-left
    key: left
  right:
    icon: mdi:chevron-right
    key: right
  center:
    icon: mdi:checkbox-blank-circle
    key: select
  power:
    icon: mdi:power
    key: suspend # or wakeup? idk I'm an Android user.
  play:
    icon: mdi:play
    key: play
  pause:
    icon: mdi:pause
    key: pause
  menu:
    icon: mdi:menu
    key: menu
  

This works 100%. You’re a star! Many thanks!
Don’t suppose you are using Kodi either?

2 Likes

Nope. I tried Kodi a few times but it never played well with my setup. I used to use a combination of AutoHotKey and Rainmeter to launch Windows streaming apps straight to fullscreen but it was janky since most Windows streaming apps don’t play well with direction key controls and it confused people who thought the whole setup would behave like a regular smart TV. Tried a couple of third party app launchers but then bit the bullet and got a Google TV for my home theater when the new Home Assistant Android TV remote integration was released. For streaming personal media I use Plex. Got a lifetime pass on sale a while ago and it’s easy for less technically savvy family and friends to use.

1 Like

Thanks for the info. Long time Kodi user here and these days on Raspi 4 with 4K, HDR and Atmos :wink:
Very happy with it. Does it all for any user with a clean GUI IMHO. Ah well.

I now have two cards working with this touchpad card for an Apple TV and a Sony Bravia TV.
Will continue to try to build two more touchpads and custom keys for Kodi and a Marantz receiver.
Those two are trickier, at least to me.
Any hints appreciated on those two would be very much appreciated.
Your touchpad code makes it very possible. Many, many thanks again!

1 Like

FYI: You can now send text to your Android TV using this card via the Android Debug Bridge integration. Entering the ADB media_player entity ID into the card config via the adb_id option and then creating and clicking on a keyboard button opens a browser prompt, which you can enter text into which will be sent to your Android TV via ADB. Make sure to also create delete and enter buttons so you can easily remove and search for the text you enter.

In the future I hope to change this to use a keypress event listener to send key events via ADB instead. I was initially working on that but I found that it would be much easier and faster to implement this method for now. Before I can use keypress events instead I’ll have to map all of the possible JS key codes to ADB key codes.

1 Like

Dear @Nerwyn
Thanks again for this great bit of code.
Just wondering if you would care to comment on an issue I have with getting Kodi to work with this
touch pad? As an example ( the down arrow for navigation) how would you in your view suggest doing this code so that it works for a button in HA used in the settings for your touchpad settings?
I have so far been unable to get it to work with this card? Many thanks regardless!