Use IntFlag for EntityFeature (#81903)

This commit is contained in:
epenet 2022-11-16 12:43:17 +01:00 committed by GitHub
parent e01115fd1f
commit a91abebea8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 28 additions and 28 deletions

View File

@ -1,5 +1,5 @@
"""Provides the constants needed for component.""" """Provides the constants needed for component."""
from enum import IntEnum from enum import IntFlag
from typing import Final from typing import Final
from homeassistant.backports.enum import StrEnum from homeassistant.backports.enum import StrEnum
@ -23,7 +23,7 @@ FORMAT_TEXT: Final = "text"
FORMAT_NUMBER: Final = "number" FORMAT_NUMBER: Final = "number"
class AlarmControlPanelEntityFeature(IntEnum): class AlarmControlPanelEntityFeature(IntFlag):
"""Supported features of the alarm control panel entity.""" """Supported features of the alarm control panel entity."""
ARM_HOME = 1 ARM_HOME = 1

View File

@ -7,7 +7,7 @@ from collections.abc import Awaitable, Callable, Iterable
from contextlib import suppress from contextlib import suppress
from dataclasses import asdict, dataclass from dataclasses import asdict, dataclass
from datetime import datetime, timedelta from datetime import datetime, timedelta
from enum import IntEnum from enum import IntFlag
from functools import partial from functools import partial
import logging import logging
import os import os
@ -95,7 +95,7 @@ STATE_STREAMING: Final = "streaming"
STATE_IDLE: Final = "idle" STATE_IDLE: Final = "idle"
class CameraEntityFeature(IntEnum): class CameraEntityFeature(IntFlag):
"""Supported features of the camera entity.""" """Supported features of the camera entity."""
ON_OFF = 1 ON_OFF = 1

View File

@ -1,6 +1,6 @@
"""Provides the constants needed for component.""" """Provides the constants needed for component."""
from enum import IntEnum from enum import IntFlag
from homeassistant.backports.enum import StrEnum from homeassistant.backports.enum import StrEnum
@ -146,7 +146,7 @@ SERVICE_SET_SWING_MODE = "set_swing_mode"
SERVICE_SET_TEMPERATURE = "set_temperature" SERVICE_SET_TEMPERATURE = "set_temperature"
class ClimateEntityFeature(IntEnum): class ClimateEntityFeature(IntFlag):
"""Supported features of the climate entity.""" """Supported features of the climate entity."""
TARGET_TEMPERATURE = 1 TARGET_TEMPERATURE = 1

View File

@ -4,7 +4,7 @@ from __future__ import annotations
from collections.abc import Callable from collections.abc import Callable
from dataclasses import dataclass from dataclasses import dataclass
from datetime import timedelta from datetime import timedelta
from enum import IntEnum from enum import IntFlag
import functools as ft import functools as ft
import logging import logging
from typing import Any, TypeVar, final from typing import Any, TypeVar, final
@ -86,7 +86,7 @@ DEVICE_CLASS_WINDOW = CoverDeviceClass.WINDOW.value
# mypy: disallow-any-generics # mypy: disallow-any-generics
class CoverEntityFeature(IntEnum): class CoverEntityFeature(IntFlag):
"""Supported features of the cover entity.""" """Supported features of the cover entity."""
OPEN = 1 OPEN = 1

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from dataclasses import dataclass from dataclasses import dataclass
from datetime import timedelta from datetime import timedelta
from enum import IntEnum from enum import IntFlag
import functools as ft import functools as ft
import logging import logging
import math import math
@ -41,7 +41,7 @@ SCAN_INTERVAL = timedelta(seconds=30)
ENTITY_ID_FORMAT = DOMAIN + ".{}" ENTITY_ID_FORMAT = DOMAIN + ".{}"
class FanEntityFeature(IntEnum): class FanEntityFeature(IntFlag):
"""Supported features of the fan entity.""" """Supported features of the fan entity."""
SET_SPEED = 1 SET_SPEED = 1

View File

@ -1,5 +1,5 @@
"""Provides the constants needed for component.""" """Provides the constants needed for component."""
from enum import IntEnum from enum import IntFlag
MODE_NORMAL = "normal" MODE_NORMAL = "normal"
MODE_ECO = "eco" MODE_ECO = "eco"
@ -30,7 +30,7 @@ SERVICE_SET_MODE = "set_mode"
SERVICE_SET_HUMIDITY = "set_humidity" SERVICE_SET_HUMIDITY = "set_humidity"
class HumidifierEntityFeature(IntEnum): class HumidifierEntityFeature(IntFlag):
"""Supported features of the alarm control panel entity.""" """Supported features of the alarm control panel entity."""
MODES = 1 MODES = 1

View File

@ -5,7 +5,7 @@ from collections.abc import Iterable
import csv import csv
import dataclasses import dataclasses
from datetime import timedelta from datetime import timedelta
from enum import IntEnum from enum import IntFlag
import logging import logging
import os import os
from typing import Any, cast, final from typing import Any, cast, final
@ -41,7 +41,7 @@ DATA_PROFILES = "light_profiles"
ENTITY_ID_FORMAT = DOMAIN + ".{}" ENTITY_ID_FORMAT = DOMAIN + ".{}"
class LightEntityFeature(IntEnum): class LightEntityFeature(IntFlag):
"""Supported features of the light entity.""" """Supported features of the light entity."""
EFFECT = 4 EFFECT = 4

View File

@ -3,7 +3,7 @@ from __future__ import annotations
from dataclasses import dataclass from dataclasses import dataclass
from datetime import timedelta from datetime import timedelta
from enum import IntEnum from enum import IntFlag
import functools as ft import functools as ft
import logging import logging
from typing import Any, final from typing import Any, final
@ -48,7 +48,7 @@ MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
LOCK_SERVICE_SCHEMA = make_entity_service_schema({vol.Optional(ATTR_CODE): cv.string}) LOCK_SERVICE_SCHEMA = make_entity_service_schema({vol.Optional(ATTR_CODE): cv.string})
class LockEntityFeature(IntEnum): class LockEntityFeature(IntFlag):
"""Supported features of the lock entity.""" """Supported features of the lock entity."""
OPEN = 1 OPEN = 1

View File

@ -1,5 +1,5 @@
"""Provides the constants needed for component.""" """Provides the constants needed for component."""
from enum import IntEnum from enum import IntFlag
from homeassistant.backports.enum import StrEnum from homeassistant.backports.enum import StrEnum
@ -176,7 +176,7 @@ REPEAT_MODE_ONE = "one"
REPEAT_MODES = [REPEAT_MODE_OFF, REPEAT_MODE_ALL, REPEAT_MODE_ONE] REPEAT_MODES = [REPEAT_MODE_OFF, REPEAT_MODE_ALL, REPEAT_MODE_ONE]
class MediaPlayerEntityFeature(IntEnum): class MediaPlayerEntityFeature(IntFlag):
"""Supported features of the media player entity.""" """Supported features of the media player entity."""
PAUSE = 1 PAUSE = 1

View File

@ -4,7 +4,7 @@ from __future__ import annotations
from collections.abc import Iterable from collections.abc import Iterable
from dataclasses import dataclass from dataclasses import dataclass
from datetime import timedelta from datetime import timedelta
from enum import IntEnum from enum import IntFlag
import functools as ft import functools as ft
import logging import logging
from typing import Any, final from typing import Any, final
@ -61,7 +61,7 @@ DEFAULT_DELAY_SECS = 0.4
DEFAULT_HOLD_SECS = 0 DEFAULT_HOLD_SECS = 0
class RemoteEntityFeature(IntEnum): class RemoteEntityFeature(IntFlag):
"""Supported features of the remote entity.""" """Supported features of the remote entity."""
LEARN_COMMAND = 1 LEARN_COMMAND = 1

View File

@ -1,6 +1,6 @@
"""Constants for the siren component.""" """Constants for the siren component."""
from enum import IntEnum from enum import IntFlag
from typing import Final from typing import Final
DOMAIN: Final = "siren" DOMAIN: Final = "siren"
@ -12,7 +12,7 @@ ATTR_DURATION: Final = "duration"
ATTR_VOLUME_LEVEL: Final = "volume_level" ATTR_VOLUME_LEVEL: Final = "volume_level"
class SirenEntityFeature(IntEnum): class SirenEntityFeature(IntFlag):
"""Supported features of the siren entity.""" """Supported features of the siren entity."""
TURN_ON = 1 TURN_ON = 1

View File

@ -1,13 +1,13 @@
"""Constants for the update component.""" """Constants for the update component."""
from __future__ import annotations from __future__ import annotations
from enum import IntEnum from enum import IntFlag
from typing import Final from typing import Final
DOMAIN: Final = "update" DOMAIN: Final = "update"
class UpdateEntityFeature(IntEnum): class UpdateEntityFeature(IntFlag):
"""Supported features of the update entity.""" """Supported features of the update entity."""
INSTALL = 1 INSTALL = 1

View File

@ -4,7 +4,7 @@ from __future__ import annotations
from collections.abc import Mapping from collections.abc import Mapping
from dataclasses import dataclass from dataclasses import dataclass
from datetime import timedelta from datetime import timedelta
from enum import IntEnum from enum import IntFlag
from functools import partial from functools import partial
import logging import logging
from typing import Any, final from typing import Any, final
@ -74,7 +74,7 @@ STATES = [STATE_CLEANING, STATE_DOCKED, STATE_RETURNING, STATE_ERROR]
DEFAULT_NAME = "Vacuum cleaner robot" DEFAULT_NAME = "Vacuum cleaner robot"
class VacuumEntityFeature(IntEnum): class VacuumEntityFeature(IntFlag):
"""Supported features of the vacuum entity.""" """Supported features of the vacuum entity."""
TURN_ON = 1 TURN_ON = 1

View File

@ -4,7 +4,7 @@ from __future__ import annotations
from collections.abc import Mapping from collections.abc import Mapping
from dataclasses import dataclass from dataclasses import dataclass
from datetime import timedelta from datetime import timedelta
from enum import IntEnum from enum import IntFlag
import functools as ft import functools as ft
import logging import logging
from typing import Any, final from typing import Any, final
@ -56,7 +56,7 @@ STATE_HEAT_PUMP = "heat_pump"
STATE_GAS = "gas" STATE_GAS = "gas"
class WaterHeaterEntityFeature(IntEnum): class WaterHeaterEntityFeature(IntFlag):
"""Supported features of the fan entity.""" """Supported features of the fan entity."""
TARGET_TEMPERATURE = 1 TARGET_TEMPERATURE = 1