Virtual Switches & Google Assistant

Hi all,

I’m new here and new to Home Assistant. So please bear with me if I’m missing something obvious. I have about 1 hour of hands-on time with the system so far. :slight_smile:

I have so far gotten some basic stuff to work, secured things enough for now, and gotten some basic things working. By basic things, that means I see most of my Google devices (speakers, etc) and have been able to manually configure/add my TP-Link switches and plugs.

The next thing I want to do is to create some virtual switches that can be accessed via Google Assistant. Can somebody give me some pointers on where to go from here?


What I have (this all works without Home Assistant):

  • TP-Link HS105 plug (“Kitchen Lights”)
  • TP-Link HS105 plug (“Fireplace Lights”)
  • I can say “Hey Google, turn off the Kitchen Lights and turn off the Fireplace Lights” and that works.
  • I can setup a Google Assistant Routine to say, “Hey Google, turn off the downstairs lights” and it works but it responds with a voice prompt of “Okay, turning off the Kitchen Lights. [5 second pause] Okay, turning off the Fireplace Lights.”

What I want (via Home Assistant & Google Assistant working together)

  • Create a new Virtual Switch that groups the above-two switches into a single switch called “Downstairs Lights” (I’ll actually add ~8-10 switches to this group later and don’t want to hear 2 minutes of confirmations!)
  • Use Google Home devices to say “Hey Google, turn off the Downstairs Lights” and it work with a confirmation: “Okay, turning off the Downstairs Lights”.

Can somebody point me in the right direction, please? Thanks!! :slight_smile:

First of all, I would do google assistant integration:

After this, I would make a new light switch, with platform: group:

Than I would expose the created light switch to Google assistant and name it downstair light.

I think it should work.

Thanks @letherwin,

I wasn’t able to do the Light Group as you suggested because, technically, these are switches and not lights, but I managed to figure it out by googling how to do switch groups. Since that’s not really a thing, I instead had to do a switch template. Your info for Google Assistant was exactly what I needed, though!

Here are my relevant bits for my solution:

switch:
#TP-Link Switches
  - platform: tplink
    host: 192.168.1.55
    name: Kitchen Lights
  - platform: tplink
    host: 192.168.1.56
    name: Fireplace Lights
# Custom Switch Groups
  - platform: template
    switches:
      downstairs_lights:
        friendly_name: Downstairs Lights
        # Only say the group is on if *all* lights are on, otherwise show the group as Off.
        value_template: "{{ is_state('switch.kitchen_lights', 'on') and is_state('switch.fireplace_lights', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: 
              - switch.kitchen_lights
              - switch.fireplace_lights
        turn_off:
          service: switch.turn_off
          data:
            entity_id: 
              - switch.kitchen_lights
              - switch.fireplace_lights 
cloud:
  google_actions:
    filter:
      include_entities:
        - switch.downstairs_lights
    entity_config:
      switch.downstairs_lights:
        name: Downstairs Lights
        room: Downstairs

Other things I tried, without success:

  1. Light Group, as you recommended
  2. Standard Groups
  3. Setting them up as Lights and not Switches

In the end, this was the only way I could get it to work, but it now functions perfectly for me. I might try to see if I can tweak the icon that my Google Home Hub displays for this but beyond that, this is about perfect and something I can easily enough replicate for the other scenarios I want to use it for.

Thanks a ton for the help!! :slight_smile: