Use area id for context instead of name (#105313)
This commit is contained in:
parent
1e3c154fdf
commit
d9b31e9841
2 changed files with 10 additions and 4 deletions
|
@ -649,7 +649,7 @@ class DefaultAgent(AbstractConversationAgent):
|
||||||
if device_area is None:
|
if device_area is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return {"area": device_area.name}
|
return {"area": device_area.id}
|
||||||
|
|
||||||
def _get_error_text(
|
def _get_error_text(
|
||||||
self, response_type: ResponseType, lang_intents: LanguageIntents | None
|
self, response_type: ResponseType, lang_intents: LanguageIntents | None
|
||||||
|
|
|
@ -307,8 +307,8 @@ async def test_device_area_context(
|
||||||
turn_on_calls = async_mock_service(hass, "light", "turn_on")
|
turn_on_calls = async_mock_service(hass, "light", "turn_on")
|
||||||
turn_off_calls = async_mock_service(hass, "light", "turn_off")
|
turn_off_calls = async_mock_service(hass, "light", "turn_off")
|
||||||
|
|
||||||
area_kitchen = area_registry.async_get_or_create("kitchen")
|
area_kitchen = area_registry.async_get_or_create("Kitchen")
|
||||||
area_bedroom = area_registry.async_get_or_create("bedroom")
|
area_bedroom = area_registry.async_get_or_create("Bedroom")
|
||||||
|
|
||||||
# Create 2 lights in each area
|
# Create 2 lights in each area
|
||||||
area_lights = defaultdict(list)
|
area_lights = defaultdict(list)
|
||||||
|
@ -323,7 +323,7 @@ async def test_device_area_context(
|
||||||
"off",
|
"off",
|
||||||
attributes={ATTR_FRIENDLY_NAME: f"{area.name} light {i}"},
|
attributes={ATTR_FRIENDLY_NAME: f"{area.name} light {i}"},
|
||||||
)
|
)
|
||||||
area_lights[area.name].append(light_entity)
|
area_lights[area.id].append(light_entity)
|
||||||
|
|
||||||
# Create voice satellites in each area
|
# Create voice satellites in each area
|
||||||
entry = MockConfigEntry()
|
entry = MockConfigEntry()
|
||||||
|
@ -354,6 +354,8 @@ async def test_device_area_context(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result.response.response_type == intent.IntentResponseType.ACTION_DONE
|
assert result.response.response_type == intent.IntentResponseType.ACTION_DONE
|
||||||
|
assert result.response.intent is not None
|
||||||
|
assert result.response.intent.slots["area"]["value"] == area_kitchen.id
|
||||||
|
|
||||||
# Verify only kitchen lights were targeted
|
# Verify only kitchen lights were targeted
|
||||||
assert {s.entity_id for s in result.response.matched_states} == {
|
assert {s.entity_id for s in result.response.matched_states} == {
|
||||||
|
@ -375,6 +377,8 @@ async def test_device_area_context(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result.response.response_type == intent.IntentResponseType.ACTION_DONE
|
assert result.response.response_type == intent.IntentResponseType.ACTION_DONE
|
||||||
|
assert result.response.intent is not None
|
||||||
|
assert result.response.intent.slots["area"]["value"] == area_bedroom.id
|
||||||
|
|
||||||
# Verify only bedroom lights were targeted
|
# Verify only bedroom lights were targeted
|
||||||
assert {s.entity_id for s in result.response.matched_states} == {
|
assert {s.entity_id for s in result.response.matched_states} == {
|
||||||
|
@ -396,6 +400,8 @@ async def test_device_area_context(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result.response.response_type == intent.IntentResponseType.ACTION_DONE
|
assert result.response.response_type == intent.IntentResponseType.ACTION_DONE
|
||||||
|
assert result.response.intent is not None
|
||||||
|
assert result.response.intent.slots["area"]["value"] == area_bedroom.id
|
||||||
|
|
||||||
# Verify only bedroom lights were targeted
|
# Verify only bedroom lights were targeted
|
||||||
assert {s.entity_id for s in result.response.matched_states} == {
|
assert {s.entity_id for s in result.response.matched_states} == {
|
||||||
|
|
Loading…
Add table
Reference in a new issue