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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
"""Constants."""
from __future__ import annotations
from dataclasses import dataclass
from .backports.enum import StrEnum
class Brand(StrEnum):
AUGUST = "august"
YALE_ACCESS = "yale_access"
YALE_HOME = "yale_home"
YALE_GLOBAL = "yale_global" # requires OAuth with Home Assistant
YALE_AUGUST = "yale_august" # requires OAuth with Home Assistant
DEFAULT_BRAND = Brand.AUGUST
@dataclass
class BrandConfig:
"""Brand configuration."""
name: str
branding: str
access_token_header: str
api_key_header: str
branding_header: str
api_key: str
supports_doorbells: bool
supports_alarms: bool
require_oauth: bool
base_url: str
configuration_url: str
pubnub_subscribe_token: str | None
pubnub_publish_token: str | None
HEADER_VALUE_API_KEY_OLD = "7cab4bbd-2693-4fc1-b99b-dec0fb20f9d4"
HEADER_VALUE_API_KEY = "d9984f29-07a6-816e-e1c9-44ec9d1be431"
HEADER_AUGUST_ACCESS_TOKEN = "x-august-access-token" # nosec
HEADER_AUGUST_API_KEY = "x-august-api-key" # nosec
HEADER_AUGUST_BRANDING = "x-august-branding"
HEADER_ACCESS_TOKEN = "x-access-token" # nosec
HEADER_API_KEY = "x-api-key" # nosec
HEADER_BRANDING = "x-branding"
BRAND_CONFIG: dict[Brand, BrandConfig] = {
Brand.AUGUST: BrandConfig(
name="August",
branding="august",
access_token_header=HEADER_AUGUST_ACCESS_TOKEN,
api_key_header=HEADER_AUGUST_API_KEY,
branding_header=HEADER_AUGUST_BRANDING,
api_key=HEADER_VALUE_API_KEY,
supports_doorbells=True,
supports_alarms=False,
require_oauth=False,
base_url="https://api-production.august.com",
configuration_url="https://account.august.com",
pubnub_subscribe_token="sub-c-1030e062-0ebe-11e5-a5c2-0619f8945a4f", # nosec
pubnub_publish_token="pub-c-567d7f2d-270a-438a-a785-f0af12ad8312", # nosec
),
Brand.YALE_ACCESS: BrandConfig(
name="Yale Access",
branding="yale",
access_token_header=HEADER_AUGUST_ACCESS_TOKEN,
api_key_header=HEADER_AUGUST_API_KEY,
branding_header=HEADER_AUGUST_BRANDING,
api_key=HEADER_VALUE_API_KEY,
supports_doorbells=True,
supports_alarms=False,
require_oauth=False,
base_url="https://api-production.august.com",
configuration_url="https://account.august.com",
pubnub_subscribe_token="sub-c-1030e062-0ebe-11e5-a5c2-0619f8945a4f", # nosec
pubnub_publish_token="pub-c-567d7f2d-270a-438a-a785-f0af12ad8312", # nosec
),
Brand.YALE_HOME: BrandConfig(
name="Yale Home",
branding="yale",
access_token_header=HEADER_ACCESS_TOKEN,
api_key_header=HEADER_API_KEY,
branding_header=HEADER_BRANDING,
api_key="6e2a2093-6118-42c5-8a41-e1fd25dce7a1", # 🤞
supports_doorbells=True,
supports_alarms=True,
require_oauth=False,
base_url="https://api.aaecosystem.com",
configuration_url="https://account.aaecosystem.com",
pubnub_subscribe_token="sub-c-c9c38d4d-5796-46c9-9262-af20cf6a1d42", # nosec
pubnub_publish_token="pub-c-353e8881-cf58-4b26-9baf-96f296de0677", # nosec
),
Brand.YALE_GLOBAL: BrandConfig(
name="Yale Global",
branding="yale",
access_token_header=HEADER_ACCESS_TOKEN,
api_key_header=HEADER_API_KEY,
branding_header=HEADER_BRANDING,
# Sadly we currently do not have a way to avoid
# having the API key in the code because it must
# run on the user's device
api_key="d16a1029-d823-4b55-a4ce-a769a9b56f0e",
supports_doorbells=True,
supports_alarms=True, # ??
require_oauth=True,
base_url="https://api.aaecosystem.com",
configuration_url="https://account.aaecosystem.com",
# This brand uses WebSockets and has migrated
# away from PubNub for this purpose which is great
# because its one less credential we have to expose
# to the user
pubnub_publish_token=None,
pubnub_subscribe_token=None,
),
Brand.YALE_AUGUST: BrandConfig(
name="Yale August",
branding="august",
access_token_header=HEADER_AUGUST_ACCESS_TOKEN,
api_key_header=HEADER_AUGUST_API_KEY,
branding_header=HEADER_AUGUST_BRANDING,
api_key="66814fd9-af2c-426c-9710-b37e7eadfb51",
supports_doorbells=True,
supports_alarms=False,
require_oauth=True,
base_url="https://api-production.august.com",
configuration_url="https://account.august.com",
pubnub_subscribe_token="sub-c-1030e062-0ebe-11e5-a5c2-0619f8945a4f", # nosec
pubnub_publish_token="pub-c-567d7f2d-270a-438a-a785-f0af12ad8312", # nosec
),
}
BRANDS = {brand: brand_config.name for brand, brand_config in BRAND_CONFIG.items()}
BRANDS_WITHOUT_OAUTH = {
brand: brand_config.name
for brand, brand_config in BRAND_CONFIG.items()
if not brand_config.require_oauth
}
BRANDING = {
brand: brand_config.branding for brand, brand_config in BRAND_CONFIG.items()
}
BASE_URLS = {
brand: brand_config.base_url for brand, brand_config in BRAND_CONFIG.items()
}
CONFIGURATION_URLS = {
brand: brand_config.configuration_url
for brand, brand_config in BRAND_CONFIG.items()
}
|