Move StrEnum to homeassistant.backports and move Platform to homeassistant.const (#60880)
Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
3188a364e2
commit
707fe67c00
21 changed files with 59 additions and 86 deletions
1
homeassistant/backports/__init__.py
Normal file
1
homeassistant/backports/__init__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
"""Backports from newer Python versions."""
|
|
@ -1,4 +1,4 @@
|
||||||
"""Enum related utilities."""
|
"""Enum backports from standard lib."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
|
@ -8,6 +8,7 @@ from typing import Any, final
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.backports.enum import StrEnum
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import STATE_OFF, STATE_ON
|
from homeassistant.const import STATE_OFF, STATE_ON
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
@ -18,7 +19,6 @@ from homeassistant.helpers.config_validation import ( # noqa: F401
|
||||||
from homeassistant.helpers.entity import Entity, EntityDescription
|
from homeassistant.helpers.entity import Entity, EntityDescription
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.typing import ConfigType, StateType
|
from homeassistant.helpers.typing import ConfigType, StateType
|
||||||
from homeassistant.util.enum import StrEnum
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ from typing import final
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.backports.enum import StrEnum
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.config_validation import ( # noqa: F401
|
from homeassistant.helpers.config_validation import ( # noqa: F401
|
||||||
|
@ -19,7 +20,6 @@ from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
from homeassistant.util.enum import StrEnum
|
|
||||||
|
|
||||||
from .const import DOMAIN, SERVICE_PRESS
|
from .const import DOMAIN, SERVICE_PRESS
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ from typing import Any, final
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.backports.enum import StrEnum
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
SERVICE_CLOSE_COVER,
|
SERVICE_CLOSE_COVER,
|
||||||
|
@ -34,7 +35,6 @@ from homeassistant.helpers.config_validation import ( # noqa: F401
|
||||||
from homeassistant.helpers.entity import Entity, EntityDescription
|
from homeassistant.helpers.entity import Entity, EntityDescription
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
from homeassistant.util.enum import StrEnum
|
|
||||||
|
|
||||||
# mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs
|
# mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ from typing import Any, final
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.backports.enum import StrEnum
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_MODE,
|
ATTR_MODE,
|
||||||
|
@ -26,7 +27,6 @@ from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
from homeassistant.util.enum import StrEnum
|
|
||||||
|
|
||||||
from .const import ( # noqa: F401
|
from .const import ( # noqa: F401
|
||||||
ATTR_AVAILABLE_MODES,
|
ATTR_AVAILABLE_MODES,
|
||||||
|
|
|
@ -22,6 +22,7 @@ import async_timeout
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from yarl import URL
|
from yarl import URL
|
||||||
|
|
||||||
|
from homeassistant.backports.enum import StrEnum
|
||||||
from homeassistant.components import websocket_api
|
from homeassistant.components import websocket_api
|
||||||
from homeassistant.components.http import KEY_AUTHENTICATED, HomeAssistantView
|
from homeassistant.components.http import KEY_AUTHENTICATED, HomeAssistantView
|
||||||
from homeassistant.components.websocket_api.const import (
|
from homeassistant.components.websocket_api.const import (
|
||||||
|
@ -63,7 +64,6 @@ from homeassistant.helpers.entity import Entity, EntityDescription
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.network import get_url
|
from homeassistant.helpers.network import get_url
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
from homeassistant.util.enum import StrEnum
|
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_APP_ID,
|
ATTR_APP_ID,
|
||||||
|
|
|
@ -8,6 +8,7 @@ from typing import Any, final
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.backports.enum import StrEnum
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_MODE
|
from homeassistant.const import ATTR_MODE
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
|
@ -18,7 +19,6 @@ from homeassistant.helpers.config_validation import ( # noqa: F401
|
||||||
from homeassistant.helpers.entity import Entity, EntityDescription
|
from homeassistant.helpers.entity import Entity, EntityDescription
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
from homeassistant.util.enum import StrEnum
|
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_MAX,
|
ATTR_MAX,
|
||||||
|
|
|
@ -12,6 +12,7 @@ from typing import Any, Final, cast, final
|
||||||
import ciso8601
|
import ciso8601
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.backports.enum import StrEnum
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ( # noqa: F401
|
from homeassistant.const import ( # noqa: F401
|
||||||
DEVICE_CLASS_AQI,
|
DEVICE_CLASS_AQI,
|
||||||
|
@ -53,7 +54,6 @@ from homeassistant.helpers.config_validation import ( # noqa: F401
|
||||||
from homeassistant.helpers.entity import Entity, EntityDescription
|
from homeassistant.helpers.entity import Entity, EntityDescription
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.typing import ConfigType, StateType
|
from homeassistant.helpers.typing import ConfigType, StateType
|
||||||
from homeassistant.util.enum import StrEnum
|
|
||||||
|
|
||||||
from .const import CONF_STATE_CLASS # noqa: F401
|
from .const import CONF_STATE_CLASS # noqa: F401
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ from typing import Any, final
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.backports.enum import StrEnum
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
SERVICE_TOGGLE,
|
SERVICE_TOGGLE,
|
||||||
|
@ -24,7 +25,6 @@ from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
from homeassistant.util.enum import StrEnum
|
|
||||||
|
|
||||||
DOMAIN = "switch"
|
DOMAIN = "switch"
|
||||||
SCAN_INTERVAL = timedelta(seconds=30)
|
SCAN_INTERVAL = timedelta(seconds=30)
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import Platform
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import WLEDDataUpdateCoordinator
|
from .coordinator import WLEDDataUpdateCoordinator
|
||||||
|
|
|
@ -3,6 +3,8 @@ from __future__ import annotations
|
||||||
|
|
||||||
from typing import Final
|
from typing import Final
|
||||||
|
|
||||||
|
from homeassistant.backports.enum import StrEnum
|
||||||
|
|
||||||
MAJOR_VERSION: Final = 2021
|
MAJOR_VERSION: Final = 2021
|
||||||
MINOR_VERSION: Final = 12
|
MINOR_VERSION: Final = 12
|
||||||
PATCH_VERSION: Final = "0.dev0"
|
PATCH_VERSION: Final = "0.dev0"
|
||||||
|
@ -16,6 +18,42 @@ REQUIRED_NEXT_PYTHON_HA_RELEASE: Final = "2022.1"
|
||||||
# Format for platform files
|
# Format for platform files
|
||||||
PLATFORM_FORMAT: Final = "{platform}.{domain}"
|
PLATFORM_FORMAT: Final = "{platform}.{domain}"
|
||||||
|
|
||||||
|
|
||||||
|
class Platform(StrEnum):
|
||||||
|
"""Available entity platforms."""
|
||||||
|
|
||||||
|
AIR_QUALITY = "air_quality"
|
||||||
|
ALARM_CONTROL_PANEL = "alarm_control_panel"
|
||||||
|
BINARY_SENSOR = "binary_sensor"
|
||||||
|
BUTTON = "button"
|
||||||
|
CALENDAR = "calendar"
|
||||||
|
CAMERA = "camera"
|
||||||
|
CLIMATE = "climate"
|
||||||
|
COVER = "cover"
|
||||||
|
DEVICE_TRACKER = "device_tracker"
|
||||||
|
FAN = "fan"
|
||||||
|
GEO_LOCATION = "geo_location"
|
||||||
|
HUMIDIFIER = "humidifier"
|
||||||
|
IMAGE_PROCESSING = "image_processing"
|
||||||
|
LIGHT = "light"
|
||||||
|
LOCK = "lock"
|
||||||
|
MAILBOX = "mailbox"
|
||||||
|
MEDIA_PLAYER = "media_player"
|
||||||
|
NOTIFY = "notify"
|
||||||
|
NUMBER = "number"
|
||||||
|
REMOTE = "remote"
|
||||||
|
SCENE = "scene"
|
||||||
|
SELECT = "select"
|
||||||
|
SENSOR = "sensor"
|
||||||
|
SIREN = "siren"
|
||||||
|
STT = "stt"
|
||||||
|
SWITCH = "switch"
|
||||||
|
TTS = "tts"
|
||||||
|
VACUUM = "vacuum"
|
||||||
|
WATER_HEATER = "water_heater"
|
||||||
|
WEATHER = "weather"
|
||||||
|
|
||||||
|
|
||||||
# Can be used to specify a catch all when registering state or event listeners.
|
# Can be used to specify a catch all when registering state or event listeners.
|
||||||
MATCH_ALL: Final = "*"
|
MATCH_ALL: Final = "*"
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,13 @@ from typing import TYPE_CHECKING, Any, NamedTuple, cast
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
|
|
||||||
|
from homeassistant.backports.enum import StrEnum
|
||||||
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED
|
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED
|
||||||
from homeassistant.core import Event, HomeAssistant, callback
|
from homeassistant.core import Event, HomeAssistant, callback
|
||||||
from homeassistant.exceptions import RequiredParameterMissing
|
from homeassistant.exceptions import RequiredParameterMissing
|
||||||
from homeassistant.helpers import storage
|
from homeassistant.helpers import storage
|
||||||
from homeassistant.helpers.frame import report
|
from homeassistant.helpers.frame import report
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
from homeassistant.util.enum import StrEnum
|
|
||||||
import homeassistant.util.uuid as uuid_util
|
import homeassistant.util.uuid as uuid_util
|
||||||
|
|
||||||
from .debounce import Debouncer
|
from .debounce import Debouncer
|
||||||
|
|
|
@ -15,6 +15,7 @@ from typing import Any, Final, Literal, TypedDict, final
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.backports.enum import StrEnum
|
||||||
from homeassistant.config import DATA_CUSTOMIZE
|
from homeassistant.config import DATA_CUSTOMIZE
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ASSUMED_STATE,
|
ATTR_ASSUMED_STATE,
|
||||||
|
@ -43,7 +44,6 @@ from homeassistant.helpers.event import Event, async_track_entity_registry_updat
|
||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
from homeassistant.util import dt as dt_util, ensure_unique_string, slugify
|
from homeassistant.util import dt as dt_util, ensure_unique_string, slugify
|
||||||
from homeassistant.util.enum import StrEnum
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
SLOW_UPDATE_WARNING = 10
|
SLOW_UPDATE_WARNING = 10
|
||||||
|
|
|
@ -34,7 +34,6 @@ from homeassistant.exceptions import (
|
||||||
)
|
)
|
||||||
from homeassistant.setup import async_start_setup
|
from homeassistant.setup import async_start_setup
|
||||||
from homeassistant.util.async_ import run_callback_threadsafe
|
from homeassistant.util.async_ import run_callback_threadsafe
|
||||||
from homeassistant.util.enum import StrEnum
|
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
config_validation as cv,
|
config_validation as cv,
|
||||||
|
@ -63,41 +62,6 @@ PLATFORM_NOT_READY_BASE_WAIT_TIME = 30 # seconds
|
||||||
_LOGGER = getLogger(__name__)
|
_LOGGER = getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Platform(StrEnum):
|
|
||||||
"""Available platforms."""
|
|
||||||
|
|
||||||
AIR_QUALITY = "air_quality"
|
|
||||||
ALARM_CONTROL_PANEL = "alarm_control_panel"
|
|
||||||
BINARY_SENSOR = "binary_sensor"
|
|
||||||
BUTTON = "button"
|
|
||||||
CALENDAR = "calendar"
|
|
||||||
CAMERA = "camera"
|
|
||||||
CLIMATE = "climate"
|
|
||||||
COVER = "cover"
|
|
||||||
DEVICE_TRACKER = "device_tracker"
|
|
||||||
FAN = "fan"
|
|
||||||
GEO_LOCATION = "geo_location"
|
|
||||||
HUMIDIFIER = "humidifier"
|
|
||||||
IMAGE_PROCESSING = "image_processing"
|
|
||||||
LIGHT = "light"
|
|
||||||
LOCK = "lock"
|
|
||||||
MAILBOX = "mailbox"
|
|
||||||
MEDIA_PLAYER = "media_player"
|
|
||||||
NOTIFY = "notify"
|
|
||||||
NUMBER = "number"
|
|
||||||
REMOTE = "remote"
|
|
||||||
SCENE = "scene"
|
|
||||||
SELECT = "select"
|
|
||||||
SENSOR = "sensor"
|
|
||||||
SIREN = "siren"
|
|
||||||
SST = "sst"
|
|
||||||
SWITCH = "switch"
|
|
||||||
TTS = "tts"
|
|
||||||
VACUUM = "vacuum"
|
|
||||||
WATER_HEATER = "water_heater"
|
|
||||||
WEATHER = "weather"
|
|
||||||
|
|
||||||
|
|
||||||
class AddEntitiesCallback(Protocol):
|
class AddEntitiesCallback(Protocol):
|
||||||
"""Protocol type for EntityPlatform.add_entities callback."""
|
"""Protocol type for EntityPlatform.add_entities callback."""
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ from typing import TYPE_CHECKING, Any, cast
|
||||||
import attr
|
import attr
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.backports.enum import StrEnum
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_DEVICE_CLASS,
|
ATTR_DEVICE_CLASS,
|
||||||
ATTR_FRIENDLY_NAME,
|
ATTR_FRIENDLY_NAME,
|
||||||
|
@ -42,7 +43,6 @@ from homeassistant.helpers.device_registry import EVENT_DEVICE_REGISTRY_UPDATED
|
||||||
from homeassistant.helpers.frame import report
|
from homeassistant.helpers.frame import report
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
from homeassistant.util import slugify, uuid as uuid_util
|
from homeassistant.util import slugify, uuid as uuid_util
|
||||||
from homeassistant.util.enum import StrEnum
|
|
||||||
from homeassistant.util.yaml import load_yaml
|
from homeassistant.util.yaml import load_yaml
|
||||||
|
|
||||||
from .typing import UNDEFINED, UndefinedType
|
from .typing import UNDEFINED, UndefinedType
|
||||||
|
|
|
@ -14,6 +14,7 @@ from homeassistant.const import (
|
||||||
EVENT_COMPONENT_LOADED,
|
EVENT_COMPONENT_LOADED,
|
||||||
EVENT_HOMEASSISTANT_START,
|
EVENT_HOMEASSISTANT_START,
|
||||||
PLATFORM_FORMAT,
|
PLATFORM_FORMAT,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import CALLBACK_TYPE
|
from homeassistant.core import CALLBACK_TYPE
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
@ -26,34 +27,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ATTR_COMPONENT = "component"
|
ATTR_COMPONENT = "component"
|
||||||
|
|
||||||
BASE_PLATFORMS = {
|
BASE_PLATFORMS = {platform.value for platform in Platform}
|
||||||
"air_quality",
|
|
||||||
"alarm_control_panel",
|
|
||||||
"binary_sensor",
|
|
||||||
"camera",
|
|
||||||
"calendar",
|
|
||||||
"climate",
|
|
||||||
"cover",
|
|
||||||
"device_tracker",
|
|
||||||
"fan",
|
|
||||||
"humidifier",
|
|
||||||
"image_processing",
|
|
||||||
"light",
|
|
||||||
"lock",
|
|
||||||
"media_player",
|
|
||||||
"notify",
|
|
||||||
"number",
|
|
||||||
"remote",
|
|
||||||
"scene",
|
|
||||||
"select",
|
|
||||||
"sensor",
|
|
||||||
"siren",
|
|
||||||
"switch",
|
|
||||||
"tts",
|
|
||||||
"vacuum",
|
|
||||||
"water_heater",
|
|
||||||
"weather",
|
|
||||||
}
|
|
||||||
|
|
||||||
DATA_SETUP_DONE = "setup_done"
|
DATA_SETUP_DONE = "setup_done"
|
||||||
DATA_SETUP_STARTED = "setup_started"
|
DATA_SETUP_STARTED = "setup_started"
|
||||||
|
|
|
@ -10,8 +10,6 @@ from typing import Any, cast
|
||||||
|
|
||||||
import ciso8601
|
import ciso8601
|
||||||
|
|
||||||
from homeassistant.const import MATCH_ALL
|
|
||||||
|
|
||||||
if sys.version_info[:2] >= (3, 9):
|
if sys.version_info[:2] >= (3, 9):
|
||||||
import zoneinfo
|
import zoneinfo
|
||||||
else:
|
else:
|
||||||
|
@ -215,7 +213,7 @@ def get_age(date: dt.datetime) -> str:
|
||||||
|
|
||||||
def parse_time_expression(parameter: Any, min_value: int, max_value: int) -> list[int]:
|
def parse_time_expression(parameter: Any, min_value: int, max_value: int) -> list[int]:
|
||||||
"""Parse the time expression part and return a list of times to match."""
|
"""Parse the time expression part and return a list of times to match."""
|
||||||
if parameter is None or parameter == MATCH_ALL:
|
if parameter is None or parameter == "*":
|
||||||
res = list(range(min_value, max_value + 1))
|
res = list(range(min_value, max_value + 1))
|
||||||
elif isinstance(parameter, str):
|
elif isinstance(parameter, str):
|
||||||
if parameter.startswith("/"):
|
if parameter.startswith("/"):
|
||||||
|
|
|
@ -4,8 +4,8 @@ from __future__ import annotations
|
||||||
import ast
|
import ast
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from homeassistant.const import Platform
|
||||||
from homeassistant.requirements import DISCOVERY_INTEGRATIONS
|
from homeassistant.requirements import DISCOVERY_INTEGRATIONS
|
||||||
from homeassistant.setup import BASE_PLATFORMS
|
|
||||||
|
|
||||||
from .model import Integration
|
from .model import Integration
|
||||||
|
|
||||||
|
@ -91,12 +91,11 @@ class ImportCollector(ast.NodeVisitor):
|
||||||
|
|
||||||
|
|
||||||
ALLOWED_USED_COMPONENTS = {
|
ALLOWED_USED_COMPONENTS = {
|
||||||
|
*{platform.value for platform in Platform},
|
||||||
# Internal integrations
|
# Internal integrations
|
||||||
"alert",
|
"alert",
|
||||||
"automation",
|
"automation",
|
||||||
"button",
|
|
||||||
"conversation",
|
"conversation",
|
||||||
"button",
|
|
||||||
"device_automation",
|
"device_automation",
|
||||||
"frontend",
|
"frontend",
|
||||||
"group",
|
"group",
|
||||||
|
@ -119,8 +118,6 @@ ALLOWED_USED_COMPONENTS = {
|
||||||
"webhook",
|
"webhook",
|
||||||
"websocket_api",
|
"websocket_api",
|
||||||
"zone",
|
"zone",
|
||||||
# Entity integrations with platforms
|
|
||||||
*BASE_PLATFORMS,
|
|
||||||
# Other
|
# Other
|
||||||
"mjpeg", # base class, has no reqs or component to load.
|
"mjpeg", # base class, has no reqs or component to load.
|
||||||
"stream", # Stream cannot install on all systems, can be imported without reqs.
|
"stream", # Stream cannot install on all systems, can be imported without reqs.
|
||||||
|
|
1
tests/backports/__init__.py
Normal file
1
tests/backports/__init__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
"""The tests for the backports."""
|
|
@ -4,7 +4,7 @@ from enum import auto
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.util.enum import StrEnum
|
from homeassistant.backports.enum import StrEnum
|
||||||
|
|
||||||
|
|
||||||
def test_strenum():
|
def test_strenum():
|
Loading…
Add table
Add a link
Reference in a new issue