From 527a3dba9cd3eebd59257f6dd8be0e2ee95c630d Mon Sep 17 00:00:00 2001 From: Tudor Sandu Date: Thu, 9 Nov 2023 14:41:25 -0800 Subject: [PATCH] Add script_mode parameter to custom intent scripts (#102203) * Add script_mode parameter to custom intent scripts * Reuse CONF_MODE from the script component --- homeassistant/components/intent_script/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/intent_script/__init__.py b/homeassistant/components/intent_script/__init__.py index d5bec0573b8..d184dad47c9 100644 --- a/homeassistant/components/intent_script/__init__.py +++ b/homeassistant/components/intent_script/__init__.py @@ -6,6 +6,7 @@ from typing import Any, TypedDict import voluptuous as vol +from homeassistant.components.script import CONF_MODE from homeassistant.const import CONF_TYPE, SERVICE_RELOAD from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.helpers import ( @@ -43,6 +44,9 @@ CONFIG_SCHEMA = vol.Schema( vol.Optional( CONF_ASYNC_ACTION, default=DEFAULT_CONF_ASYNC_ACTION ): cv.boolean, + vol.Optional(CONF_MODE, default=script.DEFAULT_SCRIPT_MODE): vol.In( + script.SCRIPT_MODE_CHOICES + ), vol.Optional(CONF_CARD): { vol.Optional(CONF_TYPE, default="simple"): cv.string, 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(): if CONF_ACTION in conf: + script_mode: str = conf.get(CONF_MODE, script.DEFAULT_SCRIPT_MODE) 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))