Pass sensor DOMAIN constant to EntitySelectorConfig (#82670)

pull/82735/head
Erik Montnemery 2022-11-24 22:19:47 +01:00 committed by GitHub
parent b94e1e9ef8
commit 9995cef0f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 6 deletions

View File

@ -6,6 +6,7 @@ from typing import Any, cast
import voluptuous as vol
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.const import (
CONF_NAME,
CONF_SOURCE,
@ -70,7 +71,7 @@ CONFIG_SCHEMA = vol.Schema(
{
vol.Required(CONF_NAME): selector.TextSelector(),
vol.Required(CONF_SOURCE): selector.EntitySelector(
selector.EntitySelectorConfig(domain="sensor"),
selector.EntitySelectorConfig(domain=SENSOR_DOMAIN),
),
}
).extend(OPTIONS_SCHEMA.schema)

View File

@ -6,6 +6,7 @@ from typing import Any, cast
import voluptuous as vol
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.const import (
CONF_METHOD,
CONF_NAME,
@ -64,7 +65,7 @@ CONFIG_SCHEMA = vol.Schema(
{
vol.Required(CONF_NAME): selector.TextSelector(),
vol.Required(CONF_SOURCE_SENSOR): selector.EntitySelector(
selector.EntitySelectorConfig(domain="sensor")
selector.EntitySelectorConfig(domain=SENSOR_DOMAIN)
),
vol.Required(CONF_METHOD, default=METHOD_TRAPEZOIDAL): selector.SelectSelector(
selector.SelectSelectorConfig(options=INTEGRATION_METHODS),

View File

@ -6,6 +6,7 @@ from typing import Any, cast
import voluptuous as vol
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.const import CONF_TYPE
from homeassistant.helpers import selector
from homeassistant.helpers.schema_config_entry_flow import (
@ -29,7 +30,7 @@ _STATISTIC_MEASURES = [
OPTIONS_SCHEMA = vol.Schema(
{
vol.Required(CONF_ENTITY_IDS): selector.EntitySelector(
selector.EntitySelectorConfig(domain="sensor", multiple=True),
selector.EntitySelectorConfig(domain=SENSOR_DOMAIN, multiple=True),
),
vol.Required(CONF_TYPE): selector.SelectSelector(
selector.SelectSelectorConfig(options=_STATISTIC_MEASURES),

View File

@ -6,6 +6,7 @@ from typing import Any
import voluptuous as vol
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.const import CONF_ENTITY_ID, CONF_NAME
from homeassistant.helpers import selector
from homeassistant.helpers.schema_config_entry_flow import (
@ -50,7 +51,7 @@ CONFIG_SCHEMA = vol.Schema(
{
vol.Required(CONF_NAME): selector.TextSelector(),
vol.Required(CONF_ENTITY_ID): selector.EntitySelector(
selector.EntitySelectorConfig(domain="sensor")
selector.EntitySelectorConfig(domain=SENSOR_DOMAIN)
),
}
).extend(OPTIONS_SCHEMA.schema)

View File

@ -6,6 +6,7 @@ from typing import Any, cast
import voluptuous as vol
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.const import CONF_NAME
from homeassistant.helpers import selector
from homeassistant.helpers.schema_config_entry_flow import (
@ -58,7 +59,7 @@ def _validate_config(data: Any) -> Any:
OPTIONS_SCHEMA = vol.Schema(
{
vol.Required(CONF_SOURCE_SENSOR): selector.EntitySelector(
selector.EntitySelectorConfig(domain="sensor"),
selector.EntitySelectorConfig(domain=SENSOR_DOMAIN),
),
}
)
@ -67,7 +68,7 @@ CONFIG_SCHEMA = vol.Schema(
{
vol.Required(CONF_NAME): selector.TextSelector(),
vol.Required(CONF_SOURCE_SENSOR): selector.EntitySelector(
selector.EntitySelectorConfig(domain="sensor"),
selector.EntitySelectorConfig(domain=SENSOR_DOMAIN),
),
vol.Required(CONF_METER_TYPE): selector.SelectSelector(
selector.SelectSelectorConfig(options=METER_TYPES),