mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 09:03:13 +01:00
Move vacuum constants to const.py (#161620)
This commit is contained in:
@@ -4,7 +4,6 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from datetime import timedelta
|
||||
from enum import IntFlag
|
||||
from functools import partial
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Any, final
|
||||
@@ -36,20 +35,20 @@ from homeassistant.helpers.frame import ReportBehavior, report_usage
|
||||
from homeassistant.helpers.icon import icon_for_battery_level
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.loader import bind_hass
|
||||
from homeassistant.util.hass_dict import HassKey
|
||||
|
||||
from .const import ( # noqa: F401
|
||||
_DEPRECATED_STATE_CLEANING,
|
||||
_DEPRECATED_STATE_DOCKED,
|
||||
_DEPRECATED_STATE_ERROR,
|
||||
_DEPRECATED_STATE_RETURNING,
|
||||
DATA_COMPONENT,
|
||||
DOMAIN,
|
||||
VacuumActivity,
|
||||
VacuumEntityFeature,
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DATA_COMPONENT: HassKey[EntityComponent[StateVacuumEntity]] = HassKey(DOMAIN)
|
||||
ENTITY_ID_FORMAT = DOMAIN + ".{}"
|
||||
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
|
||||
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
|
||||
@@ -85,25 +84,6 @@ _BATTERY_DEPRECATION_IGNORED_PLATFORMS = (
|
||||
)
|
||||
|
||||
|
||||
class VacuumEntityFeature(IntFlag):
|
||||
"""Supported features of the vacuum entity."""
|
||||
|
||||
TURN_ON = 1 # Deprecated, not supported by StateVacuumEntity
|
||||
TURN_OFF = 2 # Deprecated, not supported by StateVacuumEntity
|
||||
PAUSE = 4
|
||||
STOP = 8
|
||||
RETURN_HOME = 16
|
||||
FAN_SPEED = 32
|
||||
BATTERY = 64
|
||||
STATUS = 128 # Deprecated, not supported by StateVacuumEntity
|
||||
SEND_COMMAND = 256
|
||||
LOCATE = 512
|
||||
CLEAN_SPOT = 1024
|
||||
MAP = 2048
|
||||
STATE = 4096 # Must be set by vacuum platforms derived from StateVacuumEntity
|
||||
START = 8192
|
||||
|
||||
|
||||
# mypy: disallow-any-generics
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from enum import StrEnum
|
||||
from enum import IntFlag, StrEnum
|
||||
from functools import partial
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from homeassistant.helpers.deprecation import (
|
||||
DeprecatedConstantEnum,
|
||||
@@ -11,9 +12,16 @@ from homeassistant.helpers.deprecation import (
|
||||
check_if_deprecated_constant,
|
||||
dir_with_deprecated_constants,
|
||||
)
|
||||
from homeassistant.helpers.entity_component import EntityComponent
|
||||
from homeassistant.util.hass_dict import HassKey
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import StateVacuumEntity
|
||||
|
||||
DOMAIN = "vacuum"
|
||||
|
||||
DATA_COMPONENT: HassKey[EntityComponent[StateVacuumEntity]] = HassKey(DOMAIN)
|
||||
|
||||
|
||||
class VacuumActivity(StrEnum):
|
||||
"""Vacuum activity states."""
|
||||
@@ -26,6 +34,25 @@ class VacuumActivity(StrEnum):
|
||||
ERROR = "error"
|
||||
|
||||
|
||||
class VacuumEntityFeature(IntFlag):
|
||||
"""Supported features of the vacuum entity."""
|
||||
|
||||
TURN_ON = 1 # Deprecated, not supported by StateVacuumEntity
|
||||
TURN_OFF = 2 # Deprecated, not supported by StateVacuumEntity
|
||||
PAUSE = 4
|
||||
STOP = 8
|
||||
RETURN_HOME = 16
|
||||
FAN_SPEED = 32
|
||||
BATTERY = 64
|
||||
STATUS = 128 # Deprecated, not supported by StateVacuumEntity
|
||||
SEND_COMMAND = 256
|
||||
LOCATE = 512
|
||||
CLEAN_SPOT = 1024
|
||||
MAP = 2048
|
||||
STATE = 4096 # Must be set by vacuum platforms derived from StateVacuumEntity
|
||||
START = 8192
|
||||
|
||||
|
||||
# These STATE_* constants are deprecated as of Home Assistant 2025.1.
|
||||
# Please use the VacuumActivity enum instead.
|
||||
_DEPRECATED_STATE_CLEANING = DeprecatedConstantEnum(VacuumActivity.CLEANING, "2026.1")
|
||||
|
||||
Reference in New Issue
Block a user