core/homeassistant/components/tcp/common.py

45 lines
1.2 KiB
Python

"""Common code for TCP component."""
from __future__ import annotations
from typing import Any, Final
import voluptuous as vol
from homeassistant.const import (
CONF_HOST,
CONF_NAME,
CONF_PAYLOAD,
CONF_PORT,
CONF_SSL,
CONF_TIMEOUT,
CONF_UNIT_OF_MEASUREMENT,
CONF_VALUE_TEMPLATE,
CONF_VERIFY_SSL,
)
import homeassistant.helpers.config_validation as cv
from .const import (
CONF_BUFFER_SIZE,
CONF_VALUE_ON,
DEFAULT_BUFFER_SIZE,
DEFAULT_NAME,
DEFAULT_SSL,
DEFAULT_TIMEOUT,
DEFAULT_VERIFY_SSL,
)
TCP_PLATFORM_SCHEMA: Final[dict[vol.Marker, Any]] = {
vol.Required(CONF_HOST): cv.string,
vol.Required(CONF_PORT): cv.port,
vol.Required(CONF_PAYLOAD): cv.string,
vol.Optional(CONF_BUFFER_SIZE, default=DEFAULT_BUFFER_SIZE): cv.positive_int,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): cv.positive_int,
vol.Optional(CONF_UNIT_OF_MEASUREMENT): cv.string,
vol.Optional(CONF_VALUE_ON): cv.string,
vol.Optional(CONF_VALUE_TEMPLATE): cv.template,
vol.Optional(CONF_SSL, default=DEFAULT_SSL): cv.boolean,
vol.Optional(CONF_VERIFY_SSL, default=DEFAULT_VERIFY_SSL): cv.boolean,
}