From 25671a2e42781c445cfdd79dcb4fc1a09529667c Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Mon, 16 Oct 2023 19:13:26 -0500 Subject: [PATCH] Add HassNevermind intent (bump intents package) (#102131) * Add HassNevermind intent * Bump intents package to 2023.10.16 --- .../components/conversation/manifest.json | 2 +- homeassistant/components/intent/__init__.py | 14 ++++++++++++++ homeassistant/helpers/intent.py | 1 + homeassistant/package_constraints.txt | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- .../components/conversation/test_default_agent.py | 10 ++++++++++ 7 files changed, 29 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/conversation/manifest.json b/homeassistant/components/conversation/manifest.json index f11dda15a4e975..1b4d346082af60 100644 --- a/homeassistant/components/conversation/manifest.json +++ b/homeassistant/components/conversation/manifest.json @@ -7,5 +7,5 @@ "integration_type": "system", "iot_class": "local_push", "quality_scale": "internal", - "requirements": ["hassil==1.2.5", "home-assistant-intents==2023.10.2"] + "requirements": ["hassil==1.2.5", "home-assistant-intents==2023.10.16"] } diff --git a/homeassistant/components/intent/__init__.py b/homeassistant/components/intent/__init__.py index b2c77fed3af135..5d3a2259bed002 100644 --- a/homeassistant/components/intent/__init__.py +++ b/homeassistant/components/intent/__init__.py @@ -56,6 +56,10 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: hass, GetStateIntentHandler(), ) + intent.async_register( + hass, + NevermindIntentHandler(), + ) return True @@ -206,6 +210,16 @@ async def async_handle(self, intent_obj: intent.Intent) -> intent.IntentResponse return response +class NevermindIntentHandler(intent.IntentHandler): + """Takes no action.""" + + intent_type = intent.INTENT_NEVERMIND + + async def async_handle(self, intent_obj: intent.Intent) -> intent.IntentResponse: + """Doe not do anything, and produces an empty response.""" + return intent_obj.create_response() + + async def _async_process_intent(hass: HomeAssistant, domain: str, platform): """Process the intents of an integration.""" await platform.async_setup_intents(hass) diff --git a/homeassistant/helpers/intent.py b/homeassistant/helpers/intent.py index f27cea8dd1e6f0..056f972e7f7307 100644 --- a/homeassistant/helpers/intent.py +++ b/homeassistant/helpers/intent.py @@ -31,6 +31,7 @@ INTENT_TURN_ON = "HassTurnOn" INTENT_TOGGLE = "HassToggle" INTENT_GET_STATE = "HassGetState" +INTENT_NEVERMIND = "HassNevermind" SLOT_SCHEMA = vol.Schema({}, extra=vol.ALLOW_EXTRA) diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index db9e6fd99139c6..e1ec8425630a23 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -23,7 +23,7 @@ hass-nabucasa==0.73.0 hassil==1.2.5 home-assistant-bluetooth==1.10.3 home-assistant-frontend==20231005.0 -home-assistant-intents==2023.10.2 +home-assistant-intents==2023.10.16 httpx==0.25.0 ifaddr==0.2.0 janus==1.0.0 diff --git a/requirements_all.txt b/requirements_all.txt index 64b489d7f4c00d..f9149efab11905 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1009,7 +1009,7 @@ holidays==0.28 home-assistant-frontend==20231005.0 # homeassistant.components.conversation -home-assistant-intents==2023.10.2 +home-assistant-intents==2023.10.16 # homeassistant.components.home_connect homeconnect==0.7.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index cf1dbf4f2cb472..19eab9c0488f35 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -798,7 +798,7 @@ holidays==0.28 home-assistant-frontend==20231005.0 # homeassistant.components.conversation -home-assistant-intents==2023.10.2 +home-assistant-intents==2023.10.16 # homeassistant.components.home_connect homeconnect==0.7.2 diff --git a/tests/components/conversation/test_default_agent.py b/tests/components/conversation/test_default_agent.py index 1677b254ff6a90..c75c96ca59bc95 100644 --- a/tests/components/conversation/test_default_agent.py +++ b/tests/components/conversation/test_default_agent.py @@ -283,3 +283,13 @@ async def test_shopping_list_add_item( assert result.response.speech == { "plain": {"speech": "Added apples", "extra_data": None} } + + +async def test_nevermind_item(hass: HomeAssistant, init_components) -> None: + """Test HassNevermind intent through the default agent.""" + result = await conversation.async_converse(hass, "nevermind", None, Context()) + assert result.response.intent is not None + assert result.response.intent.intent_type == intent.INTENT_NEVERMIND + + assert result.response.response_type == intent.IntentResponseType.ACTION_DONE + assert not result.response.speech