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

I’ve got a Sony XR 65a83j, and it has the function to turn off the screen (while leaving the TV itself on) in the TV hotbar, a very handy function for using TV to play music. Do you know if and how it would be possible to configure this to have it as a dedicated button I can press on my phone to turn off the screen?

Also I have an app “TV Bro”, which is essentially a browser on my TV. Any idea how I can pull this browser app source, and also navigate inside of it via my mobile phone (is there even a way to just navigate via “mouse”, but via mobile?)

Hello Nerwyn
Thanks for the great work. I started using your card a few weeks ago. I tried your latest nunchuck update to animate buttons. I dont know why the new buttons work on my galaxy tab-s3 tablet but they don’t work on my laptop and s22ultra phone. Actually the icons dont show up on the card but they work when you touch on their supposed places on the screen.

Can you please advice how can I solve this problem

This is a picture from the non working version from my laptop, Normally the card is full of buttons but the buttons with conditional icons with nunchucks dont show up. only buttons with normal icons show up.

99% of the time Inconsistent behavior between modern devices is a caching issue. Have you tried clearing browser cache on or restarting the non-working devices?

Not sure what a TV hotbar is, but you’d have to figure out if this command is being sent via IR, RF, ADB, the remote API, or something Sony proprietary, and then figure out if it’s possible to call that from Home Assistant.

For creating new sources, see this thread: Android TV Remote - App Links/Deep Linking - Guide. I’m also not sure about 1:1 mouse control on Android TV. I know it’s possible on Windows using Unified Remote, but I don’t think the 1:1 mouse capability of that is possible on Home Assistant.

I’m not a Kodi user, but if there is a way to do it it would be in the Kodi JSON-RPC API documentation.

Thx to this project, very cool and handy to control my media devices.

Here an example of my popup control with a logitech harmony. It is based on the Rounded Theme which you can find here

type: custom:android-tv-card
remote_id: remote.wohnzimmer
slider_id: media_player.denon_avr_2113
button_style:
  width: 100px
  height: 100px
  border-radius: 20px
  background: var(--contrast3)
  '--size': 32px
touchpad_style:
  height: 200px
  background: url( '{{ state_attr("media_player.vu_wohnzimmer", "entity_picture") }}') center no-repeat
  background-color: var(--contrast3)
slider_style:
  '--border-radius': 12px
  height: 24px
  '--background-height': 12px
  '--color': var(--contrast18)
  '--background': var(--contrast3) 
rows:
  - - exit
    - home
    - power
  - - menu
    - channelup
    - channeldown  
  - - volume_slider    
  - - navigation_touchpad
  - - red
    - green
    - yellow
    - blue
custom_keys:
  power:
    icon: mdi:power
    service: select.select_option
    service_data:
      entity_id: select.wohnzimmer_activities 
      option: power_off
    style:
      color: |
        {% if is_state("select.wohnzimmer_activities", "Fernsehen") %}
          var(--black)          
        {% endif %}        
      background: |
        {% if is_state("select.wohnzimmer_activities", "Fernsehen") %}
          var(--red) 
        {% elif is_state("select.wohnzimmer_activities", "power_off") %}
          var(--green)                      
        {% endif %}  
  menu:
    icon: mdi:menu
    service: remote.send_command
    service_data:
      device: 26195962
      command: Menu   
      entity_id: remote.wohnzimmer     
  channelup: 
    icon: mdi:arrow-up-circle
    service: remote.send_command
    service_data:
      device: 26195962
      command: ChannelUp    
      entity_id: remote.wohnzimmer 
  channeldown: 
    icon: mdi:arrow-down-circle
    service: remote.send_command
    service_data:
      device: 26195962
      command: ChannelDown  
      entity_id: remote.wohnzimmer        
  yellow:
    entity: remote.wohnzimmer
    icon: mdi:circle
    service: remote.send_command
    service_data:  
      device: 26195962
      command: Yellow 
      entity_id: remote.wohnzimmer 
    style:       
      border-radius: 22px
      background: var(--contrast3)
      color: var(--yellow) 
      height: 40px  
      '--size': 25px     
      width: 75px          
  blue:
    entity: remote.wohnzimmer
    icon: mdi:circle
    service: remote.send_command
    service_data:  
      device: 26195962
      command: Blue 
      entity_id: remote.wohnzimmer 
    style:       
      border-radius: 22px
      background: var(--contrast3)
      color: var(--blue) 
      height: 40px
      '--size': 25px  
      width: 75px                        
  red:
    entity: remote.wohnzimmer
    icon: mdi:circle
    service: remote.send_command
    service_data:  
      device: 26195962
      command: Red
      entity_id: remote.wohnzimmer 
    style:       
      border-radius: 22px
      background: var(--contrast3)
      color: var(--red) 
      height: 40px       
      '--size': 25px   
      width: 75px                
  green:
    entity: remote.wohnzimmer
    icon: mdi:circle
    service: remote.send_command
    service_data:  
      device: 26195962
      command: Green
      entity_id: remote.wohnzimmer 
    style:       
      border-radius: 22px
      background: var(--contrast3)
      color: var(--green)    
      height: 40px    
      '--size': 25px  
      width: 75px                    
  up:
    icon: mdi:arrow-up-bold
    service: remote.send_command
    entity: remote.wohnzimmer
    service_data:    
      device: 26195962
      command: DirectionUp
      entity_id: remote.wohnzimmer
  right:
    icon: mdi:arrow-right-bold
    service: remote.send_command
    service_data:
      device: 26195962
      command: DirectionRight
      entity_id: remote.wohnzimmer
  left:
    icon: mdi:arrow-left-bold
    service: remote.send_command
    service_data:
      device: 26195962
      command: DirectionLeft
      entity_id: remote.wohnzimmer
  down:
    icon: mdi:arrow-down-bold
    service: remote.send_command
    service_data:
      device: 26195962
      command: DirectionDown   
      entity_id: remote.wohnzimmer
  center:
    icon: mdi:circle-outline
    service: remote.send_command
    service_data:
      device: 26195962
      command: OK       
      entity_id: remote.wohnzimmer
  exit:    
    icon: mdi:keyboard-return
    service: remote.send_command
    service_data:        
      device: 26195962
      command: Exit    
      entity_id: remote.wohnzimmer    
