|
| 1 | +""" |
| 2 | +IR Emitter entity definitions. |
| 3 | +
|
| 4 | +:copyright: (c) 2023 by Unfolded Circle ApS. |
| 5 | +:license: MPL-2.0, see LICENSE for more details. |
| 6 | +""" |
| 7 | + |
| 8 | +from enum import Enum |
| 9 | +from typing import Any |
| 10 | + |
| 11 | +from .api_definitions import CommandHandler |
| 12 | +from .entity import Entity, EntityTypes |
| 13 | + |
| 14 | + |
| 15 | +class States(str, Enum): |
| 16 | + """IR Emitter entity states.""" |
| 17 | + |
| 18 | + UNAVAILABLE = "UNAVAILABLE" |
| 19 | + UNKNOWN = "UNKNOWN" |
| 20 | + ON = "ON" |
| 21 | + |
| 22 | + |
| 23 | +class Features(str, Enum): |
| 24 | + """IR Emitter entity features.""" |
| 25 | + |
| 26 | + SEND_IR = "send_ir" |
| 27 | + |
| 28 | + |
| 29 | +class Attributes(str, Enum): |
| 30 | + """IR Emitter entity attributes.""" |
| 31 | + |
| 32 | + STATE = "state" |
| 33 | + |
| 34 | + |
| 35 | +class Commands(str, Enum): |
| 36 | + """IR Emitter entity commands.""" |
| 37 | + |
| 38 | + SEND_IR = "send_ir" |
| 39 | + STOP_IR = "stop_ir" |
| 40 | + |
| 41 | + |
| 42 | +class DeviceClasses(str, Enum): |
| 43 | + """IR Emitter entity device classes.""" |
| 44 | + |
| 45 | + |
| 46 | +class Options(str, Enum): |
| 47 | + """IR Emitter entity options.""" |
| 48 | + |
| 49 | + PORTS = "ports" |
| 50 | + IR_FORMATS = "ir_formats" |
| 51 | + |
| 52 | + |
| 53 | +class IREmitter(Entity): |
| 54 | + """ |
| 55 | + IR Emitter entity class. |
| 56 | +
|
| 57 | + See https://github.com/unfoldedcircle/core-api/blob/main/doc/entities/entity_ir_emitter.md |
| 58 | + for more information. |
| 59 | + """ |
| 60 | + |
| 61 | + # pylint: disable=R0917 |
| 62 | + def __init__( |
| 63 | + self, |
| 64 | + identifier: str, |
| 65 | + name: str | dict[str, str], |
| 66 | + features: list[Features], |
| 67 | + attributes: dict[str, Any], |
| 68 | + *, |
| 69 | + options: dict[str, Any] | None = None, |
| 70 | + area: str | None = None, |
| 71 | + cmd_handler: CommandHandler = None, |
| 72 | + ): |
| 73 | + """ |
| 74 | + Create IR Emitter instance. |
| 75 | +
|
| 76 | + :param identifier: entity identifier |
| 77 | + :param name: friendly name |
| 78 | + :param features: IR Emitter features |
| 79 | + :param attributes: IR Emitter attributes |
| 80 | + :param options: IR Emitter options |
| 81 | + :param area: optional area |
| 82 | + :param cmd_handler: handler for entity commands |
| 83 | + """ |
| 84 | + super().__init__( |
| 85 | + identifier, |
| 86 | + name, |
| 87 | + EntityTypes.IR_EMITTER, |
| 88 | + features, |
| 89 | + attributes, |
| 90 | + options=options, |
| 91 | + area=area, |
| 92 | + cmd_handler=cmd_handler, |
| 93 | + ) |
0 commit comments