Home Assistant Unofficial Reference 2024.12.1
homeassistant.helpers.script Namespace Reference

Classes

class  _AbortScript
 
class  _ChooseData
 
class  _ConditionFail
 
class  _HaltScript
 
class  _IfData
 
class  _QueuedScriptRun
 
class  _ScriptRun
 
class  _StopScript
 
class  Script
 
class  ScriptData
 
class  ScriptRunResult
 
class  ScriptStoppedError
 

Functions

None _async_stop_scripts_after_shutdown (HomeAssistant hass, datetime point_in_time)
 
None _async_stop_scripts_at_shutdown (HomeAssistant hass, Event event)
 
None _referenced_extract_ids (Any data, str key, set[str] found)
 
None _schedule_stop_scripts_after_shutdown (HomeAssistant hass)
 
None _set_result_unless_done (asyncio.Future[None] future)
 
TraceElement action_trace_append (dict[str, Any] variables, str path)
 
ConfigType async_validate_action_config (HomeAssistant hass, ConfigType config)
 
list[ConfigType] async_validate_actions_config (HomeAssistant hass, list[ConfigType] actions)
 
None breakpoint_clear (HomeAssistant hass, str key, str|None run_id, str node)
 
None breakpoint_clear_all (HomeAssistant hass)
 
list[dict[str, Any]] breakpoint_list (HomeAssistant hass)
 
None breakpoint_set (HomeAssistant hass, str key, str|None run_id, str node)
 
None debug_continue (HomeAssistant hass, str key, str run_id)
 
None debug_step (HomeAssistant hass, str key, str run_id)
 
None debug_stop (HomeAssistant hass, str key, str run_id)
 
vol.Schema make_script_schema (Mapping[Any, Any] schema, str default_script_mode, int extra=vol.PREVENT_EXTRA)
 
AsyncGenerator[TraceElementtrace_action (HomeAssistant hass, _ScriptRun script_run, asyncio.Future[None] stop, dict[str, Any] variables)
 

Variables

int _LOG_EXCEPTION = logging.ERROR + 1
 
 _LOGGER = logging.getLogger(__name__)
 
list _MAX_EXCEEDED_CHOICES = [*LOGSEVERITY, "SILENT"]
 
int _SHUTDOWN_MAX_WAIT = 60
 
string _TIMEOUT_MSG = "Timeout reached, abort script."
 
 _VarsType
 
int ACTION_TRACE_NODE_MAX_LEN = 20
 
string ATTR_CUR = "current"
 
string ATTR_MAX = "max"
 
string CONF_MAX = "max"
 
string CONF_MAX_EXCEEDED = "max_exceeded"
 
 default
 
int DEFAULT_MAX = 10
 
string DEFAULT_MAX_EXCEEDED = "WARNING"
 
string DEFAULT_SCRIPT_MODE = SCRIPT_MODE_SINGLE
 
string NODE_ANY = "*"
 
int REPEAT_TERMINATE_ITERATIONS = 10000
 
int REPEAT_WARN_ITERATIONS = 5000
 
string RUN_ID_ANY = "*"
 
 SCRIPT_BREAKPOINT_HIT = SignalType[str, str, str]("script_breakpoint_hit")
 
string SCRIPT_DEBUG_CONTINUE_ALL = "script_debug_continue_all"
 
list SCRIPT_MODE_CHOICES
 
string SCRIPT_MODE_PARALLEL = "parallel"
 
string SCRIPT_MODE_QUEUED = "queued"
 
string SCRIPT_MODE_RESTART = "restart"
 
string SCRIPT_MODE_SINGLE = "single"
 
tuple STATIC_VALIDATION_ACTION_TYPES
 

Detailed Description

Helpers to execute scripts.

Function Documentation

◆ _async_stop_scripts_after_shutdown()

None homeassistant.helpers.script._async_stop_scripts_after_shutdown ( HomeAssistant  hass,
datetime   point_in_time 
)
private
Stop running Script objects started after shutdown.

Definition at line 1319 of file script.py.

◆ _async_stop_scripts_at_shutdown()

None homeassistant.helpers.script._async_stop_scripts_at_shutdown ( HomeAssistant  hass,
Event  event 
)
private
Stop running Script objects started before shutdown.

Definition at line 1338 of file script.py.

◆ _referenced_extract_ids()

None homeassistant.helpers.script._referenced_extract_ids ( Any  data,
str  key,
set[str]  found 
)
private
Extract referenced IDs.

Definition at line 1361 of file script.py.

◆ _schedule_stop_scripts_after_shutdown()

None homeassistant.helpers.script._schedule_stop_scripts_after_shutdown ( HomeAssistant  hass)
private
Stop running Script objects started after shutdown.

Definition at line 1312 of file script.py.

◆ _set_result_unless_done()

None homeassistant.helpers.script._set_result_unless_done ( asyncio.Future[None]  future)
private
Set result of future unless it is done.

Definition at line 174 of file script.py.

◆ action_trace_append()

TraceElement homeassistant.helpers.script.action_trace_append ( dict[str, Any]  variables,
str  path 
)
Append a TraceElement to trace[path].

Definition at line 180 of file script.py.

◆ async_validate_action_config()

ConfigType homeassistant.helpers.script.async_validate_action_config ( HomeAssistant  hass,
ConfigType   config 
)
Validate config.

Definition at line 307 of file script.py.

◆ async_validate_actions_config()

list[ConfigType] homeassistant.helpers.script.async_validate_actions_config ( HomeAssistant  hass,
list[ConfigType]   actions 
)
Validate a list of actions.

Definition at line 298 of file script.py.

◆ breakpoint_clear()

None homeassistant.helpers.script.breakpoint_clear ( HomeAssistant  hass,
str  key,
str | None  run_id,
str   node 
)
Clear a breakpoint.

Definition at line 2036 of file script.py.

◆ breakpoint_clear_all()

None homeassistant.helpers.script.breakpoint_clear_all ( HomeAssistant  hass)
Clear all breakpoints.

Definition at line 2048 of file script.py.

◆ breakpoint_list()

list[dict[str, Any]] homeassistant.helpers.script.breakpoint_list ( HomeAssistant  hass)
List breakpoints.

Definition at line 2068 of file script.py.

◆ breakpoint_set()

None homeassistant.helpers.script.breakpoint_set ( HomeAssistant  hass,
str  key,
str | None  run_id,
str   node 
)
Set a breakpoint.

Definition at line 2054 of file script.py.

◆ debug_continue()

None homeassistant.helpers.script.debug_continue ( HomeAssistant  hass,
str  key,
str  run_id 
)
Continue execution of a halted script.

Definition at line 2081 of file script.py.

◆ debug_step()

None homeassistant.helpers.script.debug_step ( HomeAssistant  hass,
str  key,
str  run_id 
)
Single step a halted script.

Definition at line 2091 of file script.py.

◆ debug_stop()

None homeassistant.helpers.script.debug_stop ( HomeAssistant  hass,
str  key,
str  run_id 
)
Stop execution of a running or halted script.

Definition at line 2101 of file script.py.

◆ make_script_schema()

vol.Schema homeassistant.helpers.script.make_script_schema ( Mapping[Any, Any]  schema,
str  default_script_mode,
int   extra = vol.PREVENT_EXTRA 
)
Make a schema for a component that uses the script helper.

Definition at line 262 of file script.py.

◆ trace_action()

AsyncGenerator[TraceElement] homeassistant.helpers.script.trace_action ( HomeAssistant  hass,
_ScriptRun  script_run,
asyncio.Future[None]  stop,
dict[str, Any]  variables 
)
Trace action execution.

Definition at line 188 of file script.py.

Variable Documentation

◆ _LOG_EXCEPTION

int homeassistant.helpers.script._LOG_EXCEPTION = logging.ERROR + 1
private

Definition at line 146 of file script.py.

◆ _LOGGER

homeassistant.helpers.script._LOGGER = logging.getLogger(__name__)
private

Definition at line 144 of file script.py.

◆ _MAX_EXCEEDED_CHOICES

list homeassistant.helpers.script._MAX_EXCEEDED_CHOICES = [*LOGSEVERITY, "SILENT"]
private

Definition at line 130 of file script.py.

◆ _SHUTDOWN_MAX_WAIT

int homeassistant.helpers.script._SHUTDOWN_MAX_WAIT = 60
private

Definition at line 149 of file script.py.

◆ _TIMEOUT_MSG

string homeassistant.helpers.script._TIMEOUT_MSG = "Timeout reached, abort script."
private

Definition at line 147 of file script.py.

◆ _VarsType

homeassistant.helpers.script._VarsType
private

Definition at line 1358 of file script.py.

◆ ACTION_TRACE_NODE_MAX_LEN

int homeassistant.helpers.script.ACTION_TRACE_NODE_MAX_LEN = 20

Definition at line 152 of file script.py.

◆ ATTR_CUR

string homeassistant.helpers.script.ATTR_CUR = "current"

Definition at line 133 of file script.py.

◆ ATTR_MAX

string homeassistant.helpers.script.ATTR_MAX = "max"

Definition at line 134 of file script.py.

◆ CONF_MAX

string homeassistant.helpers.script.CONF_MAX = "max"

Definition at line 126 of file script.py.

◆ CONF_MAX_EXCEEDED

string homeassistant.helpers.script.CONF_MAX_EXCEEDED = "max_exceeded"

Definition at line 129 of file script.py.

◆ default

homeassistant.helpers.script.default

Definition at line 160 of file script.py.

◆ DEFAULT_MAX

int homeassistant.helpers.script.DEFAULT_MAX = 10

Definition at line 127 of file script.py.

◆ DEFAULT_MAX_EXCEEDED

string homeassistant.helpers.script.DEFAULT_MAX_EXCEEDED = "WARNING"

Definition at line 131 of file script.py.

◆ DEFAULT_SCRIPT_MODE

string homeassistant.helpers.script.DEFAULT_SCRIPT_MODE = SCRIPT_MODE_SINGLE

Definition at line 124 of file script.py.

◆ NODE_ANY

string homeassistant.helpers.script.NODE_ANY = "*"

Definition at line 142 of file script.py.

◆ REPEAT_TERMINATE_ITERATIONS

int homeassistant.helpers.script.REPEAT_TERMINATE_ITERATIONS = 10000

Definition at line 295 of file script.py.

◆ REPEAT_WARN_ITERATIONS

int homeassistant.helpers.script.REPEAT_WARN_ITERATIONS = 5000

Definition at line 294 of file script.py.

◆ RUN_ID_ANY

string homeassistant.helpers.script.RUN_ID_ANY = "*"

Definition at line 141 of file script.py.

◆ SCRIPT_BREAKPOINT_HIT

homeassistant.helpers.script.SCRIPT_BREAKPOINT_HIT = SignalType[str, str, str]("script_breakpoint_hit")

Definition at line 154 of file script.py.

◆ SCRIPT_DEBUG_CONTINUE_ALL

string homeassistant.helpers.script.SCRIPT_DEBUG_CONTINUE_ALL = "script_debug_continue_all"

Definition at line 158 of file script.py.

◆ SCRIPT_MODE_CHOICES

list homeassistant.helpers.script.SCRIPT_MODE_CHOICES
Initial value:
1 = [
2  SCRIPT_MODE_PARALLEL,
3  SCRIPT_MODE_QUEUED,
4  SCRIPT_MODE_RESTART,
5  SCRIPT_MODE_SINGLE,
6 ]

Definition at line 118 of file script.py.

◆ SCRIPT_MODE_PARALLEL

string homeassistant.helpers.script.SCRIPT_MODE_PARALLEL = "parallel"

Definition at line 114 of file script.py.

◆ SCRIPT_MODE_QUEUED

string homeassistant.helpers.script.SCRIPT_MODE_QUEUED = "queued"

Definition at line 115 of file script.py.

◆ SCRIPT_MODE_RESTART

string homeassistant.helpers.script.SCRIPT_MODE_RESTART = "restart"

Definition at line 116 of file script.py.

◆ SCRIPT_MODE_SINGLE

string homeassistant.helpers.script.SCRIPT_MODE_SINGLE = "single"

Definition at line 117 of file script.py.

◆ STATIC_VALIDATION_ACTION_TYPES

tuple homeassistant.helpers.script.STATIC_VALIDATION_ACTION_TYPES
Initial value:
1 = (
2  cv.SCRIPT_ACTION_ACTIVATE_SCENE,
3  cv.SCRIPT_ACTION_CALL_SERVICE,
4  cv.SCRIPT_ACTION_DELAY,
5  cv.SCRIPT_ACTION_FIRE_EVENT,
6  cv.SCRIPT_ACTION_SET_CONVERSATION_RESPONSE,
7  cv.SCRIPT_ACTION_STOP,
8  cv.SCRIPT_ACTION_VARIABLES,
9  cv.SCRIPT_ACTION_WAIT_TEMPLATE,
10 )

Definition at line 283 of file script.py.