2 Likes

Not sure what a TV hotbar is

essentially on the Sony Bravia TV remote there’s a button (gear icon) that when pressed displays a small bar on the bottom of the TV with some pre-configured options (to quickly switch picture / audio modes, change brightness but also to just turn off the screen). I guess it’s just a collection of specific functions that are in the main settings as well, but just presented to you in an easier accessible way.

Unfortunately I’m out of my depth to even begin trying to find out how to figure out how that command is being sent to the TV

You should look into the Sony Bravia TV Home Assistant integration and see if it does what you need. If not you could also look into a smart IR remote like a Broadlink (which I personally use for TV and AV receiver controls) to learn and send IR and RF remote commands.

Right you are, in the log I found that “PictureOff” corresponds to the key command to turn off the screen. Tried it via Developer Tools → Service Calls → Remote:Send command and it works.

Now I’m trying to integrate into the custom card, but am struggling to correctly define th custom key. Could me out how to do it properly?

Here’s how the service call that works in developer tools looks like

service: remote.send_command
target:
  entity_id:
    - remote.sony_bravia_tv
  device_id: []
  area_id: []
data:
  command: PictureOff

trying to implement it like this in the custom card:

type: custom:android-tv-card
remote_id: remote.sony_xr_65a83j
slider_id: media_player.sony_bravia_tv
keyboard_id: remote.sony_xr_65a83j_adb
title: Fernseher
custom_keys:
  screen_off:
    icon: mdi:selection-remove
    service: remote.send_command
    target:
      entity_id:
        - remote.sony_bravia_tv
      data:
        command: PictureOff
rows:
  - - back
    - power
    - home
    - screen_off

but then I get the following error:
image

I tried to change the remote_id further up in the custom card, and then the command just works, but then I lose the functionality of the other commands you’ve programmed

Your data block is an indent level too deep.

type: custom:android-tv-card
remote_id: remote.sony_xr_65a83j
slider_id: media_player.sony_bravia_tv
keyboard_id: remote.sony_xr_65a83j_adb
title: Fernseher
custom_keys:
  screen_off:
    icon: mdi:selection-remove
    service: remote.send_command
    target:
      entity_id:
        - remote.sony_bravia_tv
    data:
      command: PictureOff
rows:
  - - back
    - power
    - home
    - screen_off

I also have my personal remote in popup controls using browser mod popup cards, card-mod, and layout-card media queries for horizontal and vertical layouts, which is opened via a regular Home Assistant button set to the remote entity.

type: custom:popup-card
card:
  type: custom:layout-card
  cards:
    - type: tile
      entity: media_player.lounge_tv
      icon_tap_action:
        action: toggle
      vertical: false
    - type: custom:android-tv-card
      remote_id: remote.lounge_google_tv
      adb_id: media_player.lounge_google_tv_adb
      custom_keys:
        volume_down:
          service: script.amplifier_volume_down
        volume_mute:
          service: script.amplifier_volume_mute
        volume_up:
          service: script.amplifier_volume_up
      alt_volume_icons: true
      rows:
        - - - - back
              - null
              - home
              - null
              - menu
            - - volume_down
              - null
              - volume_mute
              - null
              - volume_up
            - - rewind
              - null
              - play_pause
              - null
              - fast_forward
            - - netflix
              - disney
              - hulu
              - max
              - primevideo
            - - plex
              - vudu
              - youtube
              - spotify
          - - - keyboard
              - search
            - - navigation_touchpad
      touchpad_height: 325px
      view_layout:
        show:
          mediaquery: '(orientation: landscape)'
      card_mod:
        style: |
          ha-card {
            padding: 0 !important;
          }
    - type: custom:android-tv-card
      remote_id: remote.lounge_google_tv
      adb_id: media_player.lounge_google_tv_adb
      alt_volume_icons: true
      custom_keys:
        volume_down:
          service: script.amplifier_volume_down
        volume_mute:
          service: script.amplifier_volume_mute
        volume_up:
          service: script.amplifier_volume_up
      touchpad_height: 340px
      rows:
        - - back
          - home
          - play_pause
        - - keyboard
          - search
        - - volume_buttons
        - - navigation_touchpad
      view_layout:
        show:
          mediaquery: '(orientation: portrait)'
      card_mod:
        style: |
          ha-card {
            padding: 0 !important;
          }
  layout_type: custom:grid-layout
entity: remote.lounge_google_tv
size: fullscreen
dismissable: true
card_mod:
  style:
    .: |
      div.content {
        height: fit-content !important;
      }
    ha-dialog$: |
      .mdc-dialog__surface {
        border-radius: var(--ha-card-border-radius) !important;        
      }
      .mdc-dialog__container {
        flex-direction: column !important;
      }
      .mdc-dialog {
        --mdc-dialog-min-width: 95vw !important;
        --mdc-dialog-min-height: fit-content !important;
      }


2 Likes

Version 3.2.0 has just been released! This version changes custom action syntax to follow the Home Assistant actions format, and adds support for remappable double tap and hold actions for custom buttons. The following action types are now supported:

  • key
  • source
  • call-service
  • navigate
  • url

I’ve also refactored and improved how double taps, holds, and touchpad swipes are processed so they now work on all platforms! You can use them on any chromium based or Firefox desktop browser, and the Home Assistant apps on Android and iPhone.

This release does deprecate a few fields related to remapping touchpad actions and changes the format of custom actions (formerly custom keys and sources), but old configurations should continue to work and get internally upgraded to work with the refactored tap/double tap/hold action logic.

1 Like

Hi, I am looking to use the commands learned via Broadlink RM4 mini, however, it is not working. I have already tested the commands and they work via script. Is it possible to use this custom card together with the learned commands?

type: custom:android-tv-card
        title: TV Box
        custom_keys:
          power:
            service: remote.send_command
            target:
              entity_id: remote.control_universal_master
            data:
              device: TVBox_fision
              command:
                - power
          channel_up:
            service: remote.send_command
            target:
              entity_id: remote.control_universal_master
            data:
              device: TVBox_fision
              command:
                - channel_up
          channel_down:
            service: remote.send_command
            target:
              entity_id: remote.control_universal_master
            data:
              device: TVBox_fision
              command:
                - channel_down
          volume_up:
          volume_down:
          info:
          menu:
          back:
          guide:
        rows:
          - - power
          - - back
            - home
            - tv
            - netflix
          - - youtube
            - spotify
            - netflix
          - - touchpad
          - - slider
          - - channel_up
            - channel_down
            - info
          - - rewind
            - play
            - spotify
            - pause
            - fast_forward

It should work the way you have it listed there yeah. I just tried it with some of my Broadlink IR commands and they worked fine when the service calls were defined in custom actions (I define all my IR remote actions in scripts and call those, which lets me run them in parallel mode with a max of 2 runs, which I’ve found works best for repeated IR commands speed and preventing overshooting too much). I’m not sure why it wouldn’t work for you. Are you seeing any errors in the Home Assistant logs?

1 Like

thanks for your quick response! i was able to solve it, the error was that i had forgotten to change the name of the entity, i was not calling it by its new name, but by the old one. :rofl: :joy:

2 Likes

Hey stop developing this further, you are now breaking all my old remote designs! :rofl: :rofl:

Just kidding man, this is all too awesome. Thanks for the great work! This totally rocks!

I think I will use your remote for things other than android TV! Like lights, fans, curtains etc.

1 Like

While you are joking, old remote configs should get internally upgraded and should continue to work. If you found that a new version does break old remote configs and there isn’t a breaking change section in the GitHub release notes, let me know for real!

1 Like

Thanks for your great work! I was able to create a decent remote without too much hassle.
I was wondering if it’s possible to have a numpad (or buttons) to sent channel numbers. My dutch tv provider kpn is build on the Android tv and does accept channel numbers from Google Home (and some apps on playstore as well). Did i miss something or is it not possible?
Keep it up!

Have you tried using the default keys for the numbers and channel up/down keys?

type: custom:android-tv-card
rows:
  - - n7
    - n8
    - n9
  - - n4
    - n5
    - n6
  - - n1
    - n2
    - n3
  - - channel_up
    - channel_down

image

1 Like

I had the numbers without ‘n’ pasted from somewhere. Now it works perfectly. Thanks a lot, you’re great!
Screenshot of remote for KPN TV+ Android STB. Every button is working.

1 Like