Add support for for
to binary_sensor, light and switch device triggers (#26658)
* Add support for `for` to binary_sensor, light and switch device triggers * Add WS API device_automation/trigger/capabilities
This commit is contained in:
parent
d8c6b281b8
commit
65ce3b49c1
21 changed files with 495 additions and 42 deletions
|
@ -15,8 +15,9 @@ from typing import Any, Union, TypeVar, Callable, List, Dict, Optional
|
|||
from urllib.parse import urlparse
|
||||
from uuid import UUID
|
||||
|
||||
import voluptuous as vol
|
||||
from pkg_resources import parse_version
|
||||
import voluptuous as vol
|
||||
import voluptuous_serialize
|
||||
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.const import (
|
||||
|
@ -374,6 +375,9 @@ def positive_timedelta(value: timedelta) -> timedelta:
|
|||
return value
|
||||
|
||||
|
||||
positive_time_period_dict = vol.All(time_period_dict, positive_timedelta)
|
||||
|
||||
|
||||
def remove_falsy(value: List[T]) -> List[T]:
|
||||
"""Remove falsy values from a list."""
|
||||
return [v for v in value if v]
|
||||
|
@ -690,6 +694,14 @@ def key_dependency(key, dependency):
|
|||
return validator
|
||||
|
||||
|
||||
def custom_serializer(schema):
|
||||
"""Serialize additional types for voluptuous_serialize."""
|
||||
if schema is positive_time_period_dict:
|
||||
return {"type": "positive_time_period_dict"}
|
||||
|
||||
return voluptuous_serialize.UNSUPPORTED
|
||||
|
||||
|
||||
# Schemas
|
||||
PLATFORM_SCHEMA = vol.Schema(
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue