homeassistant.helpers.config_validation module provides validators and schemas for configuration validation using the voluptuous library.
Common Validators
Basic Types
boolean
Validate and coerce a boolean value.Any
required
Value to validate (accepts bool, str, number)
bool
Validated boolean value
string
Coerce value to string, except for None.Any
required
Value to coerce
str
String representation of value
Entity and Service Validators
entity_id
Validate entity ID.Any
required
Value to validate
str
Validated lowercase entity ID
entity_ids
Validate a list of entity IDs.str | list
required
Comma-separated string or list of entity IDs
list[str]
List of validated entity IDs
entity_domain
Validate that entity belongs to specific domain.str | list[str]
required
Domain(s) to validate against
Callable[[Any], str]
Validator function
service
Validate service name format.Any
required
Value to validate
str
Validated service name
Numeric Validators
positive_int
Validate positive integer.positive_float
Validate positive float.port
Validate port number (1-65535).byte
Validate byte value (0-255).Geographic Validators
latitude
Validate latitude (-90 to 90).longitude
Validate longitude (-180 to 180).gps
Validate GPS coordinates.Time and Date Validators
time
Validate and transform a time.Any
required
Time value to validate
time
Validated time object
date
Validate and transform a date.Any
required
Date value to validate
date
Validated date object
time_period
Validate time period (timedelta).positive_time_period
Validate positive time period.Template Validators
template
Validate a jinja2 template.Any
required
Template string to validate
Template
Validated Template object
dynamic_template
Validate a dynamic (non-static) jinja2 template.Any
required
Template string to validate (must contain template syntax)
Template
Validated Template object
URL Validators
url
Validate a URL.Any
required
URL to validate
str
Validated URL
configuration_url
Validate a URL that allows the homeassistant scheme.File System Validators
path
Validate it’s a safe path.Any
required
Path to validate
str
Validated path
isfile
Validate that the value is an existing file.isdir
Validate that the value is an existing directory.Schema Helpers
has_at_least_one_key
Validate that at least one key exists.has_at_most_one_key
Validate that zero keys exist or one key exists.deprecated
Log key as deprecated and provide a replacement.str
required
Deprecated key name
str | None
default:"None"
Replacement key name
Any | None
default:"None"
Default value
bool
default:"False"
Whether to raise exception if key is present
make_entity_service_schema
Create an entity service schema.dict | None
required
Service data schema
int
default:"vol.PREVENT_EXTRA"
Extra keys handling (vol.PREVENT_EXTRA or vol.ALLOW_EXTRA)
VolSchemaType
Entity service schema
Pre-built Schemas
PLATFORM_SCHEMA_BASE
Base schema for platform configuration.ENTITY_SERVICE_FIELDS
Fields for entity service schemas (entity_id, device_id, area_id, floor_id, label_id).TARGET_SERVICE_FIELDS
Fields for target service schemas (supports entity registry IDs).Constants
CONF_PLATFORM- “platform” keyCONF_ENTITY_ID- “entity_id” keyCONF_DEVICE_ID- “device_id” keyCONF_AREA_ID- “area_id” keyCONF_NAME- “name” keyCONF_SCAN_INTERVAL- “scan_interval” key