mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 23:27:37 +00:00
Remove support for condition platforms defining only a CONDITION_SCHEMA (#144832)
This commit is contained in:
parent
26796f87cd
commit
cd61f37df7
@ -20,7 +20,7 @@ from homeassistant.helpers.sun import get_astral_event_date
|
||||
from homeassistant.helpers.typing import ConfigType, TemplateVarsType
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
CONDITION_SCHEMA = vol.All(
|
||||
_CONDITION_SCHEMA = vol.All(
|
||||
vol.Schema(
|
||||
{
|
||||
**cv.CONDITION_BASE_SCHEMA,
|
||||
@ -37,6 +37,13 @@ CONDITION_SCHEMA = vol.All(
|
||||
)
|
||||
|
||||
|
||||
async def async_validate_condition_config(
|
||||
hass: HomeAssistant, config: ConfigType
|
||||
) -> ConfigType:
|
||||
"""Validate config."""
|
||||
return _CONDITION_SCHEMA(config) # type: ignore[no-any-return]
|
||||
|
||||
|
||||
def sun(
|
||||
hass: HomeAssistant,
|
||||
before: str | None = None,
|
||||
|
@ -94,12 +94,7 @@ INPUT_ENTITY_ID = re.compile(
|
||||
|
||||
|
||||
class ConditionProtocol(Protocol):
|
||||
"""Define the format of device_condition modules.
|
||||
|
||||
Each module must define either CONDITION_SCHEMA or async_validate_condition_config.
|
||||
"""
|
||||
|
||||
CONDITION_SCHEMA: vol.Schema
|
||||
"""Define the format of condition modules."""
|
||||
|
||||
async def async_validate_condition_config(
|
||||
self, hass: HomeAssistant, config: ConfigType
|
||||
@ -952,9 +947,7 @@ async def async_validate_condition_config(
|
||||
|
||||
platform = await _async_get_condition_platform(hass, config)
|
||||
if platform is not None:
|
||||
if hasattr(platform, "async_validate_condition_config"):
|
||||
return await platform.async_validate_condition_config(hass, config)
|
||||
return cast(ConfigType, platform.CONDITION_SCHEMA(config))
|
||||
if platform is None and condition in ("numeric_state", "state"):
|
||||
validator = cast(
|
||||
Callable[[HomeAssistant, ConfigType], ConfigType],
|
||||
|
Loading…
x
Reference in New Issue
Block a user