Home Assistant Unofficial Reference 2024.12.1
const.py
Go to the documentation of this file.
1 """Provides the constants needed for component."""
2 
3 from enum import IntFlag, StrEnum
4 from functools import partial
5 from typing import Final
6 
8  DeprecatedConstantEnum,
9  all_with_deprecated_constants,
10  check_if_deprecated_constant,
11  dir_with_deprecated_constants,
12 )
13 
14 DOMAIN: Final = "alarm_control_panel"
15 
16 ATTR_CHANGED_BY: Final = "changed_by"
17 ATTR_CODE_ARM_REQUIRED: Final = "code_arm_required"
18 
19 
20 class AlarmControlPanelState(StrEnum):
21  """Alarm control panel entity states."""
22 
23  DISARMED = "disarmed"
24  ARMED_HOME = "armed_home"
25  ARMED_AWAY = "armed_away"
26  ARMED_NIGHT = "armed_night"
27  ARMED_VACATION = "armed_vacation"
28  ARMED_CUSTOM_BYPASS = "armed_custom_bypass"
29  PENDING = "pending"
30  ARMING = "arming"
31  DISARMING = "disarming"
32  TRIGGERED = "triggered"
33 
34 
35 class CodeFormat(StrEnum):
36  """Code formats for the Alarm Control Panel."""
37 
38  TEXT = "text"
39  NUMBER = "number"
40 
41 
42 # These constants are deprecated as of Home Assistant 2022.5, can be removed in 2025.1
43 # Please use the CodeFormat enum instead.
44 _DEPRECATED_FORMAT_TEXT: Final = DeprecatedConstantEnum(CodeFormat.TEXT, "2025.1")
45 _DEPRECATED_FORMAT_NUMBER: Final = DeprecatedConstantEnum(CodeFormat.NUMBER, "2025.1")
46 
47 
49  """Supported features of the alarm control panel entity."""
50 
51  ARM_HOME = 1
52  ARM_AWAY = 2
53  ARM_NIGHT = 4
54  TRIGGER = 8
55  ARM_CUSTOM_BYPASS = 16
56  ARM_VACATION = 32
57 
58 
59 # These constants are deprecated as of Home Assistant 2022.5
60 # Please use the AlarmControlPanelEntityFeature enum instead.
61 _DEPRECATED_SUPPORT_ALARM_ARM_HOME: Final = DeprecatedConstantEnum(
62  AlarmControlPanelEntityFeature.ARM_HOME, "2025.1"
63 )
64 _DEPRECATED_SUPPORT_ALARM_ARM_AWAY: Final = DeprecatedConstantEnum(
65  AlarmControlPanelEntityFeature.ARM_AWAY, "2025.1"
66 )
67 _DEPRECATED_SUPPORT_ALARM_ARM_NIGHT: Final = DeprecatedConstantEnum(
68  AlarmControlPanelEntityFeature.ARM_NIGHT, "2025.1"
69 )
70 _DEPRECATED_SUPPORT_ALARM_TRIGGER: Final = DeprecatedConstantEnum(
71  AlarmControlPanelEntityFeature.TRIGGER, "2025.1"
72 )
73 _DEPRECATED_SUPPORT_ALARM_ARM_CUSTOM_BYPASS: Final = DeprecatedConstantEnum(
74  AlarmControlPanelEntityFeature.ARM_CUSTOM_BYPASS, "2025.1"
75 )
76 _DEPRECATED_SUPPORT_ALARM_ARM_VACATION: Final = DeprecatedConstantEnum(
77  AlarmControlPanelEntityFeature.ARM_VACATION, "2025.1"
78 )
79 
80 CONDITION_TRIGGERED: Final = "is_triggered"
81 CONDITION_DISARMED: Final = "is_disarmed"
82 CONDITION_ARMED_HOME: Final = "is_armed_home"
83 CONDITION_ARMED_AWAY: Final = "is_armed_away"
84 CONDITION_ARMED_NIGHT: Final = "is_armed_night"
85 CONDITION_ARMED_VACATION: Final = "is_armed_vacation"
86 CONDITION_ARMED_CUSTOM_BYPASS: Final = "is_armed_custom_bypass"
87 
88 # These can be removed if no deprecated constant are in this module anymore
89 __getattr__ = partial(check_if_deprecated_constant, module_globals=globals())
90 __dir__ = partial(
91  dir_with_deprecated_constants, module_globals_keys=[*globals().keys()]
92 )
93 __all__ = all_with_deprecated_constants(globals())
list[str] all_with_deprecated_constants(dict[str, Any] module_globals)
Definition: deprecation.py:356