diff --git a/homeassistant/components/google_assistant/http.py b/homeassistant/components/google_assistant/http.py index c339c8a4dc5..a9512404b1e 100644 --- a/homeassistant/components/google_assistant/http.py +++ b/homeassistant/components/google_assistant/http.py @@ -126,23 +126,23 @@ class GoogleAssistantView(HomeAssistantView): commands = [] for command in requested_commands: ent_ids = [ent.get('id') for ent in command.get('devices', [])] - execution = command.get('execution')[0] - for eid in ent_ids: - success = False - domain = eid.split('.')[0] - (service, service_data) = determine_service( - eid, execution.get('command'), execution.get('params'), - hass.config.units) - if domain == "group": - domain = "homeassistant" - success = yield from hass.services.async_call( - domain, service, service_data, blocking=True) - result = {"ids": [eid], "states": {}} - if success: - result['status'] = 'SUCCESS' - else: - result['status'] = 'ERROR' - commands.append(result) + for execution in command.get('execution'): + for eid in ent_ids: + success = False + domain = eid.split('.')[0] + (service, service_data) = determine_service( + eid, execution.get('command'), execution.get('params'), + hass.config.units) + if domain == "group": + domain = "homeassistant" + success = yield from hass.services.async_call( + domain, service, service_data, blocking=True) + result = {"ids": [eid], "states": {}} + if success: + result['status'] = 'SUCCESS' + else: + result['status'] = 'ERROR' + commands.append(result) return self.json( _make_actions_response(request_id, {'commands': commands})) diff --git a/tests/components/google_assistant/test_google_assistant.py b/tests/components/google_assistant/test_google_assistant.py index dba10608991..05178649c88 100644 --- a/tests/components/google_assistant/test_google_assistant.py +++ b/tests/components/google_assistant/test_google_assistant.py @@ -316,8 +316,6 @@ def test_execute_request(hass_fixture, assistant_client): "id": "light.ceiling_lights", }, { "id": "switch.decorative_lights", - }, { - "id": "light.bed_light", }], "execution": [{ "command": "action.devices.commands.OnOff", @@ -350,6 +348,25 @@ def test_execute_request(hass_fixture, assistant_client): } } }] + }, { + "devices": [{ + "id": "light.bed_light" + }], + "execution": [{ + "command": "action.devices.commands.ColorAbsolute", + "params": { + "color": { + "spectrumRGB": 65280 + } + } + }, { + "command": "action.devices.commands.ColorAbsolute", + "params": { + "color": { + "temperature": 4700 + } + } + }] }] } }] @@ -362,10 +379,17 @@ def test_execute_request(hass_fixture, assistant_client): body = yield from result.json() assert body.get('requestId') == reqid commands = body['payload']['commands'] - assert len(commands) == 5 + assert len(commands) == 6 + ceiling = hass_fixture.states.get('light.ceiling_lights') assert ceiling.state == 'off' + kitchen = hass_fixture.states.get('light.kitchen_lights') assert kitchen.attributes.get(light.ATTR_COLOR_TEMP) == 476 assert kitchen.attributes.get(light.ATTR_RGB_COLOR) == (255, 0, 0) + + bed = hass_fixture.states.get('light.bed_light') + assert bed.attributes.get(light.ATTR_COLOR_TEMP) == 212 + assert bed.attributes.get(light.ATTR_RGB_COLOR) == (0, 255, 0) + assert hass_fixture.states.get('switch.decorative_lights').state == 'off'