File: behavior_script.py

package info (click to toggle)
python-aiohue 4.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 612 kB
  • sloc: python: 4,444; sh: 30; makefile: 5
file content (62 lines) | stat: -rw-r--r-- 1,884 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""
Model(s) for behavior_script resource on HUE bridge.

API to discover available scripts that can be instantiated
https://developers.meethue.com/develop/hue-api-v2/api-reference/#resource_behavior_script
"""

from dataclasses import dataclass
from enum import Enum

from .resource import ResourceTypes


class BehaviorScriptCategory(Enum):
    """Enum with various Behavior Script Categories."""

    AUTOMATION = "automation"
    ENTERTAINMENT = "entertainment"
    ACCESSORY = "accessory"
    OTHER = "other"

    @classmethod
    def _missing_(cls: type, value: object):  # noqa: ARG003
        """Set default enum member if an unknown value is provided."""
        return BehaviorScriptCategory.OTHER


@dataclass
class BehaviorScriptMetadata:
    """Represent BehaviorScript Metadata object as used by BehaviorScript resource."""

    name: str | None = None
    category: BehaviorScriptCategory = BehaviorScriptCategory.OTHER


@dataclass
class BehaviorScript:
    """
    Represent a (full) `BehaviorScript` resource when retrieved from the api.

    Available scripts that can be instantiated.
    https://developers.meethue.com/develop/hue-api-v2/api-reference/#resource_behavior_script_get
    """

    id: str
    description: str
    # configuration_schema: required(object)
    # JSON schema object used for validating ScriptInstance.configuration property.
    configuration_schema: dict
    # trigger_schema: required(object)
    # JSON schema object used for validating ScriptInstance.trigger property.
    trigger_schema: dict
    # state_schema: required(object)
    # JSON schema of ScriptInstance.state property.
    state_schema: dict
    version: str
    metadata: BehaviorScriptMetadata
    supported_features: list[str] | None
    max_number_instances: int | None = None

    id_v1: str | None = None
    type: ResourceTypes = ResourceTypes.BEHAVIOR_SCRIPT