mirror of
https://github.com/home-assistant/core.git
synced 2025-11-13 21:10:25 +00:00
Intent script: allow setting description and platforms (#118500)
* Add description to intent_script * Allow setting platforms
This commit is contained in:
@@ -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"}}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user