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.Value to validate (accepts bool, str, number)
Validated boolean value
string
Coerce value to string, except for None.Value to coerce
String representation of value
Entity and Service Validators
entity_id
Validate entity ID.Value to validate
Validated lowercase entity ID
entity_ids
Validate a list of entity IDs.Comma-separated string or list of entity IDs
List of validated entity IDs
entity_domain
Validate that entity belongs to specific domain.Domain(s) to validate against
Validator function
service
Validate service name format.Value to validate
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.Time value to validate
Validated time object
date
Validate and transform a date.Date value to validate
Validated date object
time_period
Validate time period (timedelta).positive_time_period
Validate positive time period.Template Validators
template
Validate a jinja2 template.Template string to validate
Validated Template object
dynamic_template
Validate a dynamic (non-static) jinja2 template.Template string to validate (must contain template syntax)
Validated Template object
URL Validators
url
Validate a URL.URL to validate
Validated URL
configuration_url
Validate a URL that allows the homeassistant scheme.File System Validators
path
Validate it’s a safe path.Path to validate
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.Deprecated key name
Replacement key name
Default value
Whether to raise exception if key is present
make_entity_service_schema
Create an entity service schema.Service data schema
Extra keys handling (vol.PREVENT_EXTRA or vol.ALLOW_EXTRA)
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