diff --git a/homeassistant/components/snips/__init__.py b/homeassistant/components/snips/__init__.py index 441104211cf233791527432e9ce97f1fd9ddb7e6..93e445e8cedfc7f37cdd6b2ff80450f44fb8770d 100644 --- a/homeassistant/components/snips/__init__.py +++ b/homeassistant/components/snips/__init__.py @@ -135,7 +135,6 @@ async def async_setup(hass, config): intent_type = request["intent"]["intentName"].split("__")[-1] else: intent_type = request["intent"]["intentName"].split(":")[-1] - snips_response = None slots = {} for slot in request.get("slots", []): slots[slot["slotName"]] = {"value": resolve_slot_values(slot)} @@ -148,8 +147,15 @@ async def async_setup(hass, config): intent_response = await intent.async_handle( hass, DOMAIN, intent_type, slots, request["input"] ) + notification = {"sessionId": request.get("sessionId", "default")} + if "plain" in intent_response.speech: - snips_response = intent_response.speech["plain"]["speech"] + notification["text"] = intent_response.speech["plain"]["speech"] + + _LOGGER.debug("send_response %s", json.dumps(notification)) + mqtt.async_publish( + hass, "hermes/dialogueManager/endSession", json.dumps(notification) + ) except intent.UnknownIntent: _LOGGER.warning( "Received unknown intent %s", request["intent"]["intentName"] @@ -157,17 +163,6 @@ async def async_setup(hass, config): except intent.IntentError: _LOGGER.exception("Error while handling intent: %s.", intent_type) - if snips_response: - notification = { - "sessionId": request.get("sessionId", "default"), - "text": snips_response, - } - - _LOGGER.debug("send_response %s", json.dumps(notification)) - mqtt.async_publish( - hass, "hermes/dialogueManager/endSession", json.dumps(notification) - ) - await hass.components.mqtt.async_subscribe(INTENT_TOPIC, message_received) async def snips_say(call):