mirror of
https://github.com/home-assistant/core.git
synced 2025-04-30 20:27:57 +00:00
Add script_mode parameter to custom intent scripts (#102203)
* Add script_mode parameter to custom intent scripts * Reuse CONF_MODE from the script component
This commit is contained in:
parent
04e0e2bd75
commit
527a3dba9c
@ -6,6 +6,7 @@ from typing import Any, TypedDict
|
|||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.components.script import CONF_MODE
|
||||||
from homeassistant.const import CONF_TYPE, SERVICE_RELOAD
|
from homeassistant.const import CONF_TYPE, SERVICE_RELOAD
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
from homeassistant.helpers import (
|
from homeassistant.helpers import (
|
||||||
@ -43,6 +44,9 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
vol.Optional(
|
vol.Optional(
|
||||||
CONF_ASYNC_ACTION, default=DEFAULT_CONF_ASYNC_ACTION
|
CONF_ASYNC_ACTION, default=DEFAULT_CONF_ASYNC_ACTION
|
||||||
): cv.boolean,
|
): cv.boolean,
|
||||||
|
vol.Optional(CONF_MODE, default=script.DEFAULT_SCRIPT_MODE): vol.In(
|
||||||
|
script.SCRIPT_MODE_CHOICES
|
||||||
|
),
|
||||||
vol.Optional(CONF_CARD): {
|
vol.Optional(CONF_CARD): {
|
||||||
vol.Optional(CONF_TYPE, default="simple"): cv.string,
|
vol.Optional(CONF_TYPE, default="simple"): cv.string,
|
||||||
vol.Required(CONF_TITLE): cv.template,
|
vol.Required(CONF_TITLE): cv.template,
|
||||||
@ -87,8 +91,13 @@ def async_load_intents(hass: HomeAssistant, intents: dict[str, ConfigType]) -> N
|
|||||||
|
|
||||||
for intent_type, conf in intents.items():
|
for intent_type, conf in intents.items():
|
||||||
if CONF_ACTION in conf:
|
if CONF_ACTION in conf:
|
||||||
|
script_mode: str = conf.get(CONF_MODE, script.DEFAULT_SCRIPT_MODE)
|
||||||
conf[CONF_ACTION] = script.Script(
|
conf[CONF_ACTION] = script.Script(
|
||||||
hass, conf[CONF_ACTION], f"Intent Script {intent_type}", DOMAIN
|
hass,
|
||||||
|
conf[CONF_ACTION],
|
||||||
|
f"Intent Script {intent_type}",
|
||||||
|
DOMAIN,
|
||||||
|
script_mode=script_mode,
|
||||||
)
|
)
|
||||||
intent.async_register(hass, ScriptIntentHandler(intent_type, conf))
|
intent.async_register(hass, ScriptIntentHandler(intent_type, conf))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user