mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Update snips to listen on new mqtt topic and utilize rawValue (#11020)
* Updated snips to listen on new mqtt topic and use rawValue if value not present in slot * Too late at night * Trying to make minor changes via web * Update test_snips.py * Update __init__.py * Updated wrong branch cause I'm a monkey
This commit is contained in:
parent
4d6070e33a
commit
fed7bd9473
@ -15,7 +15,7 @@ DEPENDENCIES = ['mqtt']
|
||||
CONF_INTENTS = 'intents'
|
||||
CONF_ACTION = 'action'
|
||||
|
||||
INTENT_TOPIC = 'hermes/nlu/intentParsed'
|
||||
INTENT_TOPIC = 'hermes/intent/#'
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -32,7 +32,8 @@ INTENT_SCHEMA = vol.Schema({
|
||||
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 async_setup(hass, config):
|
||||
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(
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user