Snips: Added special slot values, session_id and slotname_raw (#16185)
* Added special slot values, site_id, session_id, and slotname_raw * Update snips.py
This commit is contained in:
parent
2b0b431a2a
commit
3797b6b012
2 changed files with 16 additions and 4 deletions
|
@ -131,7 +131,10 @@ async def async_setup(hass, config):
|
||||||
slots = {}
|
slots = {}
|
||||||
for slot in request.get('slots', []):
|
for slot in request.get('slots', []):
|
||||||
slots[slot['slotName']] = {'value': resolve_slot_values(slot)}
|
slots[slot['slotName']] = {'value': resolve_slot_values(slot)}
|
||||||
|
slots['{}_raw'.format(slot['slotName'])] = {
|
||||||
|
'value': slot['rawValue']}
|
||||||
slots['site_id'] = {'value': request.get('siteId')}
|
slots['site_id'] = {'value': request.get('siteId')}
|
||||||
|
slots['session_id'] = {'value': request.get('sessionId')}
|
||||||
slots['probability'] = {'value': request['intent']['probability']}
|
slots['probability'] = {'value': request['intent']['probability']}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -93,6 +93,8 @@ async def test_snips_intent(hass, mqtt_mock):
|
||||||
assert result
|
assert result
|
||||||
payload = """
|
payload = """
|
||||||
{
|
{
|
||||||
|
"siteId": "default",
|
||||||
|
"sessionId": "1234567890ABCDEF",
|
||||||
"input": "turn the lights green",
|
"input": "turn the lights green",
|
||||||
"intent": {
|
"intent": {
|
||||||
"intentName": "Lights",
|
"intentName": "Lights",
|
||||||
|
@ -104,7 +106,8 @@ async def test_snips_intent(hass, mqtt_mock):
|
||||||
"value": {
|
"value": {
|
||||||
"kind": "Custom",
|
"kind": "Custom",
|
||||||
"value": "green"
|
"value": "green"
|
||||||
}
|
},
|
||||||
|
"rawValue": "green"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -119,9 +122,12 @@ async def test_snips_intent(hass, mqtt_mock):
|
||||||
intent = intents[0]
|
intent = intents[0]
|
||||||
assert intent.platform == 'snips'
|
assert intent.platform == 'snips'
|
||||||
assert intent.intent_type == 'Lights'
|
assert intent.intent_type == 'Lights'
|
||||||
|
assert intent
|
||||||
assert intent.slots == {'light_color': {'value': 'green'},
|
assert intent.slots == {'light_color': {'value': 'green'},
|
||||||
|
'light_color_raw': {'value': 'green'},
|
||||||
'probability': {'value': 1},
|
'probability': {'value': 1},
|
||||||
'site_id': {'value': None}}
|
'site_id': {'value': 'default'},
|
||||||
|
'session_id': {'value': '1234567890ABCDEF'}}
|
||||||
assert intent.text_input == 'turn the lights green'
|
assert intent.text_input == 'turn the lights green'
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,7 +153,8 @@ async def test_snips_service_intent(hass, mqtt_mock):
|
||||||
"value": {
|
"value": {
|
||||||
"kind": "Custom",
|
"kind": "Custom",
|
||||||
"value": "kitchen"
|
"value": "kitchen"
|
||||||
}
|
},
|
||||||
|
"rawValue": "green"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -217,7 +224,9 @@ async def test_snips_intent_with_duration(hass, mqtt_mock):
|
||||||
assert intent.intent_type == 'SetTimer'
|
assert intent.intent_type == 'SetTimer'
|
||||||
assert intent.slots == {'probability': {'value': 1},
|
assert intent.slots == {'probability': {'value': 1},
|
||||||
'site_id': {'value': None},
|
'site_id': {'value': None},
|
||||||
'timer_duration': {'value': 300}}
|
'session_id': {'value': None},
|
||||||
|
'timer_duration': {'value': 300},
|
||||||
|
'timer_duration_raw': {'value': 'five minutes'}}
|
||||||
|
|
||||||
|
|
||||||
async def test_intent_speech_response(hass, mqtt_mock):
|
async def test_intent_speech_response(hass, mqtt_mock):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue