This blueprint allows you to easily trigger actions for all of the keypresses that the Emulated Roku integration supports. This is commonly used when integrating with smart remotes (like the Logitech Harmony line).
blueprint:
name: Emulated Roku
description: Create Automations for Emulated Roku Keypresses
domain: automation
input:
emulated_roku_name:
name: Emulated Roku Name
description: The name of the Emulated Roku
selector:
text:
multiline: false
up_action:
name: >
"Up" Button
description: >
Action to run, when the "Up" button is pressed
default: []
selector:
action: {}
right_action:
name: >
"Right" Button
description: >
Action to run, when the "Right" button is pressed
default: []
selector:
action: {}
down_action:
name: >
"Down" Button
description: >
Action to run, when the "Down" button is pressed
default: []
selector:
action: {}
left_action:
name: >
"Left" Button
description: >
Action to run, when the "Left" button is pressed
default: []
selector:
action: {}
home_action:
name: >
"Home" Button
description: >
Action to run, when the "Home" button is pressed
default: []
selector:
action: {}
search_action:
name: >
"Search" Button
description: >
Action to run, when the "Search" button is pressed
default: []
selector:
action: {}
rewind_action:
name: >
"Rewind" Button
description: >
Action to run, when the "Rewind" button is pressed
default: []
selector:
action: {}
forward_action:
name: >
"Forward" Button
description: >
Action to run when the "Forward" button is pressed
default: []
selector:
action: {}
play_action:
name: >
"Play" Button
description: >
Action to run when the "Play" button is pressed
default: []
selector:
action: {}
select_action:
name: >
"Select" Button
description: >
Action to run when the "Select" button is pressed
default: []
selector:
action: {}
back_action:
name: >
"Back" Button
description: >
Action to run when the "Back" button is pressed
default: []
selector:
action: {}
instant_replay_action:
name: >
"InstantReplay" Button
description: >
Action to run when the "InstantReplay" button is pressed
default: []
selector:
action: {}
info_action:
name: >
"Info" Button
description: >
Action to run when the "Info" button is pressed
default: []
selector:
action: {}
back_space_action:
name: >
"BackSpace" Button
description: >
Action to run when the "BackSpace" button is pressed
default: []
selector:
action: {}
enter_action:
name: >
"Enter" Button
description: >
Action to run when the "Enter" button is pressed
default: []
selector:
action: {}
source_url: https://community.home-assistant.io/t/emulated-roku/325451
mode: single
max_exceeded: silent
variables:
emulated_roku_name: !input emulated_roku_name
trigger:
- platform: event
event_type: roku_command
condition:
- condition: template
value_template: '{{ trigger.event.data.source_name == emulated_roku_name }}'
- condition: template
value_template: '{{ trigger.event.data.type == "keypress" }}'
action:
- variables:
key_id: '{{ trigger.event.data.key }}'
- choose:
- conditions: '{{ key_id == "Up" }}'
sequence: !input up_action
- conditions: '{{ key_id == "Right" }}'
sequence: !input right_action
- conditions: '{{ key_id == "Down" }}'
sequence: !input down_action
- conditions: '{{ key_id == "Left" }}'
sequence: !input left_action
- conditions: '{{ key_id == "Home" }}'
sequence: !input home_action
- conditions: '{{ key_id == "Search" }}'
sequence: !input search_action
- conditions: '{{ key_id == "Rev" }}'
sequence: !input rewind_action
- conditions: '{{ key_id == "Fwd" }}'
sequence: !input forward_action
- conditions: '{{ key_id == "Play" }}'
sequence: !input play_action
- conditions: '{{ key_id == "Select" }}'
sequence: !input select_action
- conditions: '{{ key_id == "Back" }}'
sequence: !input back_action
- conditions: '{{ key_id == "InstantReplay" }}'
sequence: !input instant_replay_action
- conditions: '{{ key_id == "Info" }}'
sequence: !input info_action
- conditions: '{{ key_id == "BackSpace" }}'
sequence: !input back_space_action
- conditions: '{{ key_id == "Enter" }}'
sequence: !input enter_action
Thanks for this. I am trying to re-jig this template to also be able to capture and assign the app launch function of the emulated roku (for my new sofabaton). I’ve copied it and changed the bits that I think need changing, but I can’t quite get it to work. Would you be able to look over this and see what I might be doing wrong?
blueprint:
name: Emulated Roku Apps
description: Create Automations for Emulated Roku Apps
domain: automation
input:
emulated_roku_name:
name: Emulated Roku Name
description: The name of the Emulated Roku
selector:
text:
multiline: false
multiple: false
app_id_1:
name: '"App ID 1" Button'
description: 'Action to run, when the "App ID 1" button is pressed'
default: []
selector:
action: {}
app_id_2:
name: '"App ID 2" Button'
description: 'Action to run, when the "App ID 2" button is pressed'
default: []
selector:
action: {}
app_id_3:
name: '"App ID 3" Button'
description: 'Action to run, when the "App ID 3" button is pressed'
default: []
selector:
action: {}
app_id_4:
name: '"App ID 4" Button'
description: 'Action to run, when the "App ID 4" button is pressed'
default: []
selector:
action: {}
app_id_5:
name: '"App ID 5" Button'
description: 'Action to run, when the "App ID 5" button is pressed'
default: []
selector:
action: {}
app_id_6:
name: '"App ID 6" Button'
description: 'Action to run, when the "App ID 6" button is pressed'
default: []
selector:
action: {}
app_id_7:
name: '"App ID 7" Button'
description: 'Action to run, when the "App ID 7" button is pressed'
default: []
selector:
action: {}
app_id_8:
name: '"App ID 8" Button'
description: 'Action to run, when the "App ID 8" button is pressed'
default: []
selector:
action: {}
app_id_9:
name: '"App ID 9" Button'
description: 'Action to run, when the "App ID 9" button is pressed'
default: []
selector:
action: {}
app_id_10:
name: '"App ID 10" Button'
description: 'Action to run, when the "App ID 10" button is pressed'
default: []
selector:
action: {}
app_id_11:
name: '"App ID 11" Button'
description: 'Action to run, when the "App ID 11" button is pressed'
default: []
selector:
action: {}
app_id_12:
name: '"App ID 12" Button'
description: 'Action to run, when the "App ID 12" button is pressed'
default: []
selector:
action: {}
app_id_13:
name: '"App ID 13" Button'
description: 'Action to run, when the "App ID 13" button is pressed'
default: []
selector:
action: {}
app_id_14:
name: '"App ID 14" Button'
description: 'Action to run, when the "App ID 14" button is pressed'
default: []
selector:
action: {}
app_id_15:
name: '"App ID 15" Button'
description: 'Action to run, when the "App ID 15" button is pressed'
default: []
selector:
action: {}
app_id_16:
name: '"App ID 16" Button'
description: 'Action to run, when the "App ID 16" button is pressed'
default: []
selector:
action: {}
app_id_17:
name: '"App ID 17" Button'
description: 'Action to run, when the "App ID 17" button is pressed'
default: []
selector:
action: {}
app_id_18:
name: '"App ID 18" Button'
description: 'Action to run, when the "App ID 18" button is pressed'
default: []
selector:
action: {}
app_id_19:
name: '"App ID 19" Button'
description: 'Action to run, when the "App ID 19" button is pressed'
default: []
selector:
action: {}
app_id_20:
name: '"App ID 20" Button'
description: 'Action to run, when the "App ID 20" button is pressed'
default: []
selector:
action: {}
source_url: https://community.home-assistant.io/t/emulated-roku/325451
mode: single
max_exceeded: silent
variables:
emulated_roku_name: !input emulated_roku_name
trigger:
- platform: event
event_type: roku_command
condition:
- condition: template
value_template: "{{ trigger.event.data.source_name == emulated_roku_name }}"
- condition: template
value_template: '{{ trigger.event.data.type == "launch" }}'
action:
- variables:
key_id: "{{ trigger.event.data.app_id }}"
- choose:
- conditions: '{{ key_id == "1" }}'
sequence: !input app_id_1
- conditions: '{{ key_id == "2" }}'
sequence: !input app_id_2
- conditions: '{{ key_id == "3" }}'
sequence: !input app_id_3
- conditions: '{{ key_id == "4" }}'
sequence: !input app_id_4
- conditions: '{{ key_id == "5" }}'
sequence: !input app_id_5
- conditions: '{{ key_id == "6" }}'
sequence: !input app_id_6
- conditions: '{{ key_id == "7" }}'
sequence: !input app_id_7
- conditions: '{{ key_id == "8" }}'
sequence: !input app_id_8
- conditions: '{{ key_id == "9" }}'
sequence: !input app_id_9
- conditions: '{{ key_id == "10" }}'
sequence: !input app_id_10
- conditions: '{{ key_id == "11" }}'
sequence: !input app_id_11
- conditions: '{{ key_id == "12" }}'
sequence: !input app_id_12
- conditions: '{{ key_id == "13" }}'
sequence: !input app_id_13
- conditions: '{{ key_id == "14" }}'
sequence: !input app_id_14
- conditions: '{{ key_id == "15" }}'
sequence: !input app_id_15
- conditions: '{{ key_id == "16" }}'
sequence: !input app_id_16
- conditions: '{{ key_id == "17" }}'
sequence: !input app_id_17
- conditions: '{{ key_id == "18" }}'
sequence: !input app_id_18
- conditions: '{{ key_id == "19" }}'
sequence: !input app_id_19
- conditions: '{{ key_id == "20" }}'
sequence: !input app_id_20
I have used info in this topic to manually edit the launch app_ids for scripts and scenes around my home. I can do it all manually with an automation and using triggers but that is much harder to maintain and update etc than using a blueprint as I am up to 18 app_ids.
I think one of the problems is the app_id’s that get passed from the roku_command events are presented within quotations, where-as the key presses are not. eg.
event_type: roku_command
data:
source_name: Home Assistant
type: launch
app_id: "8"
origin: LOCAL
time_fired: "2024-06-02T12:08:42.436069+00:00"
context:
id: XXX
parent_id: null
user_id: null
event_type: roku_command
data:
source_name: Home Assistant
type: keypress
key: Info
origin: LOCAL
time_fired: "2024-06-02T12:08:50.355953+00:00"
context:
id: XXX
parent_id: null
user_id: null
Can’t figure out how to get that passed along this blueprint so it calls the correct action.