diff --git a/homeassistant/components/snips.py b/homeassistant/components/snips.py index 1f64f78e9c8af6..a302f25bd00363 100644 --- a/homeassistant/components/snips.py +++ b/homeassistant/components/snips.py @@ -15,7 +15,7 @@ CONF_INTENTS = 'intents' CONF_ACTION = 'action' -INTENT_TOPIC = 'hermes/nlu/intentParsed' +INTENT_TOPIC = 'hermes/intent/#' _LOGGER = logging.getLogger(__name__) @@ -32,7 +32,8 @@ vol.Required('slotName'): str, vol.Required('value'): { vol.Required('kind'): str, - vol.Required('value'): cv.match_all + vol.Optional('value'): cv.match_all, + vol.Optional('rawValue'): cv.match_all } }] }, extra=vol.ALLOW_EXTRA) @@ -59,8 +60,12 @@ def message_received(topic, payload, qos): return intent_type = request['intent']['intentName'].split('__')[-1] - slots = {slot['slotName']: {'value': slot['value']['value']} - for slot in request.get('slots', [])} + slots = {} + for slot in request.get('slots', []): + if 'value' in slot['value']: + slots[slot['slotName']] = {'value': slot['value']['value']} + else: + slots[slot['slotName']] = {'value': slot['rawValue']} try: yield from intent.async_handle( diff --git a/tests/components/test_snips.py b/tests/components/test_snips.py index 5e49bbd03827c0..a3e6fac029524c 100644 --- a/tests/components/test_snips.py +++ b/tests/components/test_snips.py @@ -34,7 +34,7 @@ def test_snips_call_action(hass, mqtt_mock): intents = async_mock_intent(hass, 'Lights') - async_fire_mqtt_message(hass, 'hermes/nlu/intentParsed', + async_fire_mqtt_message(hass, 'hermes/intent/activateLights', EXAMPLE_MSG) yield from hass.async_block_till_done() assert len(intents) == 1