Пример #1
0
def general_options_schema(
    _: SchemaConfigFlowHandler | SchemaOptionsFlowHandler,
    options: Dict[str, Any],
) -> vol.Schema:
    """Generate options schema."""
    return vol.Schema({
        required(const.CONF_FREQUENCY, options, const.DEFAULT_FREQUENCY):
        vol.In(const.FREQUENCY_OPTIONS),
        optional(const.CONF_ICON_NORMAL, options, const.DEFAULT_ICON_NORMAL):
        selector.IconSelector(),
        optional(const.CONF_ICON_TODAY, options, const.DEFAULT_ICON_TODAY):
        selector.IconSelector(),
        optional(const.CONF_ICON_TOMORROW, options, const.DEFAULT_ICON_TOMORROW):
        selector.IconSelector(),
        optional(const.CONF_EXPIRE_AFTER, options):
        selector.TimeSelector(),
        optional(const.CONF_VERBOSE_STATE, options, const.DEFAULT_VERBOSE_STATE):
        bool,
        optional(ATTR_HIDDEN, options, False):
        bool,
        optional(const.CONF_MANUAL, options, False):
        bool,
    })
Пример #2
0
from .const import CONF_FROM, CONF_TIME, CONF_TO, DOMAIN
from .util import create_unique_id

ERROR_INVALID_AUTH = "Source: Security, message: Invalid authentication"
ERROR_INVALID_ROUTE = "No FerryAnnouncement found"

DATA_SCHEMA = vol.Schema({
    vol.Required(CONF_API_KEY):
    selector.TextSelector(selector.TextSelectorConfig()),
    vol.Required(CONF_FROM):
    selector.TextSelector(selector.TextSelectorConfig()),
    vol.Optional(CONF_TO):
    selector.TextSelector(selector.TextSelectorConfig()),
    vol.Optional(CONF_TIME):
    selector.TimeSelector(selector.TimeSelectorConfig()),
    vol.Required(CONF_WEEKDAY, default=WEEKDAYS):
    selector.SelectSelector(
        selector.SelectSelectorConfig(
            options=WEEKDAYS,
            multiple=True,
            mode=selector.SelectSelectorMode.DROPDOWN,
        )),
})
DATA_SCHEMA_REAUTH = vol.Schema({
    vol.Required(CONF_API_KEY):
    selector.TextSelector(selector.TextSelectorConfig()),
})


class TVFerryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
Пример #3
0
import voluptuous as vol

from homeassistant.const import CONF_NAME
from homeassistant.helpers import selector
from homeassistant.helpers.schema_config_entry_flow import (
    SchemaConfigFlowHandler,
    SchemaFlowFormStep,
    SchemaFlowMenuStep,
)

from .const import CONF_AFTER_TIME, CONF_BEFORE_TIME, DOMAIN

OPTIONS_SCHEMA = vol.Schema(
    {
        vol.Required(CONF_AFTER_TIME): selector.TimeSelector(),
        vol.Required(CONF_BEFORE_TIME): selector.TimeSelector(),
    }
)

CONFIG_SCHEMA = vol.Schema(
    {
        vol.Required(CONF_NAME): selector.TextSelector(),
    }
).extend(OPTIONS_SCHEMA.schema)

CONFIG_FLOW: dict[str, SchemaFlowFormStep | SchemaFlowMenuStep] = {
    "user": SchemaFlowFormStep(CONFIG_SCHEMA)
}

OPTIONS_FLOW: dict[str, SchemaFlowFormStep | SchemaFlowMenuStep] = {