Google assistant not liking groups from HA

Got my google assistant setup last night and it is working pretty good, still have some issue with resync to sort out, my project isn’t listed on the site shown in step 9 but that’s a different time.

I have my 11 devices presented from ha to ga it seems them and I can tell google to control them no problem except for the two groups I have made avaliable. Google sees them but when I say turn on christmas lights it waits then says it cant control that device. Do groups not work or do we need to tweak something?

Thanks in advance.

When you ask GA to turn on a group, is sends a service call turn_on on a group. The domain group do not support turn_on. I googled (some time) on this as well and could not find anything so I settled for a workaround. I create a template switch for each group I want to expose in GA.

Configuration.yaml:

switch:
  - platform: template
    switches:
      living_room:
        value_template: "{{ is_state('group.living_room', 'on') }}"
        turn_on:
          service: homeassistant.turn_on
          data:
            entity_id: group.living_room
        turn_off:
          service: homeassistant.turn_off
          data:
            entity_id: group.living_room

It is also possible to group entities in the Google Home app, but I really wanted to avoid config in there since at least right now there is a lot of linking and unlinking for me.

If anyone have a better solution please speak up.

Thanks will look at that later, its strange because the emulated hue allowed it to work. Must be the way the hue worked I guess.

It looks like the Google Assistant Component has a function called determine_service in smart_home.py to convert the Google Home Command to a Home Assistant command smart_home.py.

It may be possible to add a case for if the entity is a group and the command is turn_on to use set with state on instead.

I was able to get this working automatically for all groups by creating a simple custom component

<path_to_hassio_installation_share>/config/custom_components/google_assistant_group_fix.py

DOMAIN = 'group'

MAPPED_DOMAIN = 'homeassistant'
MAPPED_SERVICE_ON = 'turn_on'
MAPPED_SERVICE_OFF = 'turn_off'

ENTITY_ID_ATTR = 'entity_id'

def setup(hass, config):

    def safe_map_call(call, mapped_service):
        entity_id = call.data.get(ENTITY_ID_ATTR, None)
        if entity_id is not None:
            data = { ENTITY_ID_ATTR: entity_id }
            hass.services.call(MAPPED_DOMAIN, mapped_service, data)

    def handle_turn_on(call):
        safe_map_call(call, MAPPED_SERVICE_ON)

    def handle_turn_off(call):
        safe_map_call(call, MAPPED_SERVICE_OFF)

    hass.services.register(DOMAIN, MAPPED_SERVICE_ON, handle_turn_on)
    hass.services.register(DOMAIN, MAPPED_SERVICE_OFF, handle_turn_off)

    return True

And then in the configuration.yaml you need to add this line:

google_assistant_group_fix:

This basically just registers the turn_on and turn_off services for the group domain and forwards them to the Home Assistant on/off service. It’s pretty hacky, but it does appear to work and doesn’t require customizations for every group you have.

Edit:

  • Fixed spacing issue lost when posting (thanks @pernordlund)
  • As mentioned by @pernordlund below, you also need to add en entry to the customize element to set the google_assistant_type for the group.

For example:

customize:   
    group.living_room_lights:
        google_assistant_type: light
4 Likes

@Khalos Thanks a lot. I was thinking in those lines but never got to it. Now you did. Thanks. For those less experienced you lost 4 spaces in front of the last three line. Also one need to set the property google_assistant_type to something else than group eg light

Is this better then using ROOM in the GH app?

1 Like

You mean ROOM, correct?

Yes @anon35356645 I meant the ROOM functionality. In my opinion using the grouping in Hass is a lot better. You get all your config in Hass. Also, if you for some reason need to unlink your device and GA then you loose all your room-device relations in GA.

But if you never will unlink your account you might be just as well off using the ROOM thing. For some reason (incompetence maybe) I think I have linked and unlinked 15 times already today…

Whole smokes thanks everyone for the great recommendations, I am going to be lazy right now and use the google rooms functions just for time and effort, I don’t make a bunch of changes to my google assistant room setup.

But since my home control is also linked to my Kasa app for TP link I can technically have each switch assigned to 2 different rooms one via Kasa and 1 via google assistant integration which will get me what I need.

Not anymore in 0.58.1 - You can sync any changes and Google Assistant sees them.

2 Likes

This is awesome. Have you submitted a PR for the next release?

Unfortunately I haven’t had a chance to clean it up, set up the dev environment, and integrate it properly into the Google Assistant component yet.

It’s been running fine for a week now, so when I have a chance I may take a crack at doing this properly and submit a PR.

Looks like we’re all good in .59.2!

Awesome! https://github.com/home-assistant/home-assistant/pull/10111 for anyone who’s interested in how it was resolved. Thanks @balloob for the fix :slight_smile:

This appears to turn groups on and off but when I try to set a brightness it says the device is not setup yet.