Home Assistant Unofficial Reference 2024.12.1
const.py
Go to the documentation of this file.
1 """Device tracker constants."""
2 
3 from __future__ import annotations
4 
5 from datetime import timedelta
6 from enum import StrEnum
7 from functools import partial
8 import logging
9 from typing import Final
10 
12  DeprecatedConstantEnum,
13  all_with_deprecated_constants,
14  check_if_deprecated_constant,
15  dir_with_deprecated_constants,
16 )
17 from homeassistant.util.signal_type import SignalType
18 
19 LOGGER: Final = logging.getLogger(__package__)
20 
21 DOMAIN: Final = "device_tracker"
22 ENTITY_ID_FORMAT: Final = DOMAIN + ".{}"
23 
24 PLATFORM_TYPE_LEGACY: Final = "legacy"
25 PLATFORM_TYPE_ENTITY: Final = "entity_platform"
26 
27 
28 class SourceType(StrEnum):
29  """Source type for device trackers."""
30 
31  GPS = "gps"
32  ROUTER = "router"
33  BLUETOOTH = "bluetooth"
34  BLUETOOTH_LE = "bluetooth_le"
35 
36 
37 # SOURCE_TYPE_* below are deprecated as of 2022.9
38 # use the SourceType enum instead.
39 _DEPRECATED_SOURCE_TYPE_GPS: Final = DeprecatedConstantEnum(SourceType.GPS, "2025.1")
40 _DEPRECATED_SOURCE_TYPE_ROUTER: Final = DeprecatedConstantEnum(
41  SourceType.ROUTER, "2025.1"
42 )
43 _DEPRECATED_SOURCE_TYPE_BLUETOOTH: Final = DeprecatedConstantEnum(
44  SourceType.BLUETOOTH, "2025.1"
45 )
46 _DEPRECATED_SOURCE_TYPE_BLUETOOTH_LE: Final = DeprecatedConstantEnum(
47  SourceType.BLUETOOTH_LE, "2025.1"
48 )
49 
50 CONF_SCAN_INTERVAL: Final = "interval_seconds"
51 SCAN_INTERVAL: Final = timedelta(seconds=12)
52 
53 CONF_TRACK_NEW: Final = "track_new_devices"
54 DEFAULT_TRACK_NEW: Final = True
55 
56 CONF_CONSIDER_HOME: Final = "consider_home"
57 DEFAULT_CONSIDER_HOME: Final = timedelta(seconds=180)
58 
59 CONF_NEW_DEVICE_DEFAULTS: Final = "new_device_defaults"
60 
61 ATTR_ATTRIBUTES: Final = "attributes"
62 ATTR_BATTERY: Final = "battery"
63 ATTR_DEV_ID: Final = "dev_id"
64 ATTR_GPS: Final = "gps"
65 ATTR_HOST_NAME: Final = "host_name"
66 ATTR_LOCATION_NAME: Final = "location_name"
67 ATTR_MAC: Final = "mac"
68 ATTR_SOURCE_TYPE: Final = "source_type"
69 ATTR_CONSIDER_HOME: Final = "consider_home"
70 ATTR_IP: Final = "ip"
71 
72 CONNECTED_DEVICE_REGISTERED = SignalType[dict[str, str | None]](
73  "device_tracker_connected_device_registered"
74 )
75 
76 # These can be removed if no deprecated constant are in this module anymore
77 __getattr__ = partial(check_if_deprecated_constant, module_globals=globals())
78 __dir__ = partial(
79  dir_with_deprecated_constants, module_globals_keys=[*globals().keys()]
80 )
81 __all__ = all_with_deprecated_constants(globals())
list[str] all_with_deprecated_constants(dict[str, Any] module_globals)
Definition: deprecation.py:356