Remove purpose-specific triggers and conditions from labs (#174450)

This commit is contained in:
Erik Montnemery
2026-06-22 16:58:51 +01:00
committed by GitHub
parent dad7da0e3b
commit b6b8391cbf
94 changed files with 16 additions and 2721 deletions
+1 -130
View File
@@ -10,9 +10,8 @@ from typing import Any, cast, override
from propcache.api import cached_property
import voluptuous as vol
from homeassistant.components import labs, websocket_api
from homeassistant.components import websocket_api
from homeassistant.components.blueprint import CONF_USE_BLUEPRINT
from homeassistant.components.labs import async_subscribe_preview_feature
from homeassistant.const import (
ATTR_AREA_ID,
ATTR_ENTITY_ID,
@@ -112,121 +111,6 @@ ATTR_SOURCE = "source"
ATTR_VARIABLES = "variables"
SERVICE_TRIGGER = "trigger"
NEW_TRIGGERS_CONDITIONS_FEATURE_FLAG = "new_triggers_conditions"
_EXPERIMENTAL_CONDITION_PLATFORMS = {
"air_quality",
"alarm_control_panel",
"assist_satellite",
"battery",
"calendar",
"climate",
"counter",
"cover",
"device_tracker",
"door",
"fan",
"garage_door",
"gate",
"humidifier",
"humidity",
"illuminance",
"lawn_mower",
"light",
"lock",
"media_player",
"moisture",
"motion",
"occupancy",
"person",
"power",
"remote",
"schedule",
"select",
"siren",
"switch",
"temperature",
"text",
"timer",
"todo",
"update",
"vacuum",
"valve",
"water_heater",
"window",
}
_EXPERIMENTAL_TRIGGER_PLATFORMS = {
"air_quality",
"alarm_control_panel",
"assist_satellite",
"battery",
"button",
"climate",
"counter",
"cover",
"device_tracker",
"door",
"doorbell",
"event",
"fan",
"garage_door",
"gate",
"humidifier",
"humidity",
"illuminance",
"lawn_mower",
"light",
"lock",
"media_player",
"moisture",
"motion",
"occupancy",
"person",
"power",
"remote",
"scene",
"schedule",
"select",
"siren",
"switch",
"temperature",
"text",
"timer",
"todo",
"update",
"vacuum",
"valve",
"water_heater",
"window",
}
@callback
def is_disabled_experimental_condition(hass: HomeAssistant, platform: str) -> bool:
"""Check if the platform is a disabled experimental condition platform."""
return (
platform in _EXPERIMENTAL_CONDITION_PLATFORMS
and not labs.async_is_preview_feature_enabled(
hass,
DOMAIN,
NEW_TRIGGERS_CONDITIONS_FEATURE_FLAG,
)
)
@callback
def is_disabled_experimental_trigger(hass: HomeAssistant, platform: str) -> bool:
"""Check if the platform is a disabled experimental trigger platform."""
return (
platform in _EXPERIMENTAL_TRIGGER_PLATFORMS
and not labs.async_is_preview_feature_enabled(
hass,
DOMAIN,
NEW_TRIGGERS_CONDITIONS_FEATURE_FLAG,
)
)
class IfAction(condition_helper.ConditionsChecker):
"""Define the format of if_action."""
@@ -425,19 +309,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
schema=vol.Schema({vol.Optional(CONF_ID): str}),
)
async def new_triggers_conditions_listener(
_event_data: labs.EventLabsUpdatedData,
) -> None:
"""Handle new_triggers_conditions flag change."""
await reload_helper.execute_service(ServiceCall(hass, DOMAIN, SERVICE_RELOAD))
async_subscribe_preview_feature(
hass,
DOMAIN,
NEW_TRIGGERS_CONDITIONS_FEATURE_FLAG,
new_triggers_conditions_listener,
)
websocket_api.async_register_command(hass, websocket_config)
return True
@@ -6,12 +6,5 @@
"dependencies": ["blueprint", "trace"],
"documentation": "https://www.home-assistant.io/integrations/automation",
"integration_type": "system",
"preview_features": {
"new_triggers_conditions": {
"feedback_url": "https://forms.gle/fWFZqf5MzuwWTsCH8",
"learn_more_url": "https://www.home-assistant.io/blog/2025/12/03/release-202512/#purpose-specific-triggers-and-conditions",
"report_issue_url": "https://github.com/home-assistant/core/issues/new?template=bug_report.yml&integration_link=https://www.home-assistant.io/integrations/automation&integration_name=Automation"
}
},
"quality_scale": "internal"
}
@@ -67,14 +67,6 @@
"title": "[%key:component::automation::common::validation_failed_title%]"
}
},
"preview_features": {
"new_triggers_conditions": {
"description": "Enables new purpose-specific triggers and conditions that are more user-friendly than technical state-based options.\n\nThese new automation features support targets across your entire home, letting you trigger automations for any entity, device, area, floor, or label (for example, when any light in your living room turned on). Integrations can now also provide their own purpose-specific triggers and conditions, just like actions.\n\nThis preview also includes a new tree view to help you navigate your home when adding triggers, conditions, and actions.",
"disable_confirmation": "Disabling this preview will cause automations and scripts that use the new purpose-specific triggers and conditions to fail.\n\nBefore disabling, ensure that your automations or scripts do not rely on this feature.",
"enable_confirmation": "This feature is still in development and may change. These new purpose-specific triggers and conditions are being refined based on user feedback and are not yet complete.\n\nBy enabling this preview, you'll have early access to these new capabilities, but be aware that they may be modified or updated in future releases.",
"name": "Purpose-specific triggers and conditions"
}
},
"services": {
"reload": {
"description": "Reloads the automation configuration.",
+1 -18
View File
@@ -9,12 +9,8 @@ from typing import TYPE_CHECKING, Any, cast
from propcache.api import cached_property
import voluptuous as vol
from homeassistant.components import automation, websocket_api
from homeassistant.components import websocket_api
from homeassistant.components.blueprint import CONF_USE_BLUEPRINT
from homeassistant.components.labs import (
EventLabsUpdatedData,
async_subscribe_preview_feature,
)
from homeassistant.const import (
ATTR_ENTITY_ID,
ATTR_MODE,
@@ -280,19 +276,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
DOMAIN, SERVICE_TOGGLE, toggle_service, schema=SCRIPT_TURN_ONOFF_SCHEMA
)
async def new_triggers_conditions_listener(
_event_data: EventLabsUpdatedData,
) -> None:
"""Handle new_triggers_conditions flag change."""
await reload_service(ServiceCall(hass, DOMAIN, SERVICE_RELOAD))
async_subscribe_preview_feature(
hass,
automation.DOMAIN,
automation.NEW_TRIGGERS_CONDITIONS_FEATURE_FLAG,
new_triggers_conditions_listener,
)
websocket_api.async_register_command(hass, websocket_config)
return True
@@ -6,14 +6,6 @@ import logging
from typing import Any
from homeassistant import config as conf_util
from homeassistant.components.automation import (
DOMAIN as AUTOMATION_DOMAIN,
NEW_TRIGGERS_CONDITIONS_FEATURE_FLAG,
)
from homeassistant.components.labs import (
EventLabsUpdatedData,
async_subscribe_preview_feature,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
CONF_DEVICE_ID,
@@ -91,21 +83,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async_register_admin_service(hass, DOMAIN, SERVICE_RELOAD, _reload_config)
async def _handle_new_triggers_conditions(
_event_data: EventLabsUpdatedData,
) -> None:
"""Handle new_triggers_conditions flag change."""
hass.async_create_task(
_reload_config(ServiceCall(hass, DOMAIN, SERVICE_RELOAD))
)
async_subscribe_preview_feature(
hass,
AUTOMATION_DOMAIN,
NEW_TRIGGERS_CONDITIONS_FEATURE_FLAG,
_handle_new_triggers_conditions,
)
return True
@@ -132,18 +109,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
entry, (entry.options["template_type"],)
)
async def _handle_entry_reload(_event_data: EventLabsUpdatedData) -> None:
hass.config_entries.async_schedule_reload(entry.entry_id)
entry.async_on_unload(
async_subscribe_preview_feature(
hass,
AUTOMATION_DOMAIN,
NEW_TRIGGERS_CONDITIONS_FEATURE_FLAG,
_handle_entry_reload,
)
)
return True
-7
View File
@@ -11,13 +11,6 @@ LABS_PREVIEW_FEATURES = {
"report_issue_url": "https://github.com/OHF-Device-Database/device-database/issues/new",
},
},
"automation": {
"new_triggers_conditions": {
"feedback_url": "https://forms.gle/fWFZqf5MzuwWTsCH8",
"learn_more_url": "https://www.home-assistant.io/blog/2025/12/03/release-202512/#purpose-specific-triggers-and-conditions",
"report_issue_url": "https://github.com/home-assistant/core/issues/new?template=bug_report.yml&integration_link=https://www.home-assistant.io/integrations/automation&integration_name=Automation",
},
},
"frontend": {
"winter_mode": {
"feedback_url": "",
+2 -49
View File
@@ -154,9 +154,6 @@ INPUT_ENTITY_ID = re.compile(
CONDITION_DESCRIPTION_CACHE: HassKey[dict[str, dict[str, Any] | None]] = HassKey(
"condition_description_cache"
)
CONDITION_DISABLED_CONDITIONS: HassKey[set[str]] = HassKey(
"condition_disabled_conditions"
)
CONDITION_PLATFORM_SUBSCRIPTIONS: HassKey[
list[Callable[[set[str]], Coroutine[Any, Any, None]]]
] = HassKey("condition_platform_subscriptions")
@@ -198,29 +195,11 @@ _CONDITIONS_DESCRIPTION_SCHEMA = vol.Schema(
async def async_setup(hass: HomeAssistant) -> None:
"""Set up the condition helper."""
from homeassistant.components import automation, labs # noqa: PLC0415
hass.data[CONDITION_DESCRIPTION_CACHE] = {}
hass.data[CONDITION_DISABLED_CONDITIONS] = set()
hass.data[CONDITION_PLATFORM_SUBSCRIPTIONS] = []
hass.data[CONDITIONS] = {}
hass.data[_DATA_HISTORY_PRIMING_MANAGER] = _HistoryPrimingManager(hass)
async def new_triggers_conditions_listener(
_event_data: labs.EventLabsUpdatedData,
) -> None:
"""Handle new_triggers_conditions flag change."""
# Invalidate the cache
hass.data[CONDITION_DESCRIPTION_CACHE] = {}
hass.data[CONDITION_DISABLED_CONDITIONS] = set()
labs.async_subscribe_preview_feature(
hass,
automation.DOMAIN,
automation.NEW_TRIGGERS_CONDITIONS_FEATURE_FLAG,
new_triggers_conditions_listener,
)
await async_process_integration_platforms(
hass, "condition", _register_condition_platform, wait_for_platforms=True
)
@@ -246,11 +225,9 @@ async def _register_condition_platform(
) -> None:
"""Register a condition platform and notify listeners.
If the condition platform does not provide any conditions, or it is disabled,
If the condition platform does not provide any conditions,
listeners will not be notified.
"""
from homeassistant.components import automation # noqa: PLC0415
new_conditions: set[str] = set()
conditions = hass.data[CONDITIONS]
@@ -277,10 +254,6 @@ async def _register_condition_platform(
)
return
if automation.is_disabled_experimental_condition(hass, integration_domain):
_LOGGER.debug("Conditions for integration %s are disabled", integration_domain)
return
# We don't use gather here because gather adds additional overhead
# when wrapping each coroutine in a task, and we expect our listeners
# to call condition.async_get_all_descriptions which will only yield
@@ -1297,21 +1270,12 @@ def trace_condition_function(
async def _async_get_condition_platform(
hass: HomeAssistant, condition_key: str
) -> tuple[str, ConditionProtocol | None]:
from homeassistant.components import automation # noqa: PLC0415
platform_and_sub_type = condition_key.split(".")
platform: str | None = platform_and_sub_type[0]
platform = _PLATFORM_ALIASES.get(platform, platform)
if platform is None:
return "", None
if automation.is_disabled_experimental_condition(hass, platform):
raise vol.Invalid(
f"Condition '{condition_key}' requires the experimental 'New triggers and "
"conditions' feature to be enabled in Home Assistant Labs settings "
f"(feature flag: '{automation.NEW_TRIGGERS_CONDITIONS_FEATURE_FLAG}')"
)
try:
integration = await async_get_integration(hass, platform)
except IntegrationNotFound:
@@ -2267,8 +2231,6 @@ async def async_get_all_descriptions(
hass: HomeAssistant,
) -> dict[str, dict[str, Any] | None]:
"""Return descriptions (i.e. user documentation) for all conditions."""
from homeassistant.components import automation # noqa: PLC0415
descriptions_cache = hass.data[CONDITION_DESCRIPTION_CACHE]
conditions = hass.data[CONDITIONS]
@@ -2277,12 +2239,7 @@ async def async_get_all_descriptions(
all_conditions = set(conditions)
previous_all_conditions = set(descriptions_cache)
# If the conditions are the same, we can return the cache
# mypy complains: Invalid index type "HassKey[set[str]]" for "HassDict"
if (
previous_all_conditions | hass.data[CONDITION_DISABLED_CONDITIONS] # type: ignore[index]
== all_conditions
):
if previous_all_conditions == all_conditions:
return descriptions_cache
# Files we loaded for missing descriptions
@@ -2322,10 +2279,6 @@ async def async_get_all_descriptions(
new_descriptions_cache = descriptions_cache.copy()
for missing_condition in missing_conditions:
domain = conditions[missing_condition]
if automation.is_disabled_experimental_condition(hass, domain):
hass.data[CONDITION_DISABLED_CONDITIONS].add(missing_condition)
continue
if (
yaml_description := new_conditions_descriptions.get(domain, {}).get(
missing_condition
+2 -44
View File
@@ -112,7 +112,6 @@ DATA_PLUGGABLE_ACTIONS: HassKey[defaultdict[tuple, PluggableActionsEntry]] = Has
TRIGGER_DESCRIPTION_CACHE: HassKey[dict[str, dict[str, Any] | None]] = HassKey(
"trigger_description_cache"
)
TRIGGER_DISABLED_TRIGGERS: HassKey[set[str]] = HassKey("trigger_disabled_triggers")
TRIGGER_PLATFORM_SUBSCRIPTIONS: HassKey[
list[Callable[[set[str]], Coroutine[Any, Any, None]]]
] = HassKey("trigger_platform_subscriptions")
@@ -154,28 +153,10 @@ _TRIGGERS_DESCRIPTION_SCHEMA = vol.Schema(
async def async_setup(hass: HomeAssistant) -> None:
"""Set up the trigger helper."""
from homeassistant.components import automation, labs # noqa: PLC0415
hass.data[TRIGGER_DESCRIPTION_CACHE] = {}
hass.data[TRIGGER_DISABLED_TRIGGERS] = set()
hass.data[TRIGGER_PLATFORM_SUBSCRIPTIONS] = []
hass.data[TRIGGERS] = {}
async def new_triggers_conditions_listener(
_event_data: labs.EventLabsUpdatedData,
) -> None:
"""Handle new_triggers_conditions flag change."""
# Invalidate the cache
hass.data[TRIGGER_DESCRIPTION_CACHE] = {}
hass.data[TRIGGER_DISABLED_TRIGGERS] = set()
labs.async_subscribe_preview_feature(
hass,
automation.DOMAIN,
automation.NEW_TRIGGERS_CONDITIONS_FEATURE_FLAG,
new_triggers_conditions_listener,
)
await async_process_integration_platforms(
hass, "trigger", _register_trigger_platform, wait_for_platforms=True
)
@@ -201,11 +182,9 @@ async def _register_trigger_platform(
) -> None:
"""Register a trigger platform and notify listeners.
If the trigger platform does not provide any triggers, or it is disabled,
If the trigger platform does not provide any triggers,
listeners will not be notified.
"""
from homeassistant.components import automation # noqa: PLC0415
new_triggers: set[str] = set()
triggers = hass.data[TRIGGERS]
@@ -237,10 +216,6 @@ async def _register_trigger_platform(
)
return
if automation.is_disabled_experimental_trigger(hass, integration_domain):
_LOGGER.debug("Triggers for integration %s are disabled", integration_domain)
return
# We don't use gather here because gather adds additional overhead
# when wrapping each coroutine in a task, and we expect our listeners
# to call trigger.async_get_all_descriptions which will only yield
@@ -1484,8 +1459,6 @@ class PluggableAction:
async def _async_get_trigger_platform(
hass: HomeAssistant, trigger_key: str
) -> tuple[str, TriggerProtocol]:
from homeassistant.components import automation # noqa: PLC0415
platform_and_sub_type = trigger_key.split(".")
platform = platform_and_sub_type[0]
# Only apply aliases for old-style triggers (no sub_type).
@@ -1493,13 +1466,6 @@ async def _async_get_trigger_platform(
if len(platform_and_sub_type) == 1:
platform = _PLATFORM_ALIASES.get(platform, platform)
if automation.is_disabled_experimental_trigger(hass, platform):
raise vol.Invalid(
f"Trigger '{trigger_key}' requires the experimental 'New triggers and "
"conditions' feature to be enabled in Home Assistant Labs settings "
f"(feature flag: '{automation.NEW_TRIGGERS_CONDITIONS_FEATURE_FLAG}')"
)
try:
integration = await async_get_integration(hass, platform)
except IntegrationNotFound:
@@ -1815,8 +1781,6 @@ async def async_get_all_descriptions(
hass: HomeAssistant,
) -> dict[str, dict[str, Any] | None]:
"""Return descriptions (i.e. user documentation) for all triggers."""
from homeassistant.components import automation # noqa: PLC0415
descriptions_cache = hass.data[TRIGGER_DESCRIPTION_CACHE]
triggers = hass.data[TRIGGERS]
@@ -1825,9 +1789,7 @@ async def async_get_all_descriptions(
all_triggers = set(triggers)
previous_all_triggers = set(descriptions_cache)
# If the triggers are the same, we can return the cache
# mypy complains: Invalid index type "HassKey[set[str]]" for "HassDict"
if previous_all_triggers | hass.data[TRIGGER_DISABLED_TRIGGERS] == all_triggers: # type: ignore[index]
if previous_all_triggers == all_triggers:
return descriptions_cache
# Files we loaded for missing descriptions
@@ -1865,10 +1827,6 @@ async def async_get_all_descriptions(
new_descriptions_cache = descriptions_cache.copy()
for missing_trigger in missing_triggers:
domain = triggers[missing_trigger]
if automation.is_disabled_experimental_trigger(hass, domain):
hass.data[TRIGGER_DISABLED_TRIGGERS].add(missing_trigger)
continue
if (
yaml_description := new_triggers_descriptions.get(domain, {}).get(
missing_trigger
@@ -20,7 +20,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
assert_numerical_condition_unit_conversion,
parametrize_condition_states_all,
@@ -50,37 +49,6 @@ async def target_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "sensor")
@pytest.mark.parametrize(
"condition",
[
"air_quality.is_gas_detected",
"air_quality.is_gas_cleared",
"air_quality.is_co_detected",
"air_quality.is_co_cleared",
"air_quality.is_smoke_detected",
"air_quality.is_smoke_cleared",
"air_quality.is_co_value",
"air_quality.is_co2_value",
"air_quality.is_pm1_value",
"air_quality.is_pm25_value",
"air_quality.is_pm4_value",
"air_quality.is_pm10_value",
"air_quality.is_ozone_value",
"air_quality.is_voc_value",
"air_quality.is_voc_ratio_value",
"air_quality.is_no_value",
"air_quality.is_no2_value",
"air_quality.is_n2o_value",
"air_quality.is_so2_value",
],
)
async def test_air_quality_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the air quality conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
_PLAIN_THRESHOLD = {"threshold": {"type": "above", "value": {"number": 50}}}
_PPB_THRESHOLD = {
"threshold": {
@@ -102,7 +70,6 @@ _UGM3_THRESHOLD = {
}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -148,7 +115,6 @@ async def test_air_quality_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -221,7 +187,6 @@ async def test_air_quality_binary_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -294,7 +259,6 @@ async def test_air_quality_binary_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -369,7 +333,6 @@ async def test_air_quality_numerical_with_unit_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -444,7 +407,6 @@ async def test_air_quality_numerical_with_unit_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -510,7 +472,6 @@ async def test_air_quality_numerical_no_unit_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -576,7 +537,6 @@ async def test_air_quality_numerical_no_unit_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_air_quality_condition_unit_conversion_co(
hass: HomeAssistant,
) -> None:
@@ -24,7 +24,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_numerical_state_value_changed_trigger_states,
parametrize_numerical_state_value_crossed_threshold_trigger_states,
@@ -52,50 +51,6 @@ async def target_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "sensor")
@pytest.mark.parametrize(
"trigger_key",
[
"air_quality.gas_detected",
"air_quality.gas_cleared",
"air_quality.co_detected",
"air_quality.co_cleared",
"air_quality.smoke_detected",
"air_quality.smoke_cleared",
"air_quality.co_changed",
"air_quality.co_crossed_threshold",
"air_quality.co2_changed",
"air_quality.co2_crossed_threshold",
"air_quality.pm1_changed",
"air_quality.pm1_crossed_threshold",
"air_quality.pm25_changed",
"air_quality.pm25_crossed_threshold",
"air_quality.pm4_changed",
"air_quality.pm4_crossed_threshold",
"air_quality.pm10_changed",
"air_quality.pm10_crossed_threshold",
"air_quality.ozone_changed",
"air_quality.ozone_crossed_threshold",
"air_quality.voc_changed",
"air_quality.voc_crossed_threshold",
"air_quality.voc_ratio_changed",
"air_quality.voc_ratio_crossed_threshold",
"air_quality.no_changed",
"air_quality.no_crossed_threshold",
"air_quality.no2_changed",
"air_quality.no2_crossed_threshold",
"air_quality.n2o_changed",
"air_quality.n2o_crossed_threshold",
"air_quality.so2_changed",
"air_quality.so2_crossed_threshold",
],
)
async def test_air_quality_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the air quality triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
_CHANGED_THRESHOLD = {"threshold": {"type": "any"}}
_PLAIN_CROSSED_THRESHOLD = {"threshold": {"type": "above", "value": {"number": 50}}}
_PPB_CROSSED_THRESHOLD = {
@@ -118,7 +73,6 @@ _UGM3_CROSSED_THRESHOLD = {
}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -173,7 +127,6 @@ async def test_air_quality_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -255,7 +208,6 @@ async def test_air_quality_trigger_binary_sensor_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -334,7 +286,6 @@ async def test_air_quality_trigger_binary_sensor_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -413,7 +364,6 @@ async def test_air_quality_trigger_binary_sensor_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -593,7 +543,6 @@ async def test_air_quality_trigger_sensor_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -704,7 +653,6 @@ async def test_air_quality_trigger_sensor_crossed_threshold_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -815,7 +763,6 @@ async def test_air_quality_trigger_sensor_crossed_threshold_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_air_quality_trigger_unit_conversion_co_ppm_to_ugm3(
hass: HomeAssistant,
) -> None:
@@ -15,7 +15,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
other_states,
parametrize_condition_states_all,
@@ -31,26 +30,6 @@ async def target_alarm_control_panels(hass: HomeAssistant) -> dict[str, list[str
return await target_entities(hass, "alarm_control_panel")
@pytest.mark.parametrize(
"condition",
[
"alarm_control_panel.is_armed",
"alarm_control_panel.is_armed_away",
"alarm_control_panel.is_armed_home",
"alarm_control_panel.is_armed_night",
"alarm_control_panel.is_armed_vacation",
"alarm_control_panel.is_disarmed",
"alarm_control_panel.is_triggered",
],
)
async def test_alarm_control_panel_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the alarm_control_panel conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -80,7 +59,6 @@ async def test_alarm_control_panel_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("alarm_control_panel"),
@@ -172,7 +150,6 @@ async def test_alarm_control_panel_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("alarm_control_panel"),
@@ -16,7 +16,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
other_states,
parametrize_target_entities,
@@ -31,26 +30,6 @@ async def target_alarm_control_panels(hass: HomeAssistant) -> dict[str, list[str
return await target_entities(hass, "alarm_control_panel")
@pytest.mark.parametrize(
"trigger_key",
[
"alarm_control_panel.armed",
"alarm_control_panel.armed_away",
"alarm_control_panel.armed_home",
"alarm_control_panel.armed_night",
"alarm_control_panel.armed_vacation",
"alarm_control_panel.disarmed",
"alarm_control_panel.triggered",
],
)
async def test_alarm_control_panel_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the ACP triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -80,7 +59,6 @@ async def test_alarm_control_panel_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("alarm_control_panel"),
@@ -180,7 +158,6 @@ async def test_alarm_control_panel_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("alarm_control_panel"),
@@ -280,7 +257,6 @@ async def test_alarm_control_panel_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("alarm_control_panel"),
@@ -11,7 +11,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
other_states,
parametrize_condition_states_all,
@@ -27,23 +26,6 @@ async def target_assist_satellites(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "assist_satellite")
@pytest.mark.parametrize(
"condition",
[
"assist_satellite.is_idle",
"assist_satellite.is_listening",
"assist_satellite.is_processing",
"assist_satellite.is_responding",
],
)
async def test_assist_satellite_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the assist satellite conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -70,7 +52,6 @@ async def test_assist_satellite_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("assist_satellite"),
@@ -123,7 +104,6 @@ async def test_assist_satellite_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("assist_satellite"),
@@ -12,7 +12,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
other_states,
parametrize_target_entities,
@@ -27,23 +26,6 @@ async def target_assist_satellites(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "assist_satellite")
@pytest.mark.parametrize(
"trigger_key",
[
"assist_satellite.idle",
"assist_satellite.listening",
"assist_satellite.processing",
"assist_satellite.responding",
],
)
async def test_assist_satellite_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the Assist satellite triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -70,7 +52,6 @@ async def test_assist_satellite_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("assist_satellite"),
@@ -123,7 +104,6 @@ async def test_assist_satellite_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("assist_satellite"),
@@ -176,7 +156,6 @@ async def test_assist_satellite_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("assist_satellite"),
+1 -122
View File
@@ -8,7 +8,7 @@ from unittest.mock import ANY, Mock, patch
import pytest
from homeassistant.components import automation, input_boolean, labs, script
from homeassistant.components import automation, input_boolean, script
from homeassistant.components.automation import (
ATTR_SOURCE,
DOMAIN,
@@ -2346,7 +2346,6 @@ async def test_extraction_functions(
async def test_extraction_functions_with_trigger_targets(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
hass_ws_client: WebSocketGenerator,
) -> None:
"""Test extraction functions with targets in triggers.
@@ -2369,21 +2368,6 @@ async def test_extraction_functions_with_trigger_targets(
)
await hass.async_block_till_done()
# Enable the new_triggers_conditions feature flag to allow new-style triggers
assert await async_setup_component(hass, "labs", {})
ws_client = await hass_ws_client(hass)
await ws_client.send_json_auto_id(
{
"type": "labs/update",
"domain": "automation",
"preview_feature": "new_triggers_conditions",
"enabled": True,
}
)
msg = await ws_client.receive_json()
assert msg["success"]
await hass.async_block_till_done()
assert await async_setup_component(
hass,
DOMAIN,
@@ -2542,7 +2526,6 @@ async def test_extraction_functions_with_trigger_targets(
async def test_extraction_functions_with_condition_targets(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
hass_ws_client: WebSocketGenerator,
) -> None:
"""Test extraction functions with targets in conditions."""
config_entry = MockConfigEntry(domain="fake_integration", data={})
@@ -2558,21 +2541,6 @@ async def test_extraction_functions_with_condition_targets(
await async_setup_component(hass, "light", {"light": {"platform": "demo"}})
await hass.async_block_till_done()
# Enable the new_triggers_conditions feature flag to allow new-style conditions
assert await async_setup_component(hass, "labs", {})
ws_client = await hass_ws_client(hass)
await ws_client.send_json_auto_id(
{
"type": "labs/update",
"domain": "automation",
"preview_feature": "new_triggers_conditions",
"enabled": True,
}
)
msg = await ws_client.receive_json()
assert msg["success"]
await hass.async_block_till_done()
assert await async_setup_component(
hass,
DOMAIN,
@@ -4038,95 +4006,6 @@ async def test_valid_configuration(
await hass.async_block_till_done()
async def test_reload_when_labs_flag_changes(
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
calls: list[ServiceCall],
hass_admin_user: MockUser,
hass_read_only_user: MockUser,
) -> None:
"""Test automations are reloaded when labs flag changes."""
ws_client = await hass_ws_client(hass)
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"alias": "hello",
"trigger": {"platform": "event", "event_type": "test_event"},
"action": {
"action": "test.automation",
"data_template": {"event": "{{ trigger.event.event_type }}"},
},
}
},
)
assert await async_setup_component(hass, labs.DOMAIN, {})
assert hass.states.get("automation.hello") is not None
assert hass.states.get("automation.bye") is None
listeners = hass.bus.async_listeners()
assert listeners.get("test_event") == 1
assert listeners.get("test_event2") is None
hass.bus.async_fire("test_event")
await hass.async_block_till_done()
assert len(calls) == 1
assert calls[0].data.get("event") == "test_event"
test_reload_event = async_capture_events(hass, EVENT_AUTOMATION_RELOADED)
# Check we reload whenever the labs flag is set, even if it's already enabled
for enabled in (True, True, False, False):
test_reload_event.clear()
calls.clear()
with patch(
"homeassistant.config.load_yaml_config_file",
autospec=True,
return_value={
automation.DOMAIN: {
"alias": "bye",
"trigger": {"platform": "event", "event_type": "test_event2"},
"action": {
"action": "test.automation",
"data_template": {"event": "{{ trigger.event.event_type }}"},
},
}
},
):
await ws_client.send_json_auto_id(
{
"type": "labs/update",
"domain": "automation",
"preview_feature": "new_triggers_conditions",
"enabled": enabled,
}
)
msg = await ws_client.receive_json()
assert msg["success"]
await hass.async_block_till_done()
assert len(test_reload_event) == 1
assert hass.states.get("automation.hello") is None
assert hass.states.get("automation.bye") is not None
listeners = hass.bus.async_listeners()
assert listeners.get("test_event") is None
assert listeners.get("test_event2") == 1
hass.bus.async_fire("test_event")
await hass.async_block_till_done()
assert len(calls) == 0
hass.bus.async_fire("test_event2")
await hass.async_block_till_done()
assert len(calls) == 1
assert calls[-1].data.get("event") == "test_event2"
async def test_remove_automation_unloads_condition_and_script(
hass: HomeAssistant,
calls: list[ServiceCall],
@@ -17,7 +17,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
parametrize_condition_states_all,
parametrize_condition_states_any,
@@ -46,27 +45,9 @@ async def target_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
)
@pytest.mark.parametrize(
"condition",
[
"battery.is_low",
"battery.is_not_low",
"battery.is_charging",
"battery.is_not_charging",
"battery.is_level",
],
)
async def test_battery_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the battery conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
_LEVEL_THRESHOLD = {"threshold": {"type": "above", "value": {"number": 50}}}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -94,7 +75,6 @@ async def test_battery_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -151,7 +131,6 @@ async def test_battery_binary_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -208,7 +187,6 @@ async def test_battery_binary_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -244,7 +222,6 @@ async def test_battery_is_level_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
-26
View File
@@ -19,7 +19,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_numerical_state_value_changed_trigger_states,
parametrize_numerical_state_value_crossed_threshold_trigger_states,
@@ -45,29 +44,10 @@ async def target_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
)
@pytest.mark.parametrize(
"trigger_key",
[
"battery.low",
"battery.not_low",
"battery.started_charging",
"battery.stopped_charging",
"battery.level_changed",
"battery.level_crossed_threshold",
],
)
async def test_battery_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the battery triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
_LEVEL_CHANGED_THRESHOLD = {"threshold": {"type": "any"}}
_LEVEL_CROSSED_THRESHOLD = {"threshold": {"type": "above", "value": {"number": 50}}}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -96,7 +76,6 @@ async def test_battery_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -157,7 +136,6 @@ async def test_battery_binary_sensor_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -218,7 +196,6 @@ async def test_battery_binary_sensor_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -279,7 +256,6 @@ async def test_battery_binary_sensor_trigger_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -322,7 +298,6 @@ async def test_battery_sensor_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -360,7 +335,6 @@ async def test_battery_level_crossed_threshold_sensor_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
-11
View File
@@ -10,7 +10,6 @@ from homeassistant.core import HomeAssistant
from tests.components.common import (
TriggerStateDescription,
arm_trigger,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
set_or_remove_state,
@@ -24,15 +23,6 @@ async def target_buttons(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "button")
@pytest.mark.parametrize("trigger_key", ["button.pressed"])
async def test_button_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the button triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -56,7 +46,6 @@ async def test_button_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("button"),
@@ -11,7 +11,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
parametrize_condition_states_all,
parametrize_condition_states_any,
@@ -26,20 +25,6 @@ async def target_calendars(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "calendar")
@pytest.mark.parametrize(
"condition",
[
"calendar.is_event_active",
],
)
async def test_calendar_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the calendar conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -63,7 +48,6 @@ async def test_calendar_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("calendar"),
@@ -101,7 +85,6 @@ async def test_calendar_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("calendar"),
@@ -21,7 +21,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
assert_numerical_condition_unit_conversion,
other_states,
@@ -40,26 +39,6 @@ async def target_climates(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "climate")
@pytest.mark.parametrize(
"condition",
[
"climate.is_off",
"climate.is_on",
"climate.is_cooling",
"climate.is_drying",
"climate.is_heating",
"climate.is_hvac_mode",
"climate.target_humidity",
"climate.target_temperature",
],
)
async def test_climate_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the climate conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
_HUMIDITY_THRESHOLD = {"threshold": {"type": "above", "value": {"number": 50}}}
_TEMPERATURE_THRESHOLD = {
"threshold": {
@@ -69,7 +48,6 @@ _TEMPERATURE_THRESHOLD = {
}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -100,7 +78,6 @@ async def test_climate_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -168,7 +145,6 @@ async def test_climate_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -236,7 +212,6 @@ async def test_climate_state_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -284,7 +259,6 @@ async def test_climate_attribute_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -332,7 +306,6 @@ async def test_climate_attribute_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -378,7 +351,6 @@ async def test_climate_numerical_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -424,7 +396,6 @@ async def test_climate_numerical_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_climate_numerical_condition_unit_conversion(hass: HomeAssistant) -> None:
"""Test that the climate numerical condition converts units correctly."""
_unit_celsius = {ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS}
-31
View File
@@ -28,7 +28,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
other_states,
parametrize_numerical_attribute_changed_trigger_states,
@@ -45,28 +44,6 @@ async def target_climates(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "climate")
@pytest.mark.parametrize(
"trigger_key",
[
"climate.hvac_mode_changed",
"climate.target_humidity_changed",
"climate.target_humidity_crossed_threshold",
"climate.target_temperature_changed",
"climate.target_temperature_crossed_threshold",
"climate.turned_off",
"climate.turned_on",
"climate.started_cooling",
"climate.started_drying",
"climate.started_heating",
],
)
async def test_climate_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the climate triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
_CHANGED_THRESHOLD = {"threshold": {"type": "any"}}
_HUMIDITY_CROSSED_THRESHOLD = {"threshold": {"type": "above", "value": {"number": 50}}}
_TEMPERATURE_CROSSED_THRESHOLD = {
@@ -77,7 +54,6 @@ _TEMPERATURE_CROSSED_THRESHOLD = {
}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -120,7 +96,6 @@ async def test_climate_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger", "trigger_options", "expected_result"),
[
@@ -176,7 +151,6 @@ async def test_climate_trigger_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -234,7 +208,6 @@ async def test_climate_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -308,7 +281,6 @@ async def test_climate_state_attribute_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -366,7 +338,6 @@ async def test_climate_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -427,7 +398,6 @@ async def test_climate_state_attribute_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -485,7 +455,6 @@ async def test_climate_state_trigger_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
-67
View File
@@ -44,7 +44,6 @@ from homeassistant.helpers.trigger import (
async_validate_trigger_config,
)
from homeassistant.helpers.typing import UNDEFINED, TemplateVarsType, UndefinedType
from homeassistant.setup import async_setup_component
from homeassistant.util.yaml import load_yaml_dict
from tests.common import MockConfigEntry, mock_device_registry
@@ -1413,72 +1412,6 @@ def other_states(state: StrEnum | Iterable[StrEnum]) -> list[str]:
return sorted({s.value for s in enum_class} - excluded_values)
async def assert_condition_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Helper to check that a condition is gated by the labs flag."""
# Local include to avoid importing the automation component unnecessarily
from homeassistant.components import automation # noqa: PLC0415
await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {"platform": "event", "event_type": "test_event"},
"condition": {
CONF_CONDITION: condition,
CONF_TARGET: {ATTR_LABEL_ID: "test_label"},
CONF_OPTIONS: {"behavior": "any"},
},
"action": {
"service": "test.automation",
},
}
},
)
assert (
"Unnamed automation failed to setup conditions and has been disabled: "
f"Condition '{condition}' requires the experimental 'New triggers and "
"conditions' feature to be enabled in Home Assistant Labs settings "
"(feature flag: 'new_triggers_conditions')"
) in caplog.text
async def assert_trigger_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger: str
) -> None:
"""Helper to check that a trigger is gated by the labs flag."""
# Local include to avoid importing the automation component unnecessarily
from homeassistant.components import automation # noqa: PLC0415
await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {
CONF_PLATFORM: trigger,
CONF_TARGET: {ATTR_LABEL_ID: "test_label"},
},
"action": {
"service": "test.automation",
},
}
},
)
assert (
"Unnamed automation failed to setup triggers and has been disabled: Trigger "
f"'{trigger}' requires the experimental 'New triggers and conditions' "
"feature to be enabled in Home Assistant Labs settings (feature flag: "
"'new_triggers_conditions')"
) in caplog.text
async def _validate_condition_options(
hass: HomeAssistant,
condition: str,
-10
View File
@@ -1498,13 +1498,3 @@ async def check_translations(
for description in translation_errors.values():
if description != "used":
pytest.fail(description)
@pytest.fixture(name="enable_labs_preview_features")
def enable_labs_preview_features() -> Generator[None]:
"""Enable labs preview features."""
with patch(
"homeassistant.components.labs.async_is_preview_feature_enabled",
return_value=True,
):
yield
@@ -10,7 +10,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
parametrize_condition_states_all,
parametrize_condition_states_any,
@@ -25,23 +24,9 @@ async def target_counters(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "counter")
@pytest.mark.parametrize(
"condition",
[
"counter.is_value",
],
)
async def test_counter_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the counter conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
_PLAIN_THRESHOLD = {"threshold": {"type": "above", "value": {"number": 50}}}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -65,7 +50,6 @@ async def test_counter_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("counter"),
@@ -138,7 +122,6 @@ async def test_counter_is_value_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("counter"),
-23
View File
@@ -20,7 +20,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
parametrize_trigger_states,
@@ -53,24 +52,6 @@ async def target_counters(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, DOMAIN)
@pytest.mark.parametrize(
"trigger_key",
[
"counter.decremented",
"counter.incremented",
"counter.maximum_reached",
"counter.minimum_reached",
"counter.reset",
],
)
async def test_counter_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the counter triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -98,7 +79,6 @@ async def test_counter_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -183,7 +163,6 @@ async def test_counter_state_trigger(
calls.clear()
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -214,7 +193,6 @@ async def test_counter_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -245,7 +223,6 @@ async def test_counter_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
-27
View File
@@ -12,7 +12,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
create_target_condition,
parametrize_condition_states_all,
@@ -36,29 +35,6 @@ async def target_covers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "cover")
@pytest.mark.parametrize(
"condition",
[
"cover.awning_is_closed",
"cover.awning_is_open",
"cover.blind_is_closed",
"cover.blind_is_open",
"cover.curtain_is_closed",
"cover.curtain_is_open",
"cover.shade_is_closed",
"cover.shade_is_open",
"cover.shutter_is_closed",
"cover.shutter_is_open",
],
)
async def test_cover_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the cover conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -91,7 +67,6 @@ async def test_cover_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -154,7 +129,6 @@ async def test_cover_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -217,7 +191,6 @@ async def test_cover_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
(
"condition_key",
-27
View File
@@ -13,7 +13,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
parametrize_trigger_states,
@@ -35,29 +34,6 @@ async def target_covers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "cover")
@pytest.mark.parametrize(
"trigger_key",
[
"cover.awning_closed",
"cover.awning_opened",
"cover.blind_closed",
"cover.blind_opened",
"cover.curtain_closed",
"cover.curtain_opened",
"cover.shade_closed",
"cover.shade_opened",
"cover.shutter_closed",
"cover.shutter_opened",
],
)
async def test_cover_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the cover triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -90,7 +66,6 @@ async def test_cover_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -162,7 +137,6 @@ async def test_cover_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -234,7 +208,6 @@ async def test_cover_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
-21
View File
@@ -12,7 +12,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
create_target_condition,
parametrize_condition_states_all,
@@ -34,21 +33,6 @@ async def target_covers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "cover")
@pytest.mark.parametrize(
"condition",
[
"door.is_closed",
"door.is_open",
],
)
async def test_door_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the door conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -76,7 +60,6 @@ async def test_door_condition_options_validation(
# --- binary_sensor tests ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -121,7 +104,6 @@ async def test_door_binary_sensor_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -169,7 +151,6 @@ async def test_door_binary_sensor_condition_behavior_all(
# --- cover tests ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -228,7 +209,6 @@ async def test_door_cover_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -290,7 +270,6 @@ async def test_door_cover_condition_behavior_all(
# --- Cross-domain device class exclusion test ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
(
"condition_key",
-22
View File
@@ -14,7 +14,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
parametrize_trigger_states,
@@ -34,21 +33,6 @@ async def target_covers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "cover")
@pytest.mark.parametrize(
"trigger_key",
[
"door.opened",
"door.closed",
],
)
async def test_door_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the door triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -73,7 +57,6 @@ async def test_door_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -124,7 +107,6 @@ async def test_door_trigger_binary_sensor_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -192,7 +174,6 @@ async def test_door_trigger_cover_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -243,7 +224,6 @@ async def test_door_trigger_binary_sensor_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -294,7 +274,6 @@ async def test_door_trigger_binary_sensor_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -362,7 +341,6 @@ async def test_door_trigger_cover_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
-15
View File
@@ -11,7 +11,6 @@ from homeassistant.core import HomeAssistant
from tests.components.common import (
BasicTriggerStateDescription,
arm_trigger,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
set_or_remove_state,
@@ -25,19 +24,6 @@ async def target_events(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "event")
@pytest.mark.parametrize("trigger_key", ["doorbell.rang"])
async def test_doorbell_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the doorbell triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(
hass,
caplog,
trigger_key,
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -61,7 +47,6 @@ async def test_doorbell_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("event"),
-15
View File
@@ -11,7 +11,6 @@ from homeassistant.core import HomeAssistant
from tests.components.common import (
TriggerStateDescription,
arm_trigger,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
set_or_remove_state,
@@ -25,19 +24,6 @@ async def target_events(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "event")
@pytest.mark.parametrize("trigger_key", ["event.received"])
async def test_event_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the event triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(
hass,
caplog,
trigger_key,
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -61,7 +47,6 @@ async def test_event_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("event"),
-18
View File
@@ -11,7 +11,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
parametrize_condition_states_all,
parametrize_condition_states_any,
@@ -26,21 +25,6 @@ async def target_fans(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "fan", domain_excluded="switch")
@pytest.mark.parametrize(
"condition",
[
"fan.is_off",
"fan.is_on",
],
)
async def test_fan_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the fan conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -65,7 +49,6 @@ async def test_fan_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("fan"),
@@ -110,7 +93,6 @@ async def test_fan_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("fan"),
-19
View File
@@ -12,7 +12,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
parametrize_trigger_states,
@@ -26,21 +25,6 @@ async def target_fans(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "fan")
@pytest.mark.parametrize(
"trigger_key",
[
"fan.turned_off",
"fan.turned_on",
],
)
async def test_fan_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the fan triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -65,7 +49,6 @@ async def test_fan_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("fan"),
@@ -108,7 +91,6 @@ async def test_fan_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("fan"),
@@ -151,7 +133,6 @@ async def test_fan_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("fan"),
@@ -12,7 +12,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
create_target_condition,
parametrize_condition_states_all,
@@ -34,21 +33,6 @@ async def target_covers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "cover")
@pytest.mark.parametrize(
"condition",
[
"garage_door.is_closed",
"garage_door.is_open",
],
)
async def test_garage_door_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the garage_door conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -76,7 +60,6 @@ async def test_garage_door_condition_options_validation(
# --- binary_sensor tests ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -121,7 +104,6 @@ async def test_garage_door_binary_sensor_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -169,7 +151,6 @@ async def test_garage_door_binary_sensor_condition_behavior_all(
# --- cover tests ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -228,7 +209,6 @@ async def test_garage_door_cover_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -290,7 +270,6 @@ async def test_garage_door_cover_condition_behavior_all(
# --- Cross-domain device class exclusion test ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
(
"condition_key",
@@ -14,7 +14,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
parametrize_trigger_states,
@@ -34,21 +33,6 @@ async def target_covers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "cover")
@pytest.mark.parametrize(
"trigger_key",
[
"garage_door.opened",
"garage_door.closed",
],
)
async def test_garage_door_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the garage door triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -73,7 +57,6 @@ async def test_garage_door_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -127,7 +110,6 @@ async def test_garage_door_trigger_binary_sensor_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -195,7 +177,6 @@ async def test_garage_door_trigger_cover_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -246,7 +227,6 @@ async def test_garage_door_trigger_binary_sensor_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -297,7 +277,6 @@ async def test_garage_door_trigger_binary_sensor_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -365,7 +344,6 @@ async def test_garage_door_trigger_cover_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
-19
View File
@@ -12,7 +12,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
create_target_condition,
parametrize_condition_states_all,
@@ -28,21 +27,6 @@ async def target_covers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "cover")
@pytest.mark.parametrize(
"condition",
[
"gate.is_closed",
"gate.is_open",
],
)
async def test_gate_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the gate conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -67,7 +51,6 @@ async def test_gate_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -126,7 +109,6 @@ async def test_gate_cover_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -188,7 +170,6 @@ async def test_gate_cover_condition_behavior_all(
# --- Device class exclusion test ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
(
"condition_key",
-19
View File
@@ -13,7 +13,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
parametrize_trigger_states,
@@ -27,21 +26,6 @@ async def target_covers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "cover")
@pytest.mark.parametrize(
"trigger_key",
[
"gate.opened",
"gate.closed",
],
)
async def test_gate_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the gate triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -66,7 +50,6 @@ async def test_gate_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -134,7 +117,6 @@ async def test_gate_trigger_cover_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -202,7 +184,6 @@ async def test_gate_trigger_cover_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -29,7 +29,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
parametrize_condition_states_all,
parametrize_condition_states_any,
@@ -46,28 +45,9 @@ async def target_humidifiers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "humidifier")
@pytest.mark.parametrize(
"condition",
[
"humidifier.is_off",
"humidifier.is_on",
"humidifier.is_drying",
"humidifier.is_humidifying",
"humidifier.is_mode",
"humidifier.is_target_humidity",
],
)
async def test_humidifier_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the humidifier conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
_HUMIDITY_THRESHOLD = {"threshold": {"type": "above", "value": {"number": 50}}}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -96,7 +76,6 @@ async def test_humidifier_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("humidifier"),
@@ -139,7 +118,6 @@ async def test_humidifier_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("humidifier"),
@@ -182,7 +160,6 @@ async def test_humidifier_state_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("humidifier"),
@@ -239,7 +216,6 @@ async def test_humidifier_attribute_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("humidifier"),
@@ -296,7 +272,6 @@ async def test_humidifier_attribute_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("humidifier"),
@@ -333,7 +308,6 @@ async def test_humidifier_numerical_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("humidifier"),
@@ -370,7 +344,6 @@ async def test_humidifier_numerical_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition", "condition_options", "expected_result"),
[
@@ -29,7 +29,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
parametrize_trigger_states,
@@ -43,24 +42,6 @@ async def target_humidifiers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "humidifier")
@pytest.mark.parametrize(
"trigger_key",
[
"humidifier.mode_changed",
"humidifier.started_drying",
"humidifier.started_humidifying",
"humidifier.turned_off",
"humidifier.turned_on",
],
)
async def test_humidifier_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the humidifier triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -88,7 +69,6 @@ async def test_humidifier_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("humidifier"),
@@ -131,7 +111,6 @@ async def test_humidifier_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("humidifier"),
@@ -189,7 +168,6 @@ async def test_humidifier_state_attribute_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("humidifier"),
@@ -232,7 +210,6 @@ async def test_humidifier_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("humidifier"),
@@ -290,7 +267,6 @@ async def test_humidifier_state_attribute_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("humidifier"),
@@ -333,7 +309,6 @@ async def test_humidifier_state_trigger_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("humidifier"),
@@ -391,7 +366,6 @@ async def test_humidifier_state_attribute_trigger_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger", "trigger_options", "expected_result"),
[
@@ -19,7 +19,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
parametrize_numerical_attribute_condition_above_below_all,
parametrize_numerical_attribute_condition_above_below_any,
@@ -56,23 +55,9 @@ async def target_weathers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "weather")
@pytest.mark.parametrize(
"condition",
[
"humidity.is_value",
],
)
async def test_humidity_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the humidity conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
_PLAIN_THRESHOLD = {"threshold": {"type": "above", "value": {"number": 50}}}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -96,7 +81,6 @@ async def test_humidity_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -132,7 +116,6 @@ async def test_humidity_sensor_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -168,7 +151,6 @@ async def test_humidity_sensor_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -205,7 +187,6 @@ async def test_humidity_climate_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -242,7 +223,6 @@ async def test_humidity_climate_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("humidifier"),
@@ -279,7 +259,6 @@ async def test_humidity_humidifier_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("humidifier"),
@@ -316,7 +295,6 @@ async def test_humidity_humidifier_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("weather"),
@@ -353,7 +331,6 @@ async def test_humidity_weather_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("weather"),
-29
View File
@@ -21,7 +21,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_ignores_limit_entities_with_wrong_unit,
assert_trigger_options_supported,
parametrize_numerical_attribute_changed_trigger_states,
@@ -57,20 +56,6 @@ async def target_weathers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "weather")
@pytest.mark.parametrize(
"trigger_key",
[
"humidity.changed",
"humidity.crossed_threshold",
],
)
async def test_humidity_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the humidity triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
_CHANGED_THRESHOLD = {"threshold": {"type": "any"}}
_PERCENT_CROSSED_THRESHOLD = {
@@ -81,7 +66,6 @@ _PERCENT_CROSSED_THRESHOLD = {
}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -109,7 +93,6 @@ async def test_humidity_trigger_options_validation(
# --- Sensor domain tests (value in state.state) ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -152,7 +135,6 @@ async def test_humidity_trigger_sensor_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -190,7 +172,6 @@ async def test_humidity_trigger_sensor_crossed_threshold_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -231,7 +212,6 @@ async def test_humidity_trigger_sensor_crossed_threshold_behavior_all(
# --- Climate domain tests (value in current_humidity attribute) ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -276,7 +256,6 @@ async def test_humidity_trigger_climate_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -315,7 +294,6 @@ async def test_humidity_trigger_climate_crossed_threshold_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -357,7 +335,6 @@ async def test_humidity_trigger_climate_crossed_threshold_behavior_all(
# --- Humidifier domain tests (value in current_humidity attribute) ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("humidifier"),
@@ -402,7 +379,6 @@ async def test_humidity_trigger_humidifier_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("humidifier"),
@@ -441,7 +417,6 @@ async def test_humidity_trigger_humidifier_crossed_threshold_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("humidifier"),
@@ -483,7 +458,6 @@ async def test_humidity_trigger_humidifier_crossed_threshold_behavior_all(
# --- Weather domain tests (value in humidity attribute) ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("weather"),
@@ -528,7 +502,6 @@ async def test_humidity_trigger_weather_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("weather"),
@@ -567,7 +540,6 @@ async def test_humidity_trigger_weather_crossed_threshold_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("weather"),
@@ -633,7 +605,6 @@ async def test_humidity_trigger_weather_crossed_threshold_behavior_all(
),
],
)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_humidity_trigger_ignores_limit_entity_with_wrong_unit(
hass: HomeAssistant,
trigger: str,
@@ -16,7 +16,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
parametrize_condition_states_all,
parametrize_condition_states_any,
@@ -41,25 +40,9 @@ async def target_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "sensor")
@pytest.mark.parametrize(
"condition",
[
"illuminance.is_detected",
"illuminance.is_not_detected",
"illuminance.is_value",
],
)
async def test_illuminance_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the illuminance conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
_ILLUMINANCE_THRESHOLD = {"threshold": {"type": "above", "value": {"number": 50}}}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -85,7 +68,6 @@ async def test_illuminance_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -130,7 +112,6 @@ async def test_illuminance_binary_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -175,7 +156,6 @@ async def test_illuminance_binary_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -211,7 +191,6 @@ async def test_illuminance_value_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -20,7 +20,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_numerical_state_value_changed_trigger_states,
parametrize_numerical_state_value_crossed_threshold_trigger_states,
@@ -42,27 +41,10 @@ async def target_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "sensor")
@pytest.mark.parametrize(
"trigger_key",
[
"illuminance.detected",
"illuminance.cleared",
"illuminance.changed",
"illuminance.crossed_threshold",
],
)
async def test_illuminance_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the illuminance triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
_CHANGED_THRESHOLD = {"threshold": {"type": "any"}}
_CROSSED_THRESHOLD = {"threshold": {"type": "above", "value": {"number": 50}}}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -92,7 +74,6 @@ async def test_illuminance_trigger_options_validation(
# --- Binary sensor detected/cleared tests ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -143,7 +124,6 @@ async def test_illuminance_trigger_binary_sensor_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -194,7 +174,6 @@ async def test_illuminance_trigger_binary_sensor_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -248,7 +227,6 @@ async def test_illuminance_trigger_binary_sensor_behavior_all(
# --- Sensor changed/crossed_threshold tests ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -291,7 +269,6 @@ async def test_illuminance_trigger_sensor_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -329,7 +306,6 @@ async def test_illuminance_trigger_sensor_crossed_threshold_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -11,7 +11,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
other_states,
parametrize_condition_states_all,
@@ -27,24 +26,6 @@ async def target_lawn_mowers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "lawn_mower")
@pytest.mark.parametrize(
"condition",
[
"lawn_mower.is_docked",
"lawn_mower.is_encountering_an_error",
"lawn_mower.is_mowing",
"lawn_mower.is_paused",
"lawn_mower.is_returning",
],
)
async def test_lawn_mower_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the lawn mower conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -72,7 +53,6 @@ async def test_lawn_mower_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("lawn_mower"),
@@ -130,7 +110,6 @@ async def test_lawn_mower_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("lawn_mower"),
@@ -12,7 +12,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
other_states,
parametrize_target_entities,
@@ -27,24 +26,6 @@ async def target_lawn_mowers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "lawn_mower")
@pytest.mark.parametrize(
"trigger_key",
[
"lawn_mower.docked",
"lawn_mower.errored",
"lawn_mower.paused_mowing",
"lawn_mower.started_mowing",
"lawn_mower.started_returning",
],
)
async def test_lawn_mower_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the lawn mower triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -72,7 +53,6 @@ async def test_lawn_mower_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("lawn_mower"),
@@ -130,7 +110,6 @@ async def test_lawn_mower_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("lawn_mower"),
@@ -188,7 +167,6 @@ async def test_lawn_mower_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("lawn_mower"),
-21
View File
@@ -12,7 +12,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
parametrize_condition_states_all,
parametrize_condition_states_any,
@@ -32,25 +31,9 @@ async def target_lights(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "light", domain_excluded="switch")
@pytest.mark.parametrize(
"condition",
[
"light.is_brightness",
"light.is_off",
"light.is_on",
],
)
async def test_light_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the light conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
_BRIGHTNESS_THRESHOLD = {"threshold": {"type": "above", "value": {"number": 50}}}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -76,7 +59,6 @@ async def test_light_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("light"),
@@ -121,7 +103,6 @@ async def test_light_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("light"),
@@ -166,7 +147,6 @@ async def test_light_state_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("light"),
@@ -205,7 +185,6 @@ async def test_light_brightness_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("light"),
-25
View File
@@ -13,7 +13,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_ignores_limit_entities_with_wrong_unit,
assert_trigger_options_supported,
parametrize_numerical_attribute_changed_trigger_states,
@@ -37,29 +36,12 @@ async def target_lights(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "light")
@pytest.mark.parametrize(
"trigger_key",
[
"light.brightness_changed",
"light.brightness_crossed_threshold",
"light.turned_off",
"light.turned_on",
],
)
async def test_light_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the light triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
_CHANGED_THRESHOLD = {"threshold": {"type": "any"}}
_BRIGHTNESS_CROSSED_THRESHOLD = {
"threshold": {"type": "above", "value": {"number": 50}}
}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -91,7 +73,6 @@ async def test_light_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("light"),
@@ -134,7 +115,6 @@ async def test_light_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("light"),
@@ -179,7 +159,6 @@ async def test_light_state_attribute_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("light"),
@@ -222,7 +201,6 @@ async def test_light_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("light"),
@@ -261,7 +239,6 @@ async def test_light_state_attribute_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("light"),
@@ -304,7 +281,6 @@ async def test_light_state_trigger_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("light"),
@@ -343,7 +319,6 @@ async def test_light_state_attribute_trigger_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger", "trigger_options", "limit_entities"),
[
-20
View File
@@ -11,7 +11,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
other_states,
parametrize_condition_states_all,
@@ -27,23 +26,6 @@ async def target_locks(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "lock")
@pytest.mark.parametrize(
"condition",
[
"lock.is_jammed",
"lock.is_locked",
"lock.is_open",
"lock.is_unlocked",
],
)
async def test_lock_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the lock conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -70,7 +52,6 @@ async def test_lock_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("lock"),
@@ -123,7 +104,6 @@ async def test_lock_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("lock"),
-21
View File
@@ -12,7 +12,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
other_states,
parametrize_target_entities,
@@ -27,23 +26,6 @@ async def target_locks(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, DOMAIN)
@pytest.mark.parametrize(
"trigger_key",
[
"lock.jammed",
"lock.locked",
"lock.opened",
"lock.unlocked",
],
)
async def test_lock_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the lock triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -70,7 +52,6 @@ async def test_lock_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -123,7 +104,6 @@ async def test_lock_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -176,7 +156,6 @@ async def test_lock_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -15,7 +15,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
other_states,
parametrize_condition_states_all,
@@ -96,27 +95,6 @@ async def target_media_players(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "media_player")
@pytest.mark.parametrize(
"condition",
[
"media_player.is_muted",
"media_player.is_off",
"media_player.is_on",
"media_player.is_not_playing",
"media_player.is_paused",
"media_player.is_playing",
"media_player.is_unmuted",
"media_player.is_volume",
],
)
async def test_media_player_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the media player conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -147,7 +125,6 @@ async def test_media_player_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("media_player"),
@@ -230,7 +207,6 @@ async def test_media_player_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("media_player"),
@@ -18,7 +18,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_ignores_limit_entities_with_wrong_unit,
assert_trigger_options_supported,
parametrize_numerical_attribute_changed_trigger_states,
@@ -38,27 +37,6 @@ async def target_media_players(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "media_player")
@pytest.mark.parametrize(
"trigger_key",
[
"media_player.muted",
"media_player.unmuted",
"media_player.volume_changed",
"media_player.volume_crossed_threshold",
"media_player.paused_playing",
"media_player.started_playing",
"media_player.stopped_playing",
"media_player.turned_off",
"media_player.turned_on",
],
)
async def test_media_player_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the media player triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
# is_muted=True states (mute attr True OR volume_level == 0)
_IS_MUTED_STATES = [
(MediaPlayerState.PLAYING, {ATTR_MEDIA_VOLUME_MUTED: True}),
@@ -115,7 +93,6 @@ def parametrize_muted_trigger_states(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -152,7 +129,6 @@ async def test_media_player_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("media_player"),
@@ -249,7 +225,6 @@ async def test_media_player_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("media_player"),
@@ -297,7 +272,6 @@ async def test_media_player_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("media_player"),
@@ -345,7 +319,6 @@ async def test_media_player_state_trigger_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("media_player"),
@@ -392,7 +365,6 @@ async def test_media_player_volume_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("media_player"),
@@ -432,7 +404,6 @@ async def test_media_player_volume_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("media_player"),
@@ -472,7 +443,6 @@ async def test_media_player_volume_trigger_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger", "trigger_options", "limit_entities"),
[
@@ -529,7 +499,6 @@ async def test_media_player_trigger_ignores_limit_entity_with_wrong_unit(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_muted_trigger_ignores_entities_without_volume_attributes(
hass: HomeAssistant,
) -> None:
@@ -568,7 +537,6 @@ async def test_muted_trigger_ignores_entities_without_volume_attributes(
assert len(calls) == 1
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_muted_trigger_does_not_fire_on_losing_volume_attributes(
hass: HomeAssistant,
) -> None:
@@ -597,7 +565,6 @@ async def test_muted_trigger_does_not_fire_on_losing_volume_attributes(
assert len(calls) == 0
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_unmuted_trigger_does_not_fire_when_entity_gains_volume_attributes(
hass: HomeAssistant,
) -> None:
@@ -16,7 +16,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
parametrize_condition_states_all,
parametrize_condition_states_any,
@@ -41,25 +40,9 @@ async def target_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "sensor")
@pytest.mark.parametrize(
"condition",
[
"moisture.is_detected",
"moisture.is_not_detected",
"moisture.is_value",
],
)
async def test_moisture_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the moisture conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
_MOISTURE_THRESHOLD = {"threshold": {"type": "above", "value": {"number": 50}}}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -85,7 +68,6 @@ async def test_moisture_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -130,7 +112,6 @@ async def test_moisture_binary_sensor_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -175,7 +156,6 @@ async def test_moisture_binary_sensor_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -211,7 +191,6 @@ async def test_moisture_sensor_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
-25
View File
@@ -19,7 +19,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_ignores_limit_entities_with_wrong_unit,
assert_trigger_options_supported,
parametrize_numerical_state_value_changed_trigger_states,
@@ -42,27 +41,10 @@ async def target_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "sensor")
@pytest.mark.parametrize(
"trigger_key",
[
"moisture.detected",
"moisture.cleared",
"moisture.changed",
"moisture.crossed_threshold",
],
)
async def test_moisture_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the moisture triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
_CHANGED_THRESHOLD = {"threshold": {"type": "any"}}
_CROSSED_THRESHOLD = {"threshold": {"type": "above", "value": {"number": 50}}}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -89,7 +71,6 @@ async def test_moisture_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -140,7 +121,6 @@ async def test_moisture_trigger_binary_sensor_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -191,7 +171,6 @@ async def test_moisture_trigger_binary_sensor_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -242,7 +221,6 @@ async def test_moisture_trigger_binary_sensor_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -285,7 +263,6 @@ async def test_moisture_trigger_sensor_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -323,7 +300,6 @@ async def test_moisture_trigger_sensor_crossed_threshold_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -361,7 +337,6 @@ async def test_moisture_trigger_sensor_crossed_threshold_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger", "trigger_options", "limit_entities"),
[
-19
View File
@@ -11,7 +11,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
create_target_condition,
parametrize_condition_states_all,
@@ -27,21 +26,6 @@ async def target_binary_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "binary_sensor")
@pytest.mark.parametrize(
"condition",
[
"motion.is_detected",
"motion.is_not_detected",
],
)
async def test_motion_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the motion conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -66,7 +50,6 @@ async def test_motion_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -111,7 +94,6 @@ async def test_motion_binary_sensor_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -159,7 +141,6 @@ async def test_motion_binary_sensor_condition_behavior_all(
# --- Device class exclusion test ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
(
"condition_key",
-19
View File
@@ -13,7 +13,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
parametrize_trigger_states,
@@ -27,21 +26,6 @@ async def target_binary_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "binary_sensor")
@pytest.mark.parametrize(
"trigger_key",
[
"motion.detected",
"motion.cleared",
],
)
async def test_motion_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the motion triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -66,7 +50,6 @@ async def test_motion_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -117,7 +100,6 @@ async def test_motion_trigger_binary_sensor_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -168,7 +150,6 @@ async def test_motion_trigger_binary_sensor_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -11,7 +11,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
create_target_condition,
parametrize_condition_states_all,
@@ -27,21 +26,6 @@ async def target_binary_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "binary_sensor")
@pytest.mark.parametrize(
"condition",
[
"occupancy.is_detected",
"occupancy.is_not_detected",
],
)
async def test_occupancy_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the occupancy conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -66,7 +50,6 @@ async def test_occupancy_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -111,7 +94,6 @@ async def test_occupancy_binary_sensor_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -159,7 +141,6 @@ async def test_occupancy_binary_sensor_condition_behavior_all(
# --- Device class exclusion test ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
(
"condition_key",
@@ -13,7 +13,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
parametrize_trigger_states,
@@ -27,21 +26,6 @@ async def target_binary_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "binary_sensor")
@pytest.mark.parametrize(
"trigger_key",
[
"occupancy.detected",
"occupancy.cleared",
],
)
async def test_occupancy_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the occupancy triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -66,7 +50,6 @@ async def test_occupancy_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -117,7 +100,6 @@ async def test_occupancy_trigger_binary_sensor_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -168,7 +150,6 @@ async def test_occupancy_trigger_binary_sensor_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
-16
View File
@@ -11,7 +11,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
assert_numerical_condition_unit_conversion,
parametrize_numerical_condition_above_below_all,
@@ -27,17 +26,6 @@ async def target_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "sensor")
@pytest.mark.parametrize(
"condition",
["power.is_value"],
)
async def test_power_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the power conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
_WATT_THRESHOLD = {
"threshold": {
"type": "above",
@@ -46,7 +34,6 @@ _WATT_THRESHOLD = {
}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -70,7 +57,6 @@ async def test_power_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -107,7 +93,6 @@ async def test_power_sensor_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -144,7 +129,6 @@ async def test_power_sensor_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_power_condition_unit_conversion_sensor(
hass: HomeAssistant,
) -> None:
-19
View File
@@ -13,7 +13,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_numerical_state_value_changed_trigger_states,
parametrize_numerical_state_value_crossed_threshold_trigger_states,
@@ -30,20 +29,6 @@ async def target_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "sensor")
@pytest.mark.parametrize(
"trigger_key",
[
"power.changed",
"power.crossed_threshold",
],
)
async def test_power_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the power triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
_CHANGED_THRESHOLD = {"threshold": {"type": "any"}}
_WATT_CROSSED_THRESHOLD = {
@@ -54,7 +39,6 @@ _WATT_CROSSED_THRESHOLD = {
}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -79,7 +63,6 @@ async def test_power_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -124,7 +107,6 @@ async def test_power_trigger_sensor_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -163,7 +145,6 @@ async def test_power_trigger_sensor_crossed_threshold_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
-18
View File
@@ -11,7 +11,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
parametrize_condition_states_all,
parametrize_condition_states_any,
@@ -26,21 +25,6 @@ async def target_remotes(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "remote", domain_excluded="switch")
@pytest.mark.parametrize(
"condition",
[
"remote.is_off",
"remote.is_on",
],
)
async def test_remote_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the remote conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -65,7 +49,6 @@ async def test_remote_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("remote"),
@@ -110,7 +93,6 @@ async def test_remote_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("remote"),
-16
View File
@@ -13,7 +13,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
parametrize_trigger_states,
@@ -27,18 +26,6 @@ async def target_remotes(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, DOMAIN)
@pytest.mark.parametrize(
"trigger_key",
["remote.turned_on", "remote.turned_off"],
)
async def test_remote_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the remote triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -63,7 +50,6 @@ async def test_remote_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -106,7 +92,6 @@ async def test_remote_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -149,7 +134,6 @@ async def test_remote_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
-11
View File
@@ -10,7 +10,6 @@ from homeassistant.core import HomeAssistant
from tests.components.common import (
TriggerStateDescription,
arm_trigger,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
set_or_remove_state,
@@ -24,15 +23,6 @@ async def target_scenes(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "scene")
@pytest.mark.parametrize("trigger_key", ["scene.activated"])
async def test_scene_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the scene triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -56,7 +46,6 @@ async def test_scene_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("scene"),
@@ -12,7 +12,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
parametrize_condition_states_all,
parametrize_condition_states_any,
@@ -27,21 +26,6 @@ async def target_schedules(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, DOMAIN)
@pytest.mark.parametrize(
"condition",
[
"schedule.is_off",
"schedule.is_on",
],
)
async def test_schedule_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the schedule conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -66,7 +50,6 @@ async def test_schedule_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -109,7 +92,6 @@ async def test_schedule_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
-20
View File
@@ -23,7 +23,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
parametrize_trigger_states,
@@ -37,21 +36,6 @@ async def target_schedules(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, DOMAIN)
@pytest.mark.parametrize(
"trigger_key",
[
"schedule.turned_off",
"schedule.turned_on",
],
)
async def test_schedule_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the schedule triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -76,7 +60,6 @@ async def test_schedule_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -119,7 +102,6 @@ async def test_schedule_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -162,7 +144,6 @@ async def test_schedule_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -205,7 +186,6 @@ async def test_schedule_state_trigger_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_schedule_state_trigger_back_to_back(
hass: HomeAssistant,
schedule_setup: Callable[..., Coroutine[Any, Any, bool]],
+1 -62
View File
@@ -7,7 +7,7 @@ from unittest.mock import ANY, Mock, patch
import pytest
from homeassistant.components import labs, script
from homeassistant.components import script
from homeassistant.components.script import DOMAIN, EVENT_SCRIPT_STARTED, ScriptEntity
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import (
@@ -1893,67 +1893,6 @@ async def test_script_queued_mode(hass: HomeAssistant) -> None:
assert calls == 4
async def test_reload_when_labs_flag_changes(
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
) -> None:
"""Test scripts are reloaded when labs flag changes."""
event = "test_event"
hass.states.async_set("test.script", "off")
ws_client = await hass_ws_client(hass)
assert await async_setup_component(
hass,
DOMAIN,
{
"script": {
"test": {
"sequence": [
{"event": event},
{"wait_template": "{{ is_state('test.script', 'on') }}"},
]
}
}
},
)
assert await async_setup_component(hass, labs.DOMAIN, {})
assert hass.states.get(ENTITY_ID) is not None
assert hass.services.has_service(script.DOMAIN, "test")
for enabled, active_object_id, inactive_object_ids in (
(False, "test2", ("test",)),
(True, "test3", ("test", "test2")),
):
with patch(
"homeassistant.config.load_yaml_config_file",
return_value={
"script": {active_object_id: {"sequence": [{"delay": {"seconds": 5}}]}}
},
):
await ws_client.send_json_auto_id(
{
"type": "labs/update",
"domain": "automation",
"preview_feature": "new_triggers_conditions",
"enabled": enabled,
}
)
msg = await ws_client.receive_json()
assert msg["success"]
await hass.async_block_till_done()
for inactive_object_id in inactive_object_ids:
state = hass.states.get(f"script.{inactive_object_id}")
assert state.attributes["restored"] is True
assert not hass.services.has_service(script.DOMAIN, inactive_object_id)
assert hass.states.get(f"script.{active_object_id}") is not None
assert hass.services.has_service(script.DOMAIN, active_object_id)
async def test_remove_script_entity_unloads_script(hass: HomeAssistant) -> None:
"""Test that removing a script entity unloads its underlying script."""
assert await async_setup_component(
-19
View File
@@ -15,7 +15,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
create_target_condition,
parametrize_condition_states_all,
@@ -37,18 +36,6 @@ async def target_input_selects(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "input_select")
@pytest.mark.parametrize(
"condition",
["select.is_option_selected"],
)
async def test_select_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the select conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -72,7 +59,6 @@ async def test_select_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("select"),
@@ -109,7 +95,6 @@ async def test_select_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("select"),
@@ -146,7 +131,6 @@ async def test_select_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("input_select"),
@@ -183,7 +167,6 @@ async def test_input_select_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("input_select"),
@@ -223,7 +206,6 @@ async def test_input_select_condition_behavior_all(
# --- Cross-domain test ---
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_select_condition_evaluates_both_domains(
hass: HomeAssistant,
) -> None:
@@ -261,7 +243,6 @@ async def test_select_condition_evaluates_both_domains(
# --- Schema validation tests ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition", "condition_options", "expected_result"),
[
-13
View File
@@ -10,7 +10,6 @@ from homeassistant.core import HomeAssistant
from tests.components.common import (
TriggerStateDescription,
arm_trigger,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
set_or_remove_state,
@@ -30,15 +29,6 @@ async def target_input_selects(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "input_select")
@pytest.mark.parametrize("trigger_key", ["select.selection_changed"])
async def test_select_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the select triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -112,7 +102,6 @@ STATE_SEQUENCE = [
]
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("select"),
@@ -139,7 +128,6 @@ async def test_select_state_trigger(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("input_select"),
@@ -206,7 +194,6 @@ async def _assert_select_trigger_fires(
# --- Cross-domain test ---
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_select_trigger_fires_for_both_domains(
hass: HomeAssistant,
) -> None:
-18
View File
@@ -11,7 +11,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
parametrize_condition_states_all,
parametrize_condition_states_any,
@@ -26,21 +25,6 @@ async def target_sirens(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "siren", domain_excluded="switch")
@pytest.mark.parametrize(
"condition",
[
"siren.is_off",
"siren.is_on",
],
)
async def test_siren_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the siren conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -65,7 +49,6 @@ async def test_siren_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("siren"),
@@ -110,7 +93,6 @@ async def test_siren_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("siren"),
-19
View File
@@ -13,7 +13,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
parametrize_trigger_states,
@@ -27,21 +26,6 @@ async def target_sirens(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, DOMAIN)
@pytest.mark.parametrize(
"trigger_key",
[
"siren.turned_off",
"siren.turned_on",
],
)
async def test_siren_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the siren triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -66,7 +50,6 @@ async def test_siren_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -109,7 +92,6 @@ async def test_siren_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -152,7 +134,6 @@ async def test_siren_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
-21
View File
@@ -11,7 +11,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
create_target_condition,
parametrize_condition_states_all,
@@ -33,21 +32,6 @@ async def target_input_booleans(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "input_boolean")
@pytest.mark.parametrize(
"condition",
[
"switch.is_off",
"switch.is_on",
],
)
async def test_switch_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the switch conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -72,7 +56,6 @@ async def test_switch_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("switch"),
@@ -117,7 +100,6 @@ async def test_switch_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("switch"),
@@ -189,7 +171,6 @@ CONDITION_STATES_ALL = [
]
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("input_boolean"),
@@ -221,7 +202,6 @@ async def test_input_boolean_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("input_boolean"),
@@ -253,7 +233,6 @@ async def test_input_boolean_state_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_switch_condition_evaluates_both_domains(
hass: HomeAssistant,
) -> None:
-23
View File
@@ -14,7 +14,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
parametrize_trigger_states,
@@ -47,21 +46,6 @@ async def target_input_booleans(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "input_boolean")
@pytest.mark.parametrize(
"trigger_key",
[
"switch.turned_off",
"switch.turned_on",
],
)
async def test_switch_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the switch triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -89,7 +73,6 @@ async def test_switch_trigger_options_validation(
# --- Switch domain tests ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -121,7 +104,6 @@ async def test_switch_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -153,7 +135,6 @@ async def test_switch_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -188,7 +169,6 @@ async def test_switch_state_trigger_behavior_all(
# --- Input boolean domain tests ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("input_boolean"),
@@ -220,7 +200,6 @@ async def test_input_boolean_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("input_boolean"),
@@ -252,7 +231,6 @@ async def test_input_boolean_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("input_boolean"),
@@ -287,7 +265,6 @@ async def test_input_boolean_state_trigger_behavior_all(
# --- Cross-domain test ---
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_switch_trigger_fires_for_both_domains(
hass: HomeAssistant,
) -> None:
@@ -13,7 +13,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
assert_numerical_condition_unit_conversion,
parametrize_numerical_attribute_condition_above_below_all,
@@ -51,17 +50,6 @@ async def target_weathers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "weather")
@pytest.mark.parametrize(
"condition",
["temperature.is_value"],
)
async def test_temperature_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the temperature conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
_CELSIUS_THRESHOLD = {
"threshold": {
"type": "above",
@@ -70,7 +58,6 @@ _CELSIUS_THRESHOLD = {
}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -94,7 +81,6 @@ async def test_temperature_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -131,7 +117,6 @@ async def test_temperature_sensor_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -168,7 +153,6 @@ async def test_temperature_sensor_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -206,7 +190,6 @@ async def test_temperature_climate_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -244,7 +227,6 @@ async def test_temperature_climate_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("water_heater"),
@@ -282,7 +264,6 @@ async def test_temperature_water_heater_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("water_heater"),
@@ -320,7 +301,6 @@ async def test_temperature_water_heater_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("weather"),
@@ -359,7 +339,6 @@ async def test_temperature_weather_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("weather"),
@@ -398,7 +377,6 @@ async def test_temperature_weather_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_temperature_condition_unit_conversion_sensor(
hass: HomeAssistant,
) -> None:
@@ -488,7 +466,6 @@ async def test_temperature_condition_unit_conversion_sensor(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_temperature_condition_unit_conversion_climate(
hass: HomeAssistant,
) -> None:
@@ -30,7 +30,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_numerical_attribute_changed_trigger_states,
parametrize_numerical_attribute_crossed_threshold_trigger_states,
@@ -72,20 +71,6 @@ async def target_weathers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "weather")
@pytest.mark.parametrize(
"trigger_key",
[
"temperature.changed",
"temperature.crossed_threshold",
],
)
async def test_temperature_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the temperature triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
_CELSIUS_CROSSED_THRESHOLD = {
"threshold": {
"type": "above",
@@ -96,7 +81,6 @@ _CELSIUS_CROSSED_THRESHOLD = {
_CHANGED_THRESHOLD = {"threshold": {"type": "any"}}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -124,7 +108,6 @@ async def test_temperature_trigger_options_validation(
# --- Sensor domain tests (value in state.state) ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -169,7 +152,6 @@ async def test_temperature_trigger_sensor_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -208,7 +190,6 @@ async def test_temperature_trigger_sensor_crossed_threshold_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("sensor"),
@@ -250,7 +231,6 @@ async def test_temperature_trigger_sensor_crossed_threshold_behavior_all(
# --- Climate domain tests (value in current_temperature attribute) ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -297,7 +277,6 @@ async def test_temperature_trigger_climate_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -337,7 +316,6 @@ async def test_temperature_trigger_climate_crossed_threshold_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("climate"),
@@ -380,7 +358,6 @@ async def test_temperature_trigger_climate_crossed_threshold_behavior_all(
# --- Water heater domain tests (value in current_temperature attribute) ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("water_heater"),
@@ -427,7 +404,6 @@ async def test_temperature_trigger_water_heater_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("water_heater"),
@@ -467,7 +443,6 @@ async def test_temperature_trigger_water_heater_crossed_threshold_behavior_first
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("water_heater"),
@@ -510,7 +485,6 @@ async def test_temperature_trigger_water_heater_crossed_threshold_behavior_all(
# --- Weather domain tests (value in temperature attribute) ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("weather"),
@@ -559,7 +533,6 @@ async def test_temperature_trigger_weather_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("weather"),
@@ -600,7 +573,6 @@ async def test_temperature_trigger_weather_crossed_threshold_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("weather"),
@@ -644,7 +616,6 @@ async def test_temperature_trigger_weather_crossed_threshold_behavior_all(
# --- Unit conversion tests ---
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_temperature_trigger_unit_conversion_sensor_celsius_to_fahrenheit(
hass: HomeAssistant,
) -> None:
@@ -702,7 +673,6 @@ async def test_temperature_trigger_unit_conversion_sensor_celsius_to_fahrenheit(
calls.clear()
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_temperature_trigger_unit_conversion_sensor_fahrenheit_to_celsius(
hass: HomeAssistant,
) -> None:
@@ -760,7 +730,6 @@ async def test_temperature_trigger_unit_conversion_sensor_fahrenheit_to_celsius(
calls.clear()
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_temperature_trigger_unit_conversion_changed(
hass: HomeAssistant,
) -> None:
@@ -832,7 +801,6 @@ async def test_temperature_trigger_unit_conversion_changed(
assert len(calls) == 0
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_temperature_trigger_unit_conversion_weather(
hass: HomeAssistant,
) -> None:
+2 -172
View File
@@ -6,24 +6,15 @@ from unittest.mock import patch
import pytest
from homeassistant import config
from homeassistant.components import labs
from homeassistant.components.template import DOMAIN
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import SERVICE_RELOAD
from homeassistant.core import Context, HomeAssistant
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.setup import async_setup_component
from homeassistant.util import dt as dt_util
from tests.common import (
MockConfigEntry,
MockUser,
async_capture_events,
async_fire_time_changed,
get_fixture_path,
)
from tests.typing import WebSocketGenerator
from tests.common import MockConfigEntry, async_fire_time_changed, get_fixture_path
@pytest.mark.parametrize(("count", "domain"), [(2, "template")])
@@ -536,167 +527,6 @@ async def test_fail_non_numerical_number_settings(
)
async def test_yaml_reload_when_labs_flag_changes(
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
hass_admin_user: MockUser,
hass_read_only_user: MockUser,
) -> None:
"""Test templates are reloaded when labs flag changes."""
ws_client = await hass_ws_client(hass)
assert await async_setup_component(
hass,
DOMAIN,
{
DOMAIN: {
"triggers": {
"trigger": "event",
"event_type": "test_event",
},
"sensor": {
"name": "hello",
"state": "{{ trigger.event.data.stuff }}",
},
}
},
)
assert await async_setup_component(hass, labs.DOMAIN, {})
await hass.async_block_till_done()
assert hass.states.get("sensor.hello") is not None
assert hass.states.get("sensor.bye") is None
listeners = hass.bus.async_listeners()
assert listeners.get("test_event") == 1
assert listeners.get("test_event2") is None
context = Context()
hass.bus.async_fire("test_event", {"stuff": "foo"}, context=context)
await hass.async_block_till_done()
assert hass.states.get("sensor.hello").state == "foo"
test_reload_event = async_capture_events(hass, "event_template_reloaded")
# Check we reload whenever the labs flag is set, even if it's already enabled
last_state = "unknown"
for enabled, set_state in (
(True, "foo"),
(True, "bar"),
(False, "beer"),
(False, "good"),
):
test_reload_event.clear()
with patch(
"homeassistant.config.load_yaml_config_file",
autospec=True,
return_value={
DOMAIN: {
"triggers": {
"trigger": "event",
"event_type": "test_event2",
},
"sensor": {
"name": "bye",
"state": "{{ trigger.event.data.stuff }}",
},
}
},
):
await ws_client.send_json_auto_id(
{
"type": "labs/update",
"domain": "automation",
"preview_feature": "new_triggers_conditions",
"enabled": enabled,
}
)
msg = await ws_client.receive_json()
assert msg["success"]
await hass.async_block_till_done()
assert len(test_reload_event) == 1
assert hass.states.get("sensor.hello") is None
assert hass.states.get("sensor.bye") is not None
listeners = hass.bus.async_listeners()
assert listeners.get("test_event") is None
assert listeners.get("test_event2") == 1
hass.bus.async_fire("test_event", {"stuff": "foo"}, context=context)
await hass.async_block_till_done()
assert hass.states.get("sensor.bye").state == last_state
hass.bus.async_fire("test_event2", {"stuff": set_state}, context=context)
await hass.async_block_till_done()
assert hass.states.get("sensor.bye").state == set_state
last_state = set_state
async def test_config_entry_reload_when_labs_flag_changes(
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
hass_admin_user: MockUser,
hass_read_only_user: MockUser,
) -> None:
"""Test templates are reloaded when labs flag changes."""
ws_client = await hass_ws_client(hass)
template_config_entry = MockConfigEntry(
data={},
domain=DOMAIN,
options={
"name": "hello",
"template_type": "sensor",
"state": "{{ 'foo' }}",
},
title="My template",
)
template_config_entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(template_config_entry.entry_id)
await hass.async_block_till_done()
assert await async_setup_component(hass, labs.DOMAIN, {})
assert hass.states.get("sensor.hello") is not None
assert hass.states.get("sensor.hello").state == "foo"
# Check we reload whenever the labs flag is set, even if it's already enabled
for enabled, set_state in (
(True, "beer"),
(True, "is"),
(False, "very"),
(False, "good"),
):
hass.config_entries.async_update_entry(
template_config_entry,
options={
"name": "hello",
"template_type": "sensor",
"state": f"{{{{ '{set_state}' }}}}",
},
)
with patch(
"homeassistant.config.load_yaml_config_file",
autospec=True,
return_value={},
):
await ws_client.send_json_auto_id(
{
"type": "labs/update",
"domain": "automation",
"preview_feature": "new_triggers_conditions",
"enabled": enabled,
}
)
msg = await ws_client.receive_json()
assert msg["success"]
await hass.async_block_till_done()
assert hass.states.get("sensor.hello") is not None
assert hass.states.get("sensor.hello").state == set_state
async def test_migration_1_1(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
-15
View File
@@ -20,7 +20,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
parametrize_condition_states_all,
parametrize_condition_states_any,
@@ -41,15 +40,6 @@ async def target_input_texts(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "input_text")
@pytest.mark.parametrize("condition", ["text.is_equal_to"])
async def test_text_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the text conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -92,7 +82,6 @@ CONDITION_STATES_ALL = [
]
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("text"),
@@ -123,7 +112,6 @@ async def test_text_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("input_text"),
@@ -154,7 +142,6 @@ async def test_input_text_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("text"),
@@ -185,7 +172,6 @@ async def test_text_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("input_text"),
@@ -219,7 +205,6 @@ async def test_input_text_condition_behavior_all(
# --- Cross-domain test ---
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_text_condition_fires_for_both_domains(
hass: HomeAssistant,
) -> None:
-12
View File
@@ -12,7 +12,6 @@ from homeassistant.core import HomeAssistant
from tests.components.common import (
BasicTriggerStateDescription,
arm_trigger,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
set_or_remove_state,
@@ -129,15 +128,6 @@ async def target_input_texts(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, INPUT_TEXT_DOMAIN)
@pytest.mark.parametrize("trigger_key", ["text.changed"])
async def test_text_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the text triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -161,7 +151,6 @@ async def test_text_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -204,7 +193,6 @@ async def test_text_state_trigger(
calls.clear()
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(INPUT_TEXT_DOMAIN),
-19
View File
@@ -11,7 +11,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
parametrize_condition_states_all,
parametrize_condition_states_any,
@@ -26,22 +25,6 @@ async def target_timers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "timer")
@pytest.mark.parametrize(
"condition",
[
"timer.is_active",
"timer.is_paused",
"timer.is_idle",
],
)
async def test_timer_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the timer conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -67,7 +50,6 @@ async def test_timer_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("timer"),
@@ -115,7 +97,6 @@ async def test_timer_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("timer"),
-35
View File
@@ -38,7 +38,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
parametrize_trigger_states,
@@ -52,25 +51,6 @@ async def target_timers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, DOMAIN)
@pytest.mark.parametrize(
"trigger_key",
[
"timer.cancelled",
"timer.finished",
"timer.paused",
"timer.restarted",
"timer.started",
"timer.time_remaining",
],
)
async def test_timer_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the timer triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -99,7 +79,6 @@ async def test_timer_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -157,7 +136,6 @@ async def test_timer_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -215,7 +193,6 @@ async def test_timer_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -315,7 +292,6 @@ async def _arm_time_remaining_trigger(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_time_remaining_trigger_validation(hass: HomeAssistant) -> None:
"""Test time_remaining trigger config validation."""
# Valid config
@@ -344,7 +320,6 @@ async def test_time_remaining_trigger_validation(hass: HomeAssistant) -> None:
)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_time_remaining_trigger_fires(
hass: HomeAssistant,
freezer: FrozenDateTimeFactory,
@@ -383,7 +358,6 @@ async def test_time_remaining_trigger_fires(
assert calls[0]["remaining"] == timedelta(seconds=30)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_time_remaining_trigger_paused_before_threshold(
hass: HomeAssistant,
freezer: FrozenDateTimeFactory,
@@ -422,7 +396,6 @@ async def test_time_remaining_trigger_paused_before_threshold(
assert len(calls) == 0
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_time_remaining_trigger_cancelled_before_threshold(
hass: HomeAssistant,
freezer: FrozenDateTimeFactory,
@@ -461,7 +434,6 @@ async def test_time_remaining_trigger_cancelled_before_threshold(
assert len(calls) == 0
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_time_remaining_trigger_restarted(
hass: HomeAssistant,
freezer: FrozenDateTimeFactory,
@@ -511,7 +483,6 @@ async def test_time_remaining_trigger_restarted(
assert len(calls) == 1
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_time_remaining_trigger_short_timer(
hass: HomeAssistant,
freezer: FrozenDateTimeFactory,
@@ -542,7 +513,6 @@ async def test_time_remaining_trigger_short_timer(
assert len(calls) == 0
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_time_remaining_trigger_already_active_at_attach(
hass: HomeAssistant,
freezer: FrozenDateTimeFactory,
@@ -580,7 +550,6 @@ async def test_time_remaining_trigger_already_active_at_attach(
assert calls[0]["remaining"] == timedelta(seconds=30)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_time_remaining_trigger_already_active_past_threshold_at_attach(
hass: HomeAssistant,
freezer: FrozenDateTimeFactory,
@@ -607,7 +576,6 @@ async def test_time_remaining_trigger_already_active_past_threshold_at_attach(
assert len(calls) == 0
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_time_remaining_trigger_idle_at_attach(
hass: HomeAssistant,
freezer: FrozenDateTimeFactory,
@@ -628,7 +596,6 @@ async def test_time_remaining_trigger_idle_at_attach(
assert len(calls) == 0
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_time_remaining_trigger_active_on_first_state_event(
hass: HomeAssistant,
freezer: FrozenDateTimeFactory,
@@ -663,7 +630,6 @@ async def test_time_remaining_trigger_active_on_first_state_event(
assert calls[0]["remaining"] == timedelta(seconds=30)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_time_remaining_trigger_entity_removed_from_target(
hass: HomeAssistant,
freezer: FrozenDateTimeFactory,
@@ -713,7 +679,6 @@ async def test_time_remaining_trigger_entity_removed_from_target(
assert len(calls) == 0
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_time_remaining_trigger_entity_added_to_target(
hass: HomeAssistant,
freezer: FrozenDateTimeFactory,
-20
View File
@@ -10,7 +10,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
parametrize_condition_states_all,
parametrize_condition_states_any,
@@ -25,24 +24,9 @@ async def target_todos(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "todo", domain_excluded="sensor")
@pytest.mark.parametrize(
"condition",
[
"todo.all_completed",
"todo.incomplete",
],
)
async def test_todo_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the to-do list conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
_TODO_THRESHOLD = {"threshold": {"type": "above", "value": {"number": 5}}}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -67,7 +51,6 @@ async def test_todo_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("todo"),
@@ -106,7 +89,6 @@ async def test_todo_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("todo"),
@@ -209,7 +191,6 @@ def parametrize_incomplete_condition_states_all(
]
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("todo"),
@@ -243,7 +224,6 @@ async def test_todo_incomplete_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("todo"),
+5 -27
View File
@@ -36,10 +36,7 @@ from homeassistant.setup import async_setup_component
from . import MockTodoListEntity, create_mock_platform
from tests.common import async_mock_service, mock_device_registry
from tests.components.common import (
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
)
from tests.components.common import assert_trigger_options_supported
TODO_ENTITY_ID1 = "todo.list_one"
TODO_ENTITY_ID2 = "todo.list_two"
@@ -126,22 +123,6 @@ def service_calls(hass: HomeAssistant) -> list[ServiceCall]:
return async_mock_service(hass, "test", "item_added")
@pytest.mark.parametrize(
"trigger_key",
[
"todo.item_added",
"todo.item_completed",
"todo.item_removed",
],
)
async def test_todo_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the todo triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -265,7 +246,6 @@ async def _complete_item(hass: HomeAssistant, entity_id: str, item: str) -> None
)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_item_change_triggers(
hass: HomeAssistant, service_calls: list[ServiceCall]
) -> None:
@@ -331,7 +311,6 @@ async def test_item_change_triggers(
(_remove_item, "loaded_item", "todo.item_removed"),
],
)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_item_change_triggers_ignore_initial_unknown(
hass: HomeAssistant,
service_calls: list[ServiceCall],
@@ -368,7 +347,7 @@ async def test_item_change_triggers_ignore_initial_unknown(
)
@pytest.mark.usefixtures("enable_labs_preview_features", "target_todo_lists")
@pytest.mark.usefixtures("target_todo_lists")
@pytest.mark.parametrize(
"included_target",
[
@@ -439,7 +418,7 @@ async def test_item_change_trigger_does_not_fire_for_other_entity(
)
@pytest.mark.usefixtures("enable_labs_preview_features", "target_todo_lists")
@pytest.mark.usefixtures("target_todo_lists")
async def test_new_entity_added_to_target_fires_triggers(
hass: HomeAssistant,
service_calls: list[ServiceCall],
@@ -491,7 +470,6 @@ async def test_new_entity_added_to_target_fires_triggers(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_trigger_skips_missing_entity(
hass: HomeAssistant,
service_calls: list[ServiceCall],
@@ -515,7 +493,7 @@ async def test_trigger_skips_missing_entity(
)
@pytest.mark.usefixtures("enable_labs_preview_features", "target_todo_lists")
@pytest.mark.usefixtures("target_todo_lists")
async def test_entity_rejoining_label_does_not_fire_trigger(
hass: HomeAssistant,
service_calls: list[ServiceCall],
@@ -557,7 +535,7 @@ async def test_entity_rejoining_label_does_not_fire_trigger(
)
@pytest.mark.usefixtures("enable_labs_preview_features", "target_todo_lists")
@pytest.mark.usefixtures("target_todo_lists")
@pytest.mark.parametrize(
"trigger_target",
[
-18
View File
@@ -11,7 +11,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
parametrize_condition_states_all,
parametrize_condition_states_any,
@@ -26,21 +25,6 @@ async def target_updates(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "update", domain_excluded="switch")
@pytest.mark.parametrize(
"condition",
[
"update.is_available",
"update.is_not_available",
],
)
async def test_update_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the update conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -65,7 +49,6 @@ async def test_update_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("update"),
@@ -110,7 +93,6 @@ async def test_update_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("update"),
-18
View File
@@ -13,7 +13,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
parametrize_trigger_states,
@@ -27,20 +26,6 @@ async def target_updates(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, DOMAIN)
@pytest.mark.parametrize(
"trigger_key",
[
"update.update_became_available",
],
)
async def test_update_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the update triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -64,7 +49,6 @@ async def test_update_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -102,7 +86,6 @@ async def test_update_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -140,7 +123,6 @@ async def test_update_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
-21
View File
@@ -11,7 +11,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
other_states,
parametrize_condition_states_all,
@@ -27,24 +26,6 @@ async def target_vacuums(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "vacuum")
@pytest.mark.parametrize(
"condition",
[
"vacuum.is_cleaning",
"vacuum.is_docked",
"vacuum.is_encountering_an_error",
"vacuum.is_paused",
"vacuum.is_returning",
],
)
async def test_vacuum_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the vacuum conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -72,7 +53,6 @@ async def test_vacuum_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("vacuum"),
@@ -130,7 +110,6 @@ async def test_vacuum_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("vacuum"),
-22
View File
@@ -12,7 +12,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
other_states,
parametrize_target_entities,
@@ -27,24 +26,6 @@ async def target_vacuums(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "vacuum")
@pytest.mark.parametrize(
"trigger_key",
[
"vacuum.docked",
"vacuum.errored",
"vacuum.paused_cleaning",
"vacuum.started_cleaning",
"vacuum.started_returning",
],
)
async def test_vacuum_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the vacuum triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -72,7 +53,6 @@ async def test_vacuum_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("vacuum"),
@@ -130,7 +110,6 @@ async def test_vacuum_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("vacuum"),
@@ -188,7 +167,6 @@ async def test_vacuum_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("vacuum"),
-18
View File
@@ -12,7 +12,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
parametrize_condition_states_all,
parametrize_condition_states_any,
@@ -27,21 +26,6 @@ async def target_valves(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "valve")
@pytest.mark.parametrize(
"condition",
[
"valve.is_open",
"valve.is_closed",
],
)
async def test_valve_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the valve conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -66,7 +50,6 @@ async def test_valve_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("valve"),
@@ -123,7 +106,6 @@ async def test_valve_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("valve"),
-19
View File
@@ -12,7 +12,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
parametrize_trigger_states,
@@ -61,21 +60,6 @@ async def target_valves(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, DOMAIN)
@pytest.mark.parametrize(
"trigger_key",
[
"valve.closed",
"valve.opened",
],
)
async def test_valve_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the valve triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -100,7 +84,6 @@ async def test_valve_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -129,7 +112,6 @@ async def test_valve_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -158,7 +140,6 @@ async def test_valve_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities(DOMAIN),
@@ -25,7 +25,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
assert_numerical_condition_unit_conversion,
parametrize_condition_states_all,
@@ -56,22 +55,6 @@ async def target_water_heaters(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "water_heater")
@pytest.mark.parametrize(
"condition",
[
"water_heater.is_off",
"water_heater.is_on",
"water_heater.is_operation_mode",
"water_heater.is_target_temperature",
],
)
async def test_water_heater_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the water heater conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
_TEMPERATURE_THRESHOLD = {
"threshold": {
"type": "above",
@@ -80,7 +63,6 @@ _TEMPERATURE_THRESHOLD = {
}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -112,7 +94,6 @@ async def test_water_heater_condition_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("water_heater"),
@@ -171,7 +152,6 @@ async def test_water_heater_state_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("water_heater"),
@@ -230,7 +210,6 @@ async def test_water_heater_state_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("water_heater"),
@@ -270,7 +249,6 @@ async def test_water_heater_numerical_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("water_heater"),
@@ -310,7 +288,6 @@ async def test_water_heater_numerical_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_water_heater_numerical_condition_unit_conversion(
hass: HomeAssistant,
) -> None:
@@ -20,7 +20,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_numerical_attribute_changed_trigger_states,
parametrize_numerical_attribute_crossed_threshold_trigger_states,
@@ -48,23 +47,6 @@ async def target_water_heaters(hass: HomeAssistant) -> list[str]:
return await target_entities(hass, "water_heater")
@pytest.mark.parametrize(
"trigger_key",
[
"water_heater.operation_mode_changed",
"water_heater.target_temperature_changed",
"water_heater.target_temperature_crossed_threshold",
"water_heater.turned_off",
"water_heater.turned_on",
],
)
async def test_water_heater_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the water heater triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
_CHANGED_THRESHOLD = {"threshold": {"type": "any"}}
_CROSSED_THRESHOLD = {
"threshold": {
@@ -74,7 +56,6 @@ _CROSSED_THRESHOLD = {
}
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -117,7 +98,6 @@ async def test_water_heater_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("water_heater"),
@@ -178,7 +158,6 @@ async def test_water_heater_state_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("water_heater"),
@@ -225,7 +204,6 @@ async def test_water_heater_state_attribute_trigger_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("water_heater"),
@@ -286,7 +264,6 @@ async def test_water_heater_state_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("water_heater"),
@@ -326,7 +303,6 @@ async def test_water_heater_state_attribute_trigger_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("water_heater"),
@@ -387,7 +363,6 @@ async def test_water_heater_state_trigger_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("water_heater"),
@@ -4260,7 +4260,7 @@ async def test_extract_from_target_validation_error(
assert "error" in msg
@pytest.mark.usefixtures("enable_labs_preview_features", "target_entities")
@pytest.mark.usefixtures("target_entities")
@patch("annotatedyaml.loader.load_yaml")
@pytest.mark.parametrize("automation_component", ["trigger", "condition"])
async def test_get_triggers_conditions_for_target(
-21
View File
@@ -12,7 +12,6 @@ from tests.components.common import (
ConditionStateDescription,
assert_condition_behavior_all,
assert_condition_behavior_any,
assert_condition_gated_by_labs_flag,
assert_condition_options_supported,
create_target_condition,
parametrize_condition_states_all,
@@ -34,21 +33,6 @@ async def target_covers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "cover")
@pytest.mark.parametrize(
"condition",
[
"window.is_closed",
"window.is_open",
],
)
async def test_window_conditions_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, condition: str
) -> None:
"""Test the window conditions are gated by the labs flag."""
await assert_condition_gated_by_labs_flag(hass, caplog, condition)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -76,7 +60,6 @@ async def test_window_condition_options_validation(
# --- binary_sensor tests ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -121,7 +104,6 @@ async def test_window_binary_sensor_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -169,7 +151,6 @@ async def test_window_binary_sensor_condition_behavior_all(
# --- cover tests ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -228,7 +209,6 @@ async def test_window_cover_condition_behavior_any(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -290,7 +270,6 @@ async def test_window_cover_condition_behavior_all(
# --- Cross-domain device class exclusion test ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
(
"condition_key",
-22
View File
@@ -14,7 +14,6 @@ from tests.components.common import (
assert_trigger_behavior_all,
assert_trigger_behavior_each,
assert_trigger_behavior_first,
assert_trigger_gated_by_labs_flag,
assert_trigger_options_supported,
parametrize_target_entities,
parametrize_trigger_states,
@@ -34,21 +33,6 @@ async def target_covers(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "cover")
@pytest.mark.parametrize(
"trigger_key",
[
"window.opened",
"window.closed",
],
)
async def test_window_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the window triggers are gated by the labs flag."""
await assert_trigger_gated_by_labs_flag(hass, caplog, trigger_key)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "base_options", "supports_behavior", "supports_duration"),
[
@@ -73,7 +57,6 @@ async def test_window_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -124,7 +107,6 @@ async def test_window_trigger_binary_sensor_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -192,7 +174,6 @@ async def test_window_trigger_cover_behavior_each(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -243,7 +224,6 @@ async def test_window_trigger_binary_sensor_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("binary_sensor"),
@@ -294,7 +274,6 @@ async def test_window_trigger_binary_sensor_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
@@ -362,7 +341,6 @@ async def test_window_trigger_cover_behavior_first(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("cover"),
-3
View File
@@ -707,7 +707,6 @@ async def test_zone_trigger_behavior_all(
# --- Zone occupancy trigger tests ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key"),
["zone.occupancy_detected", "zone.occupancy_cleared"],
@@ -727,7 +726,6 @@ async def test_zone_occupancy_trigger_options_validation(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "from_state", "to_state", "should_fire"),
[
@@ -809,7 +807,6 @@ async def test_zone_occupancy_trigger_transitions(
assert (len(service_calls) == 1) is should_fire
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_key", "from_value", "to_value", "revert_value"),
[
-147
View File
@@ -86,7 +86,6 @@ from homeassistant.util.yaml.loader import parse_yaml
from tests.common import MockModule, MockPlatform, mock_integration, mock_platform
from tests.components.recorder.common import async_wait_recording_done
from tests.typing import WebSocketGenerator
async def _create_primary_and_diagnostic_entities_in_area(
@@ -2791,7 +2790,6 @@ async def test_or_condition_with_disabled_condition(hass: HomeAssistant) -> None
)
async def test_async_get_all_descriptions(
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
sun_condition_descriptions: str,
) -> None:
"""Test async_get_all_descriptions."""
@@ -2821,8 +2819,6 @@ async def test_async_get_all_descriptions(
domain: light
"""
ws_client = await hass_ws_client(hass)
assert await async_setup_component(hass, SUN_DOMAIN, {})
assert await async_setup_component(hass, SYSTEM_HEALTH_DOMAIN, {})
await hass.async_block_till_done()
@@ -2937,39 +2933,6 @@ async def test_async_get_all_descriptions(
assert await async_setup_component(hass, LIGHT_DOMAIN, {})
await hass.async_block_till_done()
with (
patch(
"annotatedyaml.loader.load_yaml",
side_effect=_load_yaml,
),
patch.object(Integration, "has_conditions", return_value=True),
):
new_descriptions = await condition.async_get_all_descriptions(hass)
assert new_descriptions is not descriptions
# No light conditions added, they are gated by the
# automation.new_triggers_conditions
# labs flag
assert new_descriptions == expected_descriptions
# Verify the cache returns the same object
assert await condition.async_get_all_descriptions(hass) is new_descriptions
# Enable the new_triggers_conditions flag and verify light conditions are loaded
assert await async_setup_component(hass, "labs", {})
await ws_client.send_json_auto_id(
{
"type": "labs/update",
"domain": "automation",
"preview_feature": "new_triggers_conditions",
"enabled": True,
}
)
msg = await ws_client.receive_json()
assert msg["success"]
await hass.async_block_till_done()
with (
patch(
"annotatedyaml.loader.load_yaml",
@@ -3022,37 +2985,6 @@ async def test_async_get_all_descriptions(
# Verify the cache returns the same object
assert await condition.async_get_all_descriptions(hass) is new_descriptions
# Disable the new_triggers_conditions flag and verify light conditions are removed
assert await async_setup_component(hass, "labs", {})
await ws_client.send_json_auto_id(
{
"type": "labs/update",
"domain": "automation",
"preview_feature": "new_triggers_conditions",
"enabled": False,
}
)
msg = await ws_client.receive_json()
assert msg["success"]
await hass.async_block_till_done()
with (
patch(
"annotatedyaml.loader.load_yaml",
side_effect=_load_yaml,
),
patch.object(Integration, "has_conditions", return_value=True),
):
new_descriptions = await condition.async_get_all_descriptions(hass)
assert new_descriptions is not descriptions
# The light conditions should no longer be present
assert new_descriptions == expected_descriptions
# Verify the cache returns the same object
assert await condition.async_get_all_descriptions(hass) is new_descriptions
await hass.data["entity_components"][SUN_DOMAIN]._async_reset()
@@ -3193,68 +3125,6 @@ async def test_subscribe_conditions(
await hass.data["entity_components"][SUN_DOMAIN]._async_reset()
@patch("annotatedyaml.loader.load_yaml")
@patch.object(Integration, "has_conditions", return_value=True)
@pytest.mark.parametrize(
("new_triggers_conditions_enabled", "expected_events"),
[
(True, [{"light.is_off", "light.is_on", "light.is_brightness"}]),
(False, []),
],
)
async def test_subscribe_conditions_experimental_conditions(
mock_has_conditions: Mock,
mock_load_yaml: Mock,
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
caplog: pytest.LogCaptureFixture,
new_triggers_conditions_enabled: bool,
expected_events: list[set[str]],
) -> None:
"""Test async_subscribe_platform_events skips disabled conditions."""
# Return empty conditions.yaml for light integration, the actual condition
# descriptions are irrelevant for this test
light_condition_descriptions = ""
def _load_yaml(fname, secrets=None):
if fname.endswith("light/conditions.yaml"):
condition_descriptions = light_condition_descriptions
else:
raise FileNotFoundError
with io.StringIO(condition_descriptions) as file:
return parse_yaml(file)
mock_load_yaml.side_effect = _load_yaml
condition_events = []
async def good_subscriber(new_conditions: set[str]):
"""Simulate a working subscriber."""
condition_events.append(new_conditions)
ws_client = await hass_ws_client(hass)
assert await async_setup_component(hass, "labs", {})
await ws_client.send_json_auto_id(
{
"type": "labs/update",
"domain": "automation",
"preview_feature": "new_triggers_conditions",
"enabled": new_triggers_conditions_enabled,
}
)
msg = await ws_client.receive_json()
assert msg["success"]
await hass.async_block_till_done()
condition.async_subscribe_platform_events(hass, good_subscriber)
assert await async_setup_component(hass, "light", {})
await hass.async_block_till_done()
assert condition_events == expected_events
@patch("annotatedyaml.loader.load_yaml")
@patch.object(Integration, "has_conditions", return_value=True)
@patch(
@@ -3265,7 +3135,6 @@ async def test_subscribe_conditions_no_conditions(
mock_has_conditions: Mock,
mock_load_yaml: Mock,
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test async_subscribe_platform_events skips platforms without conditions."""
@@ -3289,22 +3158,6 @@ async def test_subscribe_conditions_no_conditions(
"""Simulate a working subscriber."""
condition_events.append(new_conditions)
ws_client = await hass_ws_client(hass)
assert await async_setup_component(hass, "labs", {})
await ws_client.send_json_auto_id(
{
"type": "labs/update",
"domain": "automation",
"preview_feature": "new_triggers_conditions",
"enabled": True,
}
)
msg = await ws_client.receive_json()
assert msg["success"]
await hass.async_block_till_done()
condition.async_subscribe_platform_events(hass, good_subscriber)
assert await async_setup_component(hass, "light", {})
-156
View File
@@ -102,7 +102,6 @@ from tests.common import (
mock_integration,
mock_platform,
)
from tests.typing import WebSocketGenerator
async def _call_in_order(funcs: list[Callable[[], Any]], *, reverse: bool) -> list[Any]:
@@ -1054,7 +1053,6 @@ async def test_get_trigger_platform_registers_triggers(
)
async def test_async_get_all_descriptions(
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
sun_trigger_descriptions: str,
) -> None:
"""Test async_get_all_descriptions."""
@@ -1071,8 +1069,6 @@ async def test_async_get_all_descriptions(
domain: text
"""
ws_client = await hass_ws_client(hass)
assert await async_setup_component(hass, SUN_DOMAIN, {})
assert await async_setup_component(hass, SYSTEM_HEALTH_DOMAIN, {})
await hass.async_block_till_done()
@@ -1168,38 +1164,6 @@ async def test_async_get_all_descriptions(
assert await async_setup_component(hass, TEXT_DOMAIN, {})
await hass.async_block_till_done()
with (
patch(
"annotatedyaml.loader.load_yaml",
side_effect=_load_yaml,
),
patch.object(Integration, "has_triggers", return_value=True),
):
new_descriptions = await trigger.async_get_all_descriptions(hass)
assert new_descriptions is not descriptions
# No text triggers added, they are gated by the automation.new_triggers_conditions
# labs flag
assert new_descriptions == expected_descriptions
# Verify the cache returns the same object
assert await trigger.async_get_all_descriptions(hass) is new_descriptions
# Enable the new_triggers_conditions flag and verify text triggers are loaded
assert await async_setup_component(hass, "labs", {})
await ws_client.send_json_auto_id(
{
"type": "labs/update",
"domain": "automation",
"preview_feature": "new_triggers_conditions",
"enabled": True,
}
)
msg = await ws_client.receive_json()
assert msg["success"]
await hass.async_block_till_done()
with (
patch(
"annotatedyaml.loader.load_yaml",
@@ -1228,37 +1192,6 @@ async def test_async_get_all_descriptions(
# Verify the cache returns the same object
assert await trigger.async_get_all_descriptions(hass) is new_descriptions
# Disable the new_triggers_conditions flag and verify text triggers are removed
assert await async_setup_component(hass, "labs", {})
await ws_client.send_json_auto_id(
{
"type": "labs/update",
"domain": "automation",
"preview_feature": "new_triggers_conditions",
"enabled": False,
}
)
msg = await ws_client.receive_json()
assert msg["success"]
await hass.async_block_till_done()
with (
patch(
"annotatedyaml.loader.load_yaml",
side_effect=_load_yaml,
),
patch.object(Integration, "has_triggers", return_value=True),
):
new_descriptions = await trigger.async_get_all_descriptions(hass)
assert new_descriptions is not descriptions
# The text triggers should no longer be present
assert new_descriptions == expected_descriptions
# Verify the cache returns the same object
assert await trigger.async_get_all_descriptions(hass) is new_descriptions
await hass.data["entity_components"][SUN_DOMAIN]._async_reset()
@@ -1396,78 +1329,6 @@ async def test_subscribe_triggers(
await hass.data["entity_components"][SUN_DOMAIN]._async_reset()
@patch("annotatedyaml.loader.load_yaml")
@patch.object(Integration, "has_triggers", return_value=True)
@pytest.mark.parametrize(
("new_triggers_conditions_enabled", "expected_events"),
[
(
True,
[
{
"light.brightness_changed",
"light.brightness_crossed_threshold",
"light.turned_off",
"light.turned_on",
}
],
),
(False, []),
],
)
async def test_subscribe_triggers_experimental_triggers(
mock_has_triggers: Mock,
mock_load_yaml: Mock,
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
caplog: pytest.LogCaptureFixture,
new_triggers_conditions_enabled: bool,
expected_events: list[set[str]],
) -> None:
"""Test async_subscribe_platform_events skips disabled triggers."""
# Return empty triggers.yaml for light integration, the actual trigger descriptions
# are irrelevant for this test
light_trigger_descriptions = ""
def _load_yaml(fname, secrets=None):
if fname.endswith("light/triggers.yaml"):
trigger_descriptions = light_trigger_descriptions
else:
raise FileNotFoundError
with io.StringIO(trigger_descriptions) as file:
return parse_yaml(file)
mock_load_yaml.side_effect = _load_yaml
trigger_events = []
async def good_subscriber(new_triggers: set[str]):
"""Simulate a working subscriber."""
trigger_events.append(new_triggers)
ws_client = await hass_ws_client(hass)
assert await async_setup_component(hass, "labs", {})
await ws_client.send_json_auto_id(
{
"type": "labs/update",
"domain": "automation",
"preview_feature": "new_triggers_conditions",
"enabled": new_triggers_conditions_enabled,
}
)
msg = await ws_client.receive_json()
assert msg["success"]
await hass.async_block_till_done()
trigger.async_subscribe_platform_events(hass, good_subscriber)
assert await async_setup_component(hass, "light", {})
await hass.async_block_till_done()
assert trigger_events == expected_events
@patch("annotatedyaml.loader.load_yaml")
@patch.object(Integration, "has_triggers", return_value=True)
@patch(
@@ -1478,7 +1339,6 @@ async def test_subscribe_triggers_no_triggers(
mock_has_triggers: Mock,
mock_load_yaml: Mock,
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test async_subscribe_platform_events skips platforms without triggers."""
@@ -1502,22 +1362,6 @@ async def test_subscribe_triggers_no_triggers(
"""Simulate a working subscriber."""
trigger_events.append(new_triggers)
ws_client = await hass_ws_client(hass)
assert await async_setup_component(hass, "labs", {})
await ws_client.send_json_auto_id(
{
"type": "labs/update",
"domain": "automation",
"preview_feature": "new_triggers_conditions",
"enabled": True,
}
)
msg = await ws_client.receive_json()
assert msg["success"]
await hass.async_block_till_done()
trigger.async_subscribe_platform_events(hass, good_subscriber)
assert await async_setup_component(hass, "light", {})