In my quest to replace Alexa, I needed to figure out room aware TV control for Home Assistant. I set this up a long time ago with Alexa, and it mostly worked. In Alexa world, its slow, and not always reliable, but everyone in the house uses it, so it can’t be abandoned. It took me a while to figure out how to parse the custom sentences and identify the HA device spoken to, so I figured I’d post this here to save someone else some time. This particular automation is really proof of concept. It just launches the basic youtube app. I have Nvidia Shield devices on all TVs, so that’s what we use. You can easily adapt this to another streaming box/TV and any app or even specific show/movie you like. The basic concepts can be used to do basically anything that’s not an already built-in intent, with “room awareness”.
alias: Intent - Voice - Launch YouTube on Nvidia Shield
description: ""
triggers:
- trigger: conversation
command:
- Turn on YouTube
- Launch YouTube
- Start YouTube
- Turn on YouTube in the {room}
- Launch YouTube in the {room}
- Start YouTube in the {room}
conditions: []
actions:
- variables:
room: "{{ trigger.slots.room }}"
device_id: "{{ trigger.device_id }}"
- choose:
- conditions:
- condition: template
value_template: "{{ room != '' }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ room == 'living room' }}"
sequence:
- data:
activity: https://www.youtube.com
target:
entity_id: remote.living_room_shield
action: remote.turn_on
- set_conversation_response: I will turn on youtube in the living room.
- conditions:
- condition: template
value_template: "{{ room == 'master bedroom' }}"
sequence:
- data:
activity: https://www.youtube.com
target:
entity_id: remote.mbr_shield
action: remote.turn_on
- set_conversation_response: I will turn on youtube in the Master Bedroom.
- conditions:
- condition: template
value_template: "{{ room == 'office' }}"
sequence:
- data:
activity: https://www.youtube.com
target:
entity_id: remote.basement_main_room_shield
action: remote.turn_on
- set_conversation_response: I will turn on youtube in the office.
default:
- set_conversation_response: I'm sorry, I don't recognize the room {{room}}.
- conditions:
- condition: template
value_template: "{{ room == '' }}"
sequence:
- data:
activity: https://www.youtube.com/
target:
entity_id: |
{% if device_id == 'home_assistant_voice_living_room' %}
remote.living_room_shield
{% elif device_id == '5c90b1fe698a5c92c78741f2537e9656' %}
remote.mbr_shield
{% elif device_id == '51afc4216b493a0d6eb76300da3505c4' %}
remote.basement_main_room_shield
{% else %}
{% endif %}
action: remote.turn_on
- set_conversation_response: I've activated YouTube.