Home Assistant Unofficial Reference 2024.12.1
const.py
Go to the documentation of this file.
1 """Constants for Camera component."""
2 
3 from __future__ import annotations
4 
5 from enum import StrEnum
6 from functools import partial
7 from typing import TYPE_CHECKING, Final
8 
10  DeprecatedConstantEnum,
11  all_with_deprecated_constants,
12  check_if_deprecated_constant,
13  dir_with_deprecated_constants,
14 )
15 from homeassistant.util.hass_dict import HassKey
16 
17 if TYPE_CHECKING:
18  from homeassistant.helpers.entity_component import EntityComponent
19 
20  from . import Camera
21  from .prefs import CameraPreferences
22 
23 DOMAIN: Final = "camera"
24 DATA_COMPONENT: HassKey[EntityComponent[Camera]] = HassKey(DOMAIN)
25 
26 DATA_CAMERA_PREFS: HassKey[CameraPreferences] = HassKey("camera_prefs")
27 
28 PREF_PRELOAD_STREAM: Final = "preload_stream"
29 PREF_ORIENTATION: Final = "orientation"
30 
31 SERVICE_RECORD: Final = "record"
32 
33 CONF_LOOKBACK: Final = "lookback"
34 CONF_DURATION: Final = "duration"
35 
36 CAMERA_STREAM_SOURCE_TIMEOUT: Final = 10
37 CAMERA_IMAGE_TIMEOUT: Final = 10
38 
39 
40 class CameraState(StrEnum):
41  """Camera entity states."""
42 
43  RECORDING = "recording"
44  STREAMING = "streaming"
45  IDLE = "idle"
46 
47 
48 class StreamType(StrEnum):
49  """Camera stream type.
50 
51  A camera that supports CAMERA_SUPPORT_STREAM may have a single stream
52  type which is used to inform the frontend which player to use.
53  Streams with RTSP sources typically use the stream component which uses
54  HLS for display. WebRTC streams use the home assistant core for a signal
55  path to initiate a stream, but the stream itself is between the client and
56  device.
57  """
58 
59  HLS = "hls"
60  WEB_RTC = "web_rtc"
61 
62 
63 # These constants are deprecated as of Home Assistant 2022.5
64 # Please use the StreamType enum instead.
65 _DEPRECATED_STREAM_TYPE_HLS = DeprecatedConstantEnum(StreamType.HLS, "2025.1")
66 _DEPRECATED_STREAM_TYPE_WEB_RTC = DeprecatedConstantEnum(StreamType.WEB_RTC, "2025.1")
67 
68 
69 # These can be removed if no deprecated constant are in this module anymore
70 __getattr__ = partial(check_if_deprecated_constant, module_globals=globals())
71 __dir__ = partial(
72  dir_with_deprecated_constants, module_globals_keys=[*globals().keys()]
73 )
74 __all__ = all_with_deprecated_constants(globals())
list[str] all_with_deprecated_constants(dict[str, Any] module_globals)
Definition: deprecation.py:356