I’m trying to randomly select a video when I open a youtube playlist on my TV. I have created scripts that run ADB commands to my TV with the up/down/left/right button presses, and I am trying to create a script that calls multiple random button presses so a ‘random’ video is selected each time.
However, it seems that the number of random entries that run are very inconsistent. Most of the times, 3 random presses are executed, sometimes 2, sometimes 1, but never more than 3.
Does anyone know how to solve this?
alias: Random
mode: single
sequence:
- data_template:
entity_id: >
{{ ["script.left", "script.right", "script.up", "script.down"] | random}}
service: script.turn_on
- data_template:
entity_id: >
{{ ["script.left", "script.right", "script.up", "script.down"] | random}}
service: script.turn_on
- data_template:
entity_id: >
{{ ["script.left", "script.right", "script.up", "script.down"] | random}}
service: script.turn_on
- data_template:
entity_id: >
{{ ["script.left", "script.right", "script.up", "script.down"] | random}}
service: script.turn_on
- data_template:
entity_id: >
{{ ["script.left", "script.right", "script.up", "script.down"] | random}}
service: script.turn_on
- data_template:
entity_id: >
{{ ["script.left", "script.right", "script.up", "script.down"] | random}}
service: script.turn_on
Each direction is a script like this (in this instance, script.down):
alias: TV Down
sequence:
- service: androidtv.adb_command
data:
command: >-
sendevent /dev/input/event1 1 100 1 && sendevent /dev/input/event1 1 100 0 && sendevent /dev/input/event1 0 0 0
target:
entity_id: media_player.android_tv_living_room
mode: single