Intent script: allow setting description and platforms (#118500)

* Add description to intent_script

* Allow setting platforms
This commit is contained in:
Paulus Schoutsen
2024-05-30 12:53:42 -04:00
committed by GitHub
parent 12215c51b3
commit ae3741c364
2 changed files with 29 additions and 1 deletions

View File

@@ -22,6 +22,8 @@ async def test_intent_script(hass: HomeAssistant) -> None:
{
"intent_script": {
"HelloWorld": {
"description": "Intent to control a test service.",
"platforms": ["switch"],
"action": {
"service": "test.service",
"data_template": {"hello": "{{ name }}"},
@@ -36,6 +38,17 @@ async def test_intent_script(hass: HomeAssistant) -> None:
},
)
handlers = [
intent_handler
for intent_handler in intent.async_get(hass)
if intent_handler.intent_type == "HelloWorld"
]
assert len(handlers) == 1
handler = handlers[0]
assert handler.description == "Intent to control a test service."
assert handler.platforms == {"switch"}
response = await intent.async_handle(
hass, "test", "HelloWorld", {"name": {"value": "Paulus"}}
)
@@ -78,6 +91,16 @@ async def test_intent_script_wait_response(hass: HomeAssistant) -> None:
},
)
handlers = [
intent_handler
for intent_handler in intent.async_get(hass)
if intent_handler.intent_type == "HelloWorldWaitResponse"
]
assert len(handlers) == 1
handler = handlers[0]
assert handler.platforms is None
response = await intent.async_handle(
hass, "test", "HelloWorldWaitResponse", {"name": {"value": "Paulus"}}
)