Script: https://github.com/redphx/hassio-cookbook/tree/main/scripts/androidtv_press_buttons
Demo: https://youtu.be/mrJS9Q_toQw
Comparison:
Normal method, painfully slow. You could use “sendevent” commands instead, but the code is still long.
youtube_report_ads:
alias: Report Youtube ads
sequence:
- service: androidtv.adb_command
target:
entity_id: media_player.android_tv
data:
command: PLAY_PAUSE
- service: androidtv.adb_command
target:
entity_id: media_player.android_tv
data:
command: DOWN
- service: androidtv.adb_command
target:
entity_id: media_player.android_tv
data:
command: UP
...
Faster method. Easy to write & understand.
youtube_report_ads:
alias: Report Youtube ads
sequence:
- service: script.android_tv_press_buttons
data:
entity_id: media_player.android_tv_living_room
method: sendevent
buttons:
- PLAY_PAUSE
# Press 4 buttons with minimal delay
- - DOWN
- UP
- UP
- CENTER
# Wait for 1 second
- SLEEP 1
- - DOWN
- DOWN
- DOWN
- CENTER
- SLEEP 0.5
- - UP
- CENTER
- PLAY_PAUSE
Of cource this work on CCwGTV too. Just use method: default
instead.