Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ucapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from .light import Light # noqa: F401
from .media_player import MediaPlayer # noqa: F401
from .remote import Remote # noqa: F401
from .select import Select # noqa: F401
from .sensor import Sensor # noqa: F401
from .switch import Switch # noqa: F401
from .voice_assistant import VoiceAssistant # noqa: F401
Expand Down
1 change: 1 addition & 0 deletions ucapi/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class EntityTypes(str, Enum):
LIGHT = "light"
MEDIA_PLAYER = "media_player"
REMOTE = "remote"
SELECT = "select"
SENSOR = "sensor"
SWITCH = "switch"
IR_EMITTER = "ir_emitter"
Expand Down
95 changes: 95 additions & 0 deletions ucapi/select.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
"""
Switch entity definitions.

:copyright: (c) 2023 by Unfolded Circle ApS.
:license: MPL-2.0, see LICENSE for more details.
"""

from enum import Enum
from typing import Any

from .api_definitions import CommandHandler
from .entity import Entity, EntityTypes


class States(str, Enum):
"""Select entity states."""

UNAVAILABLE = "UNAVAILABLE"
UNKNOWN = "UNKNOWN"
ON = "ON"


class Features(str, Enum):
"""Select entity features."""


class Attributes(str, Enum):
"""Select entity attributes."""

STATE = "state"
CURRENT_OPTION = "current_option"
OPTIONS = "options"


class Commands(str, Enum):
"""Select entity commands."""

SELECT_OPTION = "select_option"
SELECT_FIRST = "select_first"
SELECT_LAST = "select_last"
SELECT_NEXT = "select_next"
SELECT_PREVIOUS = "select_previous"


class DeviceClasses(str, Enum):
"""Select entity device classes."""


class Options(str, Enum):
"""Select entity options."""


class Select(Entity):
"""
Select entity class.

See https://github.com/unfoldedcircle/core-api/blob/main/doc/entities/entity_select.md
for more information.
"""

# pylint: disable=R0917
def __init__(
self,
identifier: str,
name: str | dict[str, str],
features: list[Features],
attributes: dict[str, Any],
device_class: DeviceClasses | None = None,
options: dict[str, Any] | None = None,
area: str | None = None,
cmd_handler: CommandHandler = None,
):
Comment thread
zehnm marked this conversation as resolved.
"""
Create select-entity instance.

:param identifier: entity identifier
:param name: friendly name
:param features: select features
:param attributes: select attributes
:param device_class: optional select device class
:param options: options
:param area: optional area
:param cmd_handler: handler for entity commands
"""
super().__init__(
identifier,
name,
EntityTypes.SELECT,
features,
attributes,
device_class=device_class,
options=options,
area=area,
cmd_handler=cmd_handler,
)
Loading