Home Assistant Unofficial Reference 2024.12.1
const.py
Go to the documentation of this file.
1 """Constants for the Fitbit platform."""
2 
3 from __future__ import annotations
4 
5 from enum import StrEnum
6 from typing import Final
7 
8 from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
9 
10 DOMAIN: Final = "fitbit"
11 
12 ATTR_ACCESS_TOKEN: Final = "access_token"
13 ATTR_REFRESH_TOKEN: Final = "refresh_token"
14 ATTR_LAST_SAVED_AT: Final = "last_saved_at"
15 
16 ATTR_DURATION: Final = "duration"
17 ATTR_DISTANCE: Final = "distance"
18 ATTR_ELEVATION: Final = "elevation"
19 ATTR_HEIGHT: Final = "height"
20 ATTR_WEIGHT: Final = "weight"
21 ATTR_BODY: Final = "body"
22 ATTR_LIQUIDS: Final = "liquids"
23 ATTR_BLOOD_GLUCOSE: Final = "blood glucose"
24 ATTR_BATTERY: Final = "battery"
25 
26 CONF_MONITORED_RESOURCES: Final = "monitored_resources"
27 CONF_CLOCK_FORMAT: Final = "clock_format"
28 ATTRIBUTION: Final = "Data provided by Fitbit.com"
29 
30 FITBIT_AUTH_CALLBACK_PATH: Final = "/api/fitbit/callback"
31 FITBIT_AUTH_START: Final = "/api/fitbit"
32 FITBIT_CONFIG_FILE: Final = "fitbit.conf"
33 FITBIT_DEFAULT_RESOURCES: Final[list[str]] = ["activities/steps"]
34 
35 DEFAULT_CONFIG: Final[dict[str, str]] = {
36  CONF_CLIENT_ID: "CLIENT_ID_HERE",
37  CONF_CLIENT_SECRET: "CLIENT_SECRET_HERE",
38 }
39 DEFAULT_CLOCK_FORMAT: Final = "24H"
40 
41 BATTERY_LEVELS: Final[dict[str, int]] = {
42  "High": 100,
43  "Medium": 50,
44  "Low": 20,
45  "Empty": 0,
46 }
47 
48 
49 class FitbitUnitSystem(StrEnum):
50  """Fitbit unit system set when sending requests to the Fitbit API.
51 
52  This is used as a header to tell the Fitbit API which type of units to return.
53  https://dev.fitbit.com/build/reference/web-api/developer-guide/application-design/#Units
54 
55  Prefer to leave unset for newer configurations to use the Home Assistant default units.
56  """
57 
58  LEGACY_DEFAULT = "default"
59  """When set, will use an appropriate default using a legacy algorithm."""
60 
61  METRIC = "metric"
62  """Use metric units."""
63 
64  EN_US = "en_US"
65  """Use United States units."""
66 
67  EN_GB = "en_GB"
68  """Use United Kingdom units."""
69 
70 
71 CONF_SCOPE: Final = "scope"
72 
73 
74 class FitbitScope(StrEnum):
75  """OAuth scopes for fitbit."""
76 
77  ACTIVITY = "activity"
78  HEART_RATE = "heartrate"
79  NUTRITION = "nutrition"
80  PROFILE = "profile"
81  DEVICE = "settings"
82  SLEEP = "sleep"
83  WEIGHT = "weight"
84 
85 
86 OAUTH2_AUTHORIZE = "https://www.fitbit.com/oauth2/authorize"
87 OAUTH2_TOKEN = "https://api.fitbit.com/oauth2/token"
88 OAUTH_SCOPES = [scope.value for scope in FitbitScope]