110110CONDITION_DESCRIPTION_CACHE : HassKey [dict [str , dict [str , Any ] | None ]] = HassKey (
111111 "condition_description_cache"
112112)
113+ CONDITION_DISABLED_CONDITIONS : HassKey [set [str ]] = HassKey (
114+ "condition_disabled_conditions"
115+ )
113116CONDITION_PLATFORM_SUBSCRIPTIONS : HassKey [
114117 list [Callable [[set [str ]], Coroutine [Any , Any , None ]]]
115118] = HassKey ("condition_platform_subscriptions" )
@@ -151,9 +154,27 @@ def starts_with_dot(key: str) -> str:
151154
152155async def async_setup (hass : HomeAssistant ) -> None :
153156 """Set up the condition helper."""
157+ from homeassistant .components import automation , labs # noqa: PLC0415
158+
154159 hass .data [CONDITION_DESCRIPTION_CACHE ] = {}
160+ hass .data [CONDITION_DISABLED_CONDITIONS ] = set ()
155161 hass .data [CONDITION_PLATFORM_SUBSCRIPTIONS ] = []
156162 hass .data [CONDITIONS ] = {}
163+
164+ @callback
165+ def new_triggers_conditions_listener () -> None :
166+ """Handle new_triggers_conditions flag change."""
167+ # Invalidate the cache
168+ hass .data [CONDITION_DESCRIPTION_CACHE ] = {}
169+ hass .data [CONDITION_DISABLED_CONDITIONS ] = set ()
170+
171+ labs .async_listen (
172+ hass ,
173+ automation .DOMAIN ,
174+ automation .NEW_TRIGGERS_CONDITIONS_FEATURE_FLAG ,
175+ new_triggers_conditions_listener ,
176+ )
177+
157178 await async_process_integration_platforms (
158179 hass , "condition" , _register_condition_platform , wait_for_platforms = True
159180 )
@@ -352,11 +373,21 @@ def wrapper(hass: HomeAssistant, variables: TemplateVarsType = None) -> bool | N
352373async def _async_get_condition_platform (
353374 hass : HomeAssistant , condition_key : str
354375) -> tuple [str , ConditionProtocol | None ]:
376+ from homeassistant .components import automation # noqa: PLC0415
377+
355378 platform_and_sub_type = condition_key .split ("." )
356379 platform : str | None = platform_and_sub_type [0 ]
357380 platform = _PLATFORM_ALIASES .get (platform , platform )
358381 if platform is None :
359382 return "" , None
383+
384+ if automation .is_disabled_experimental_condition (hass , platform ):
385+ raise vol .Invalid (
386+ f"Condition '{ condition_key } ' requires the experimental 'New triggers and "
387+ "conditions' feature to be enabled in Home Assistant Labs settings "
388+ f"(feature flag: '{ automation .NEW_TRIGGERS_CONDITIONS_FEATURE_FLAG } ')"
389+ )
390+
360391 try :
361392 integration = await async_get_integration (hass , platform )
362393 except IntegrationNotFound :
@@ -1209,6 +1240,8 @@ async def async_get_all_descriptions(
12091240 hass : HomeAssistant ,
12101241) -> dict [str , dict [str , Any ] | None ]:
12111242 """Return descriptions (i.e. user documentation) for all conditions."""
1243+ from homeassistant .components import automation # noqa: PLC0415
1244+
12121245 descriptions_cache = hass .data [CONDITION_DESCRIPTION_CACHE ]
12131246
12141247 conditions = hass .data [CONDITIONS ]
@@ -1217,7 +1250,12 @@ async def async_get_all_descriptions(
12171250 all_conditions = set (conditions )
12181251 previous_all_conditions = set (descriptions_cache )
12191252 # If the conditions are the same, we can return the cache
1220- if previous_all_conditions == all_conditions :
1253+
1254+ # mypy complains: Invalid index type "HassKey[set[str]]" for "HassDict"
1255+ if (
1256+ previous_all_conditions | hass .data [CONDITION_DISABLED_CONDITIONS ] # type: ignore[index]
1257+ == all_conditions
1258+ ):
12211259 return descriptions_cache
12221260
12231261 # Files we loaded for missing descriptions
@@ -1257,6 +1295,9 @@ async def async_get_all_descriptions(
12571295 new_descriptions_cache = descriptions_cache .copy ()
12581296 for missing_condition in missing_conditions :
12591297 domain = conditions [missing_condition ]
1298+ if automation .is_disabled_experimental_condition (hass , domain ):
1299+ hass .data [CONDITION_DISABLED_CONDITIONS ].add (missing_condition )
1300+ continue
12601301
12611302 if (
12621303 yaml_description := new_conditions_descriptions .get (domain , {}).get (
0 commit comments