Androidtv adb_command and sendevent

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
  org.videolan.vlc/.gui.video.VideoPlayerActivity

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.google.android.katniss:search, com.google.android.katniss:interactor, com.android.systemui, com.google.android.tv.remote.service, com.google.android.gms.persistent, com.google.android.gms, com.nvidia.blakepairing, com.dolby.android.audio.service, com.nvidia.shieldtech.accessoryui, com.nvidia.shield.remote.server, com.nvidia.osc, com.nvidia.app.messaging, com.google.android.leanback.ime, Homescreen, flar2.homebutton, com.google.android.tvrecommendations, com.android.providers.tv, com.nvidia.shield.ask, Google Cast, com.google.android.gms.unstable, com.abrenoch.hyperiongrabber, com.plexapp.mediaserver.smb:sambaserver, de.cyberdream.androidtv.notifications.google, com.google.process.gservices, com.google.android.youtube.tv.recommendations, YouTube, Play Store, com.google.process.gapps, com.android.vending:download_service, com.google.android.videos, com.android.defcontainer, com.android.gallery3d, VLC, com.nvidia.ota, com.google.android.packageinstaller, com.plexapp.mediaserver.smb, com.nvidia.tegrazone3:PersonalGridService, com.nvidia.tegrazone3:telemetry, com.google.android.apps.mediashell:privileged_process2, 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
  • ENTER
  • ENTER
  • ENTER

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.