Androidtv adb_command and sendevent

Tags: #<Tag:0x00007fc414ead1b8> #<Tag:0x00007fc414eacdf8> #<Tag:0x00007fc414eacc40>

Hi everybody,

this is a two parter, but both related to androidtv and sending adb_commands and/or send_events.

1. Play a stream

I was trying to use this command to play a local stream on VLC.

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -d
  <my_local_stream> -n

This seems to only press the HOME button, as whatever is playing right now stops and I get send to the start page. VLC does not open, no stream gets displayed. The URL is definitely right, as I use it in Home Assistant as well (for camera. entity) and that entity plays the stream just fine. Below is my source_list, so according to it, I changed org.videolan.vlc to VLC, which did not make a difference.

source_list:,,,,,, com.nvidia.blakepairing,, com.nvidia.shieldtech.accessoryui, com.nvidia.shield.remote.server, com.nvidia.osc,,, Homescreen, flar2.homebutton,,, com.nvidia.shield.ask, Google Cast,, com.abrenoch.hyperiongrabber, com.plexapp.mediaserver.smb:sambaserver,,,, YouTube, Play Store,,,,,, VLC, com.nvidia.ota,, com.plexapp.mediaserver.smb, com.nvidia.tegrazone3:PersonalGridService, com.nvidia.tegrazone3:telemetry,, com.nvidia.tegrazone3, Netflix

2. Multiple send_events

Inspired by this reddit post I wanted to create an automation that will skip the current YouTube ad when pushing a zigbee button.

See here;

  1. Call the androidtv.learn_sendevent service.
  2. Within 8 seconds, hit a single button on your Android TV / Fire TV remote.
  3. After 8 seconds, a persistent notification will appear that contains the equivalent command that can be sent via the androidtv.adb_command service.

This will output

Output from service 'learn_sendevent' from media_player.shield: 'sendevent /dev/input/event2 4 4 786498 && sendevent /dev/input/event2 1 103 1 && sendevent /dev/input/event2 3 40 0 && sendevent /dev/input/event2 3 42 1 && sendevent /dev/input/event2 0 0 0 && sendevent /dev/input/event2 4 4 786498 && sendevent /dev/input/event2 1 103 0 && sendevent /dev/input/event2 3 40 1 && sendevent /dev/input/event2 3 42 0 && sendevent /dev/input/event2 0 0 0'

for just pressing the UP button. However, I’d need to quickly do this

  • UP
  • UP

Is there a way to capture all this at once? Or do I need to learn each sendevent seperately and just simply paste them all into a single command to work? Unfortunately, the script I linked above does not work for me, otherwise I would just go with that one, but I thought it’d be nice to write a custom script and just don’t know how to best do this.

I do know how to use the regular UP, ENTER, etc. commands, but if I understand documentation correctly, those cause too much delay and sendevent would be way faster. So obviously I’d prefer that method that requires less time.

Thank you for your ideas :slight_smile:

You should use an IR remote with learn_sendevent service. The output will be much shorter.