Control Media player with Google Home

i have a webos tv and a google home, i can turn on/off TV with voice command, but other things like change input source, mute, etc… i cant or i dont know the right command, anyone have success with voice commands to do that? if yes, how :grin: ? i tried "set hdmi1 on " "set source … on " , "mute " and nothing work.

Thx.

2 Likes

I don’t think that any of those features will work at this time. Since I wondered the same thing, I examined the code for HA’s cloud integration, and it’s quite clearly mapping media_player components to be seen by Google as ‘Switch’.

DOMAIN_TO_GOOGLE_TYPES = {
climate.DOMAIN: TYPE_THERMOSTAT,
cover.DOMAIN: TYPE_SWITCH,
fan.DOMAIN: TYPE_FAN,
group.DOMAIN: TYPE_SWITCH,
input_boolean.DOMAIN: TYPE_SWITCH,
light.DOMAIN: TYPE_LIGHT,
lock.DOMAIN: TYPE_LOCK,
media_player.DOMAIN: TYPE_SWITCH,
scene.DOMAIN: TYPE_SCENE,
script.DOMAIN: TYPE_SCENE,
switch.DOMAIN: TYPE_SWITCH,
vacuum.DOMAIN: TYPE_VACUUM,
}

I was wondering the same thing about controlling media player attributes through voice commands. Maybe setting routines in the Google Home app to control input-booleans that activate scripts in home assistant?

Have you had any success with this?

I’ve had success with this. I have my TV set up as a media player. I’ve set up routines in Google Home app that toggle a switch, so I can say “Hey Google, BBC Channel”. The switch is an exposed Input_boolean that triggers an automation and sends a ‘media_player.select_source’ command. The downside being that you need to duplicate everything per channel/command. Still, it’s fantastic when you can’t find the remote, which is all the time in my house!!
image

I’m not sure bridging things with a script is necessary, I spent a while fiddling with this and I think all it takes is adding the sources as a list in customize.yaml. My use case is a little different though; I’m controlling a dumb HDMI switcher with an IR remote using a Broadlink RM4 IR/RF bridge. I used a universal media player integration to unify the IR command switches as a single “device”. Then I added a source list to customize.yaml:

media_player.bedroom_monitor:
  source_list:
  - PC
  - Computer
  - Laptop
  - Chromecast
  - Nintendo Switch
  - Aux

The Google Assistant integration is configured like so:

google_assistant:
  expose_by_default: false
  entity_config:
    media_player.bedroom_monitor:
      name: Monitor
      expose: true

Now I can say “Hey Google, change monitor input to ( PC | Computer | Laptop | Chromecast | Nintendo Switch | Aux )” and it does exactly what you’d expect. It’s very finicky about the wording though, if I say “change monitor to” instead of “change monitor input to”, it doesn’t work. Saying “set” instead of “change” works, but I’m still trying to find where all the vocabulary is documented or just spend some time experimenting more.

I’d expect that your Bravia media_player entity would work in much the same way, so long as the names you add in customize.yaml are valid sources for the Bravia. If it doesn’t work, or you want to set custom names, you could try the universal player:

  - platform: universal
    name: Bedroom Monitor
    commands:
      turn_on:
        service: switch.turn_on
        data:
          entity_id: switch.rm4_pro_hdmi_switch_power
      turn_off:
        service: switch.turn_off
        data:
          entity_id: switch.rm4_pro_hdmi_switch_power
      select_source:
        service: switch.turn_on
        data_template:
          entity_id: >
            {% if source == "1" or source == "Aux"  or source == "Laptop" %} switch.rm4_pro_hdmi_switch_source_1
            {% elif source == "2" or source == "Chromecast" %} switch.rm4_pro_hdmi_switch_source_2
            {% elif source == "3" or source == "Switch" %} switch.rm4_pro_hdmi_switch_source_3
            {% elif source == "4" or source == "PC" or source == "Computer" %} switch.rm4_pro_hdmi_switch_source_4
            {% endif %}
1 Like

Thank you very much for sharing this! I’ll give it a go and report back :+1:

It works! I did have to specify the source list in customize.yaml, as you suggested, otherwise the TV would not connect in the Google Home app (I was hoping I could just call any of the sources that show in the media_player integration but that wouldn’t work). Setting the volume to a specific value works fine, as well as just asking to turn up/down.

Thank you very much for taking the time to write your solution Nassau, what an absolute legend!

I’m extremely new to HomeAssistant and YAML. I have the Monoprice 6-Zone Amplifier Integration installed and am in the same boat regarding Google Assistant. All of it’s zones appear as On/Off toggles. Doing the mappings to make the Google Assistant work is well over my head. I would appreciate any guidance that can be given.