Hello there!
I’m having trouble adapting the Chromecast Radio with station and player selection code (to be exact, I followed the tips to split the code from this reply) to use it with ADB and Netflix. The idea is to have two input selects (one for the TV Show and the other for the Android TV streaming device) that are the sources to select the entity_id
and command
in the script.
The script works fine without the template (i.e., hard-coding entity_id
to one device and command
to execute an ADB string), otherwise, when I execute the script, it does nothing (no error in the log, nothing).
At first I tried to debug it with the Developer tools: the Model section returned the right results (apart from the “>” character after entity_id
and command
), but trying to call the Service returned different errors (I later discovered that you cannot use the Service tab with templates…?).
Is there someone who can spot the problem? I thought that it might be feasible to create many different scripts for each pair (TV Show + Streaming device), and filter them with the input selects, but it will result in a lot of (messy) code.
Another “solution” that I thought of is to use Node-RED, but I wanted to try to make it “natively”.
input_select:
tv_program:
name: 'Select TV Show:'
options:
- '24'
- 'Disenchantment'
initial: '24'
icon: mdi:filmstrip-box-multiple
receiver:
name: 'Select receiver:'
options:
- Google TV
- NVIDIA Shield TV
initial: Google TV
icon: mdi:television-classic
script:
tvshow:
alias: Play TV show
sequence:
service: androidtv.adb_command
data_template:
entity_id: >
{%- if is_state("input_select.receiver", "Google TV") %} media_player.google_tv
{%- elif is_state("input_select.receiver", "NVIDIA Shield TV") %} media_player.nvidia_shield_tv
{%- else %} media_player.google_tv
{% endif %}
command: >
{%- if is_state("input_select.tv_program", "24") %} 'am start -n com.netflix.ninja/.MainActivity -a android.intent.action.VIEW -f 0x10000020 -e "amzn_deeplink_data" "70133008"'
{%- elif is_state("input_select.tv_program", "Disenchantment") %} 'am start -n com.netflix.ninja/.MainActivity -a android.intent.action.VIEW -f 0x10000020 -e "amzn_deeplink_data" "80095697"'
{% endif %}