mirror of
https://github.com/home-assistant/core.git
synced 2026-10-08 07:19:32 -04:00
Use probatio named validators instead of hand-rolled ranges (#183815)
This commit is contained in:
@@ -79,7 +79,7 @@ PLATFORM_SCHEMA = probatio.Schema(
|
||||
probatio.Coerce(int), probatio.Range(min=1000, max=40000)
|
||||
),
|
||||
probatio.Optional(CONF_BRIGHTNESS): probatio.All(
|
||||
probatio.Coerce(int), probatio.Range(min=0, max=255)
|
||||
probatio.Coerce(int), probatio.Byte()
|
||||
),
|
||||
probatio.Optional(CONF_DISABLE_BRIGHTNESS_ADJUST): cv.boolean,
|
||||
probatio.Optional(CONF_MODE, default=DEFAULT_MODE): probatio.Any(
|
||||
|
||||
@@ -482,9 +482,7 @@ class HyperionOptionsFlow(OptionsFlowWithReload):
|
||||
default=self.config_entry.options.get(
|
||||
CONF_PRIORITY, DEFAULT_PRIORITY
|
||||
),
|
||||
): probatio.All(
|
||||
probatio.Coerce(int), probatio.Range(min=0, max=255)
|
||||
),
|
||||
): probatio.All(probatio.Coerce(int), probatio.Byte()),
|
||||
probatio.Optional(
|
||||
CONF_EFFECT_SHOW_LIST,
|
||||
default=default_effect_show_list,
|
||||
|
||||
@@ -37,7 +37,7 @@ from .const import (
|
||||
|
||||
ADD_ALL_LINK_SCHEMA = probatio.Schema(
|
||||
{
|
||||
probatio.Required(SRV_ALL_LINK_GROUP): probatio.Range(min=0, max=255),
|
||||
probatio.Required(SRV_ALL_LINK_GROUP): probatio.Byte(),
|
||||
probatio.Required(SRV_ALL_LINK_MODE): probatio.In(
|
||||
[SRV_CONTROLLER, SRV_RESPONDER]
|
||||
),
|
||||
@@ -46,7 +46,7 @@ ADD_ALL_LINK_SCHEMA = probatio.Schema(
|
||||
|
||||
|
||||
DEL_ALL_LINK_SCHEMA = probatio.Schema(
|
||||
{probatio.Required(SRV_ALL_LINK_GROUP): probatio.Range(min=0, max=255)}
|
||||
{probatio.Required(SRV_ALL_LINK_GROUP): probatio.Byte()}
|
||||
)
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ X10_HOUSECODE_SCHEMA = probatio.Schema(
|
||||
|
||||
|
||||
TRIGGER_SCENE_SCHEMA = probatio.Schema(
|
||||
{probatio.Required(SRV_ALL_LINK_GROUP): probatio.Range(min=0, max=255)}
|
||||
{probatio.Required(SRV_ALL_LINK_GROUP): probatio.Byte()}
|
||||
)
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ def build_x10_schema(
|
||||
probatio.Required(CONF_PLATFORM, default=platform): probatio.In(
|
||||
X10_PLATFORMS
|
||||
),
|
||||
dim_steps_schema: probatio.Range(min=0, max=255),
|
||||
dim_steps_schema: probatio.Byte(),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -180,15 +180,15 @@ CONFIGURATION_URL_PROTOCOL_SCHEMA_LIST = frozenset(
|
||||
)
|
||||
|
||||
# Home Assistant types
|
||||
byte = probatio.All(probatio.Coerce(int), probatio.Range(min=0, max=255))
|
||||
small_float = probatio.All(probatio.Coerce(float), probatio.Range(min=0, max=1))
|
||||
positive_int = probatio.All(probatio.Coerce(int), probatio.Range(min=0))
|
||||
positive_float = probatio.All(probatio.Coerce(float), probatio.Range(min=0))
|
||||
byte = probatio.All(probatio.Coerce(int), probatio.Byte())
|
||||
small_float = probatio.All(probatio.Coerce(float), probatio.SmallFloat())
|
||||
positive_int = probatio.All(probatio.Coerce(int), probatio.NonNegative())
|
||||
positive_float = probatio.All(probatio.Coerce(float), probatio.NonNegative())
|
||||
latitude = probatio.All(
|
||||
probatio.Coerce(float), probatio.Range(min=-90, max=90), msg="invalid latitude"
|
||||
probatio.Coerce(float), probatio.Latitude(), msg="invalid latitude"
|
||||
)
|
||||
longitude = probatio.All(
|
||||
probatio.Coerce(float), probatio.Range(min=-180, max=180), msg="invalid longitude"
|
||||
probatio.Coerce(float), probatio.Longitude(), msg="invalid longitude"
|
||||
)
|
||||
gps = probatio.ExactSequence([latitude, longitude])
|
||||
sun_event = probatio.All(
|
||||
|
||||
Reference in New Issue
Block a user