Update script helper constructor parameters (#38763)

Add domain and make it and name required.

Add optional running_description.
This commit is contained in:
Phil Bruckner authored and GitHub committed 2020-08-12 11:39:05 -05:00
1 parent fbf44b37a9
commit 716fa63e73
20 files changed
+194 -100

No files matched your search

@@ -147,17 +147,18 @@ class AlarmControlPanelTemplate(AlarmControlPanelEntity):
self._template = state_template
self._disarm_script = None
self._code_arm_required = code_arm_required
domain = __name__.split(".")[-2]
if disarm_action is not None:
self._disarm_script = Script(hass, disarm_action)
self._disarm_script = Script(hass, disarm_action, name, domain)
self._arm_away_script = None
if arm_away_action is not None:
self._arm_away_script = Script(hass, arm_away_action)
self._arm_away_script = Script(hass, arm_away_action, name, domain)
self._arm_home_script = None
if arm_home_action is not None:
self._arm_home_script = Script(hass, arm_home_action)
self._arm_home_script = Script(hass, arm_home_action, name, domain)
self._arm_night_script = None
if arm_night_action is not None:
self._arm_night_script = Script(hass, arm_night_action)
self._arm_night_script = Script(hass, arm_night_action, name, domain)
self._state = None
self._entities = template_entity_ids
+6 -5
View File
@@ -205,20 +205,21 @@ class CoverTemplate(CoverEntity):
self._entity_picture_template = entity_picture_template
self._availability_template = availability_template
self._open_script = None
domain = __name__.split(".")[-2]
if open_action is not None:
self._open_script = Script(hass, open_action)
self._open_script = Script(hass, open_action, friendly_name, domain)
self._close_script = None
if close_action is not None:
self._close_script = Script(hass, close_action)
self._close_script = Script(hass, close_action, friendly_name, domain)
self._stop_script = None
if stop_action is not None:
self._stop_script = Script(hass, stop_action)
self._stop_script = Script(hass, stop_action, friendly_name, domain)
self._position_script = None
if position_action is not None:
self._position_script = Script(hass, position_action)
self._position_script = Script(hass, position_action, friendly_name, domain)
self._tilt_script = None
if tilt_action is not None:
self._tilt_script = Script(hass, tilt_action)
self._tilt_script = Script(hass, tilt_action, friendly_name, domain)
self._optimistic = optimistic or (not state_template and not position_template)
self._tilt_optimistic = tilt_optimistic or not tilt_template
self._icon = None
+13 -5
View File
@@ -176,20 +176,28 @@ class TemplateFan(FanEntity):
self._available = True
self._supported_features = 0
self._on_script = Script(hass, on_action)
self._off_script = Script(hass, off_action)
domain = __name__.split(".")[-2]
self._on_script = Script(hass, on_action, friendly_name, domain)
self._off_script = Script(hass, off_action, friendly_name, domain)
self._set_speed_script = None
if set_speed_action:
self._set_speed_script = Script(hass, set_speed_action)
self._set_speed_script = Script(
hass, set_speed_action, friendly_name, domain
)
self._set_oscillating_script = None
if set_oscillating_action:
self._set_oscillating_script = Script(hass, set_oscillating_action)
self._set_oscillating_script = Script(
hass, set_oscillating_action, friendly_name, domain
)
self._set_direction_script = None
if set_direction_action:
self._set_direction_script = Script(hass, set_direction_action)
self._set_direction_script = Script(
hass, set_direction_action, friendly_name, domain
)
self._state = STATE_OFF
self._speed = None
+11 -6
View File
@@ -186,23 +186,28 @@ class LightTemplate(LightEntity):
self._icon_template = icon_template
self._entity_picture_template = entity_picture_template
self._availability_template = availability_template
self._on_script = Script(hass, on_action)
self._off_script = Script(hass, off_action)
domain = __name__.split(".")[-2]
self._on_script = Script(hass, on_action, friendly_name, domain)
self._off_script = Script(hass, off_action, friendly_name, domain)
self._level_script = None
if level_action is not None:
self._level_script = Script(hass, level_action)
self._level_script = Script(hass, level_action, friendly_name, domain)
self._level_template = level_template
self._temperature_script = None
if temperature_action is not None:
self._temperature_script = Script(hass, temperature_action)
self._temperature_script = Script(
hass, temperature_action, friendly_name, domain
)
self._temperature_template = temperature_template
self._color_script = None
if color_action is not None:
self._color_script = Script(hass, color_action)
self._color_script = Script(hass, color_action, friendly_name, domain)
self._color_template = color_template
self._white_value_script = None
if white_value_action is not None:
self._white_value_script = Script(hass, white_value_action)
self._white_value_script = Script(
hass, white_value_action, friendly_name, domain
)
self._white_value_template = white_value_template
self._state = False
+3 -2
View File
@@ -97,8 +97,9 @@ class TemplateLock(LockEntity):
self._state_template = value_template
self._availability_template = availability_template
self._state_entities = entity_ids
self._command_lock = Script(hass, command_lock)
self._command_unlock = Script(hass, command_unlock)
domain = __name__.split(".")[-2]
self._command_lock = Script(hass, command_lock, name, domain)
self._command_unlock = Script(hass, command_unlock, name, domain)
self._optimistic = optimistic
self._available = True
self._unique_id = unique_id
+3 -2
View File
@@ -126,8 +126,9 @@ class SwitchTemplate(SwitchEntity, RestoreEntity):
)
self._name = friendly_name
self._template = state_template
self._on_script = Script(hass, on_action)
self._off_script = Script(hass, off_action)
domain = __name__.split(".")[-2]
self._on_script = Script(hass, on_action, friendly_name, domain)
self._off_script = Script(hass, off_action, friendly_name, domain)
self._state = False
self._icon_template = icon_template
self._entity_picture_template = entity_picture_template
+15 -7
View File
@@ -195,36 +195,44 @@ class TemplateVacuum(StateVacuumEntity):
self._attribute_templates = attribute_templates
self._attributes = {}
self._start_script = Script(hass, start_action)
domain = __name__.split(".")[-2]
self._start_script = Script(hass, start_action, friendly_name, domain)
self._pause_script = None
if pause_action:
self._pause_script = Script(hass, pause_action)
self._pause_script = Script(hass, pause_action, friendly_name, domain)
self._supported_features |= SUPPORT_PAUSE
self._stop_script = None
if stop_action:
self._stop_script = Script(hass, stop_action)
self._stop_script = Script(hass, stop_action, friendly_name, domain)
self._supported_features |= SUPPORT_STOP
self._return_to_base_script = None
if return_to_base_action:
self._return_to_base_script = Script(hass, return_to_base_action)
self._return_to_base_script = Script(
hass, return_to_base_action, friendly_name, domain
)
self._supported_features |= SUPPORT_RETURN_HOME
self._clean_spot_script = None
if clean_spot_action:
self._clean_spot_script = Script(hass, clean_spot_action)
self._clean_spot_script = Script(
hass, clean_spot_action, friendly_name, domain
)
self._supported_features |= SUPPORT_CLEAN_SPOT
self._locate_script = None
if locate_action:
self._locate_script = Script(hass, locate_action)
self._locate_script = Script(hass, locate_action, friendly_name, domain)
self._supported_features |= SUPPORT_LOCATE
self._set_fan_speed_script = None
if set_fan_speed_action:
self._set_fan_speed_script = Script(hass, set_fan_speed_action)
self._set_fan_speed_script = Script(
hass, set_fan_speed_action, friendly_name, domain
)
self._supported_features |= SUPPORT_FAN_SPEED
self._state = None