Skip to content

Commit

Permalink
Add script_mode parameter to custom intent scripts (#102203)
Browse files Browse the repository at this point in the history
* Add script_mode parameter to custom intent scripts

* Reuse CONF_MODE from the script component
  • Loading branch information
tetele authored Nov 9, 2023
1 parent 04e0e2b commit 527a3db
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion homeassistant/components/intent_script/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

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 (
Expand Down Expand Up @@ -43,6 +44,9 @@
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,
Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit 527a3db

Please sign in to comment.