1 """Config flow for Trend integration."""
3 from __future__
import annotations
5 from collections.abc
import Mapping
6 from typing
import Any, cast
8 import voluptuous
as vol
14 SchemaCommonFlowHandler,
15 SchemaConfigFlowHandler,
28 DEFAULT_SAMPLE_DURATION,
34 """Get base options schema."""
37 vol.Optional(CONF_ATTRIBUTE): selector.AttributeSelector(
38 selector.AttributeSelectorConfig(
39 entity_id=handler.options[CONF_ENTITY_ID]
42 vol.Optional(CONF_INVERT, default=
False): selector.BooleanSelector(),
48 """Get extended options schema."""
52 CONF_MAX_SAMPLES, default=DEFAULT_MAX_SAMPLES
53 ): selector.NumberSelector(
54 selector.NumberSelectorConfig(
56 mode=selector.NumberSelectorMode.BOX,
60 CONF_MIN_SAMPLES, default=DEFAULT_MIN_SAMPLES
61 ): selector.NumberSelector(
62 selector.NumberSelectorConfig(
64 mode=selector.NumberSelectorMode.BOX,
68 CONF_MIN_GRADIENT, default=DEFAULT_MIN_GRADIENT
69 ): selector.NumberSelector(
70 selector.NumberSelectorConfig(
72 mode=selector.NumberSelectorMode.BOX,
76 CONF_SAMPLE_DURATION, default=DEFAULT_SAMPLE_DURATION
77 ): selector.NumberSelector(
78 selector.NumberSelectorConfig(
80 mode=selector.NumberSelectorMode.BOX,
81 unit_of_measurement=UnitOfTime.SECONDS,
88 CONFIG_SCHEMA = vol.Schema(
90 vol.Required(CONF_NAME): selector.TextSelector(),
91 vol.Required(CONF_ENTITY_ID): selector.EntitySelector(
92 selector.EntitySelectorConfig(domain=SENSOR_DOMAIN, multiple=
False),
99 """Handle a config or options flow for Trend."""
110 """Return config entry title."""
111 return cast(str, options[CONF_NAME])
str async_config_entry_title(self, Mapping[str, Any] options)
vol.Schema get_extended_options_schema(SchemaCommonFlowHandler handler)
vol.Schema get_base_options_schema(SchemaCommonFlowHandler handler)