mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Revert "Move Platform StrEnum to const" (#60875)
This commit is contained in:
parent
6e220d5d17
commit
c8b0a3b667
@ -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,8 +3,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Final
|
from typing import Final
|
||||||
|
|
||||||
from homeassistant.util.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"
|
||||||
@ -18,42 +16,6 @@ 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"
|
|
||||||
SST = "sst"
|
|
||||||
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 = "*"
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ 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,
|
||||||
@ -62,6 +63,41 @@ 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."""
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ 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
|
||||||
@ -27,7 +26,34 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
ATTR_COMPONENT = "component"
|
ATTR_COMPONENT = "component"
|
||||||
|
|
||||||
BASE_PLATFORMS = {platform.value for platform in Platform}
|
BASE_PLATFORMS = {
|
||||||
|
"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,6 +10,8 @@ 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:
|
||||||
@ -213,7 +215,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 == "*":
|
if parameter is None or parameter == MATCH_ALL:
|
||||||
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,11 +91,12 @@ 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",
|
||||||
@ -118,6 +119,8 @@ 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.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user