mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Fix for Snips platform update that breaks hermes api. (#21443)
This commit is contained in:
parent
29187795a8
commit
dc6fd780a9
@ -105,10 +105,10 @@ async def async_setup(hass, config):
|
|||||||
_LOGGER.error('Received invalid JSON: %s', payload)
|
_LOGGER.error('Received invalid JSON: %s', payload)
|
||||||
return
|
return
|
||||||
|
|
||||||
if (request['intent']['probability']
|
if (request['intent']['confidenceScore']
|
||||||
< config[DOMAIN].get(CONF_PROBABILITY)):
|
< config[DOMAIN].get(CONF_PROBABILITY)):
|
||||||
_LOGGER.warning("Intent below probaility threshold %s < %s",
|
_LOGGER.warning("Intent below probaility threshold %s < %s",
|
||||||
request['intent']['probability'],
|
request['intent']['confidenceScore'],
|
||||||
config[DOMAIN].get(CONF_PROBABILITY))
|
config[DOMAIN].get(CONF_PROBABILITY))
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ async def async_setup(hass, config):
|
|||||||
'value': slot['rawValue']}
|
'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['session_id'] = {'value': request.get('sessionId')}
|
||||||
slots['probability'] = {'value': request['intent']['probability']}
|
slots['confidenceScore'] = {'value': request['intent']['confidenceScore']}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
intent_response = await intent.async_handle(
|
intent_response = await intent.async_handle(
|
||||||
|
@ -113,7 +113,7 @@ async def test_snips_intent(hass):
|
|||||||
"input": "turn the lights green",
|
"input": "turn the lights green",
|
||||||
"intent": {
|
"intent": {
|
||||||
"intentName": "Lights",
|
"intentName": "Lights",
|
||||||
"probability": 1
|
"confidenceScore": 1
|
||||||
},
|
},
|
||||||
"slots": [
|
"slots": [
|
||||||
{
|
{
|
||||||
@ -140,7 +140,7 @@ async def test_snips_intent(hass):
|
|||||||
assert intent
|
assert intent
|
||||||
assert intent.slots == {'light_color': {'value': 'green'},
|
assert intent.slots == {'light_color': {'value': 'green'},
|
||||||
'light_color_raw': {'value': 'green'},
|
'light_color_raw': {'value': 'green'},
|
||||||
'probability': {'value': 1},
|
'confidenceScore': {'value': 1},
|
||||||
'site_id': {'value': 'default'},
|
'site_id': {'value': 'default'},
|
||||||
'session_id': {'value': '1234567890ABCDEF'}}
|
'session_id': {'value': '1234567890ABCDEF'}}
|
||||||
assert intent.text_input == 'turn the lights green'
|
assert intent.text_input == 'turn the lights green'
|
||||||
@ -161,7 +161,7 @@ async def test_snips_service_intent(hass):
|
|||||||
"input": "turn the light on",
|
"input": "turn the light on",
|
||||||
"intent": {
|
"intent": {
|
||||||
"intentName": "Lights",
|
"intentName": "Lights",
|
||||||
"probability": 0.85
|
"confidenceScore": 0.85
|
||||||
},
|
},
|
||||||
"siteId": "default",
|
"siteId": "default",
|
||||||
"slots": [
|
"slots": [
|
||||||
@ -188,7 +188,7 @@ async def test_snips_service_intent(hass):
|
|||||||
assert calls[0].domain == 'light'
|
assert calls[0].domain == 'light'
|
||||||
assert calls[0].service == 'turn_on'
|
assert calls[0].service == 'turn_on'
|
||||||
assert calls[0].data['entity_id'] == 'light.kitchen'
|
assert calls[0].data['entity_id'] == 'light.kitchen'
|
||||||
assert 'probability' not in calls[0].data
|
assert 'confidenceScore' not in calls[0].data
|
||||||
assert 'site_id' not in calls[0].data
|
assert 'site_id' not in calls[0].data
|
||||||
|
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ async def test_snips_intent_with_duration(hass):
|
|||||||
"input": "set a timer of five minutes",
|
"input": "set a timer of five minutes",
|
||||||
"intent": {
|
"intent": {
|
||||||
"intentName": "SetTimer",
|
"intentName": "SetTimer",
|
||||||
"probability": 1
|
"confidenceScore": 1
|
||||||
},
|
},
|
||||||
"slots": [
|
"slots": [
|
||||||
{
|
{
|
||||||
@ -241,7 +241,7 @@ async def test_snips_intent_with_duration(hass):
|
|||||||
intent = intents[0]
|
intent = intents[0]
|
||||||
assert intent.platform == 'snips'
|
assert intent.platform == 'snips'
|
||||||
assert intent.intent_type == 'SetTimer'
|
assert intent.intent_type == 'SetTimer'
|
||||||
assert intent.slots == {'probability': {'value': 1},
|
assert intent.slots == {'confidenceScore': {'value': 1},
|
||||||
'site_id': {'value': None},
|
'site_id': {'value': None},
|
||||||
'session_id': {'value': None},
|
'session_id': {'value': None},
|
||||||
'timer_duration': {'value': 300},
|
'timer_duration': {'value': 300},
|
||||||
@ -274,7 +274,7 @@ async def test_intent_speech_response(hass):
|
|||||||
"sessionId": "abcdef0123456789",
|
"sessionId": "abcdef0123456789",
|
||||||
"intent": {
|
"intent": {
|
||||||
"intentName": "spokenIntent",
|
"intentName": "spokenIntent",
|
||||||
"probability": 1
|
"confidenceScore": 1
|
||||||
},
|
},
|
||||||
"slots": []
|
"slots": []
|
||||||
}
|
}
|
||||||
@ -306,7 +306,7 @@ async def test_unknown_intent(hass, caplog):
|
|||||||
"sessionId": "abcdef1234567890",
|
"sessionId": "abcdef1234567890",
|
||||||
"intent": {
|
"intent": {
|
||||||
"intentName": "unknownIntent",
|
"intentName": "unknownIntent",
|
||||||
"probability": 1
|
"confidenceScore": 1
|
||||||
},
|
},
|
||||||
"slots": []
|
"slots": []
|
||||||
}
|
}
|
||||||
@ -330,7 +330,7 @@ async def test_snips_intent_user(hass):
|
|||||||
"input": "what to do",
|
"input": "what to do",
|
||||||
"intent": {
|
"intent": {
|
||||||
"intentName": "user_ABCDEF123__Lights",
|
"intentName": "user_ABCDEF123__Lights",
|
||||||
"probability": 1
|
"confidenceScore": 1
|
||||||
},
|
},
|
||||||
"slots": []
|
"slots": []
|
||||||
}
|
}
|
||||||
@ -359,7 +359,7 @@ async def test_snips_intent_username(hass):
|
|||||||
"input": "what to do",
|
"input": "what to do",
|
||||||
"intent": {
|
"intent": {
|
||||||
"intentName": "username:Lights",
|
"intentName": "username:Lights",
|
||||||
"probability": 1
|
"confidenceScore": 1
|
||||||
},
|
},
|
||||||
"slots": []
|
"slots": []
|
||||||
}
|
}
|
||||||
@ -391,7 +391,7 @@ async def test_snips_low_probability(hass, caplog):
|
|||||||
"input": "I am not sure what to say",
|
"input": "I am not sure what to say",
|
||||||
"intent": {
|
"intent": {
|
||||||
"intentName": "LightsMaybe",
|
"intentName": "LightsMaybe",
|
||||||
"probability": 0.49
|
"confidenceScore": 0.49
|
||||||
},
|
},
|
||||||
"slots": []
|
"slots": []
|
||||||
}
|
}
|
||||||
@ -419,7 +419,7 @@ async def test_intent_special_slots(hass):
|
|||||||
"action": {
|
"action": {
|
||||||
"service": "light.turn_on",
|
"service": "light.turn_on",
|
||||||
"data_template": {
|
"data_template": {
|
||||||
"probability": "{{ probability }}",
|
"confidenceScore": "{{ confidenceScore }}",
|
||||||
"site_id": "{{ site_id }}"
|
"site_id": "{{ site_id }}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -432,7 +432,7 @@ async def test_intent_special_slots(hass):
|
|||||||
"input": "turn the light on",
|
"input": "turn the light on",
|
||||||
"intent": {
|
"intent": {
|
||||||
"intentName": "Lights",
|
"intentName": "Lights",
|
||||||
"probability": 0.85
|
"confidenceScore": 0.85
|
||||||
},
|
},
|
||||||
"siteId": "default",
|
"siteId": "default",
|
||||||
"slots": []
|
"slots": []
|
||||||
@ -444,7 +444,7 @@ async def test_intent_special_slots(hass):
|
|||||||
assert len(calls) == 1
|
assert len(calls) == 1
|
||||||
assert calls[0].domain == 'light'
|
assert calls[0].domain == 'light'
|
||||||
assert calls[0].service == 'turn_on'
|
assert calls[0].service == 'turn_on'
|
||||||
assert calls[0].data['probability'] == '0.85'
|
assert calls[0].data['confidenceScore'] == '0.85'
|
||||||
assert calls[0].data['site_id'] == 'default'
|
assert calls[0].data['site_id'] == 'default'
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user