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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
|
# vim:sw=4:ts=4:et:
"""Constants and enums."""
from __future__ import annotations
from enum import Enum, auto
from typing import Final
from ring_doorbell.exceptions import RingError
class OAuth:
"""OAuth class constants."""
ENDPOINT = "https://oauth.ring.com/oauth/token"
CLIENT_ID = "ring_official_android"
SCOPE: Final[list[str]] = ["client"]
class RingEventKind(Enum):
"""Enum of available ring events."""
DING = "ding"
MOTION = "motion"
INTERCOM_UNLOCK = "intercom_unlock"
class RingCapability(Enum):
"""Enum of available ring events."""
VIDEO = auto()
MOTION_DETECTION = auto()
HISTORY = auto()
LIGHT = auto()
SIREN = auto()
VOLUME = auto()
BATTERY = auto()
OPEN = auto()
KNOCK = auto()
PRE_ROLL = auto()
DING = auto()
@staticmethod
def from_name(name: str) -> RingCapability:
"""Return ring capability from string value."""
capability = name.replace("-", "_").upper()
for ring_capability in RingCapability:
if ring_capability.name == capability:
return ring_capability
msg = f"Unknown ring capability {name}"
raise RingError(msg)
PACKAGE_NAME = "ring_doorbell"
# timeout for HTTP requests
TIMEOUT = 10
# longer default timeout for recording downloads - typical video file sizes
# are ~12 MB and empirical testing reveals a ~20 second download time over a
# fast connection, suggesting speed is largely governed by capacity of Ring
# backend; to be safe, we factor in a worst case overhead and set it to 2
# minutes (this default can be overridden in method call)
DEFAULT_VIDEO_DOWNLOAD_TIMEOUT = 120
# API endpoints
API_VERSION = "11"
API_URI = "https://api.ring.com"
APP_API_URI = "https://prd-api-us.prd.rings.solutions"
USER_AGENT = "android:com.ringapp"
# random uuid, used to make a hardware id that doesn't change or clash
NAMESPACE_UUID = "379378b0-f747-4b67-a10f-3b13327e8879"
DEFAULT_LISTEN_EVENT_EXPIRES_IN = 180
# for Ring android app. 703521446232 for ring-site
FCM_RING_SENDER_ID = "876313859327"
FCM_API_KEY = "AIzaSyCv-hdFBmmdBBJadNy-TFwB-xN_H5m3Bk8"
FCM_PROJECT_ID = "ring-17770"
FCM_APP_ID = "1:876313859327:android:e10ec6ddb3c81f39"
CLI_TOKEN_FILE = "ring_token.cache" # noqa: S105
GCM_TOKEN_FILE = "ring_gcm_token.cache" # noqa: S105
CHIMES_ENDPOINT = "/clients_api/chimes/{0}"
DEVICES_ENDPOINT = "/clients_api/ring_devices"
DINGS_ENDPOINT = "/clients_api/dings/active"
DOORBELLS_ENDPOINT = "/clients_api/doorbots/{0}"
PERSIST_TOKEN_ENDPOINT = "/clients_api/device" # noqa: S105
SUBSCRIPTION_ENDPOINT = "/clients_api/device"
GROUPS_ENDPOINT = "/groups/v1/locations/{0}/groups"
LOCATIONS_HISTORY_ENDPOINT = "/evm/v2/history/locations/{0}"
LOCATIONS_ENDPOINT = "/clients_api/locations/{0}"
HEALTH_DOORBELL_ENDPOINT = DOORBELLS_ENDPOINT + "/health"
HEALTH_CHIMES_ENDPOINT = CHIMES_ENDPOINT + "/health"
LIGHTS_ENDPOINT = DOORBELLS_ENDPOINT + "/floodlight_light_{1}"
LINKED_CHIMES_ENDPOINT = CHIMES_ENDPOINT + "/linked_doorbots"
LIVE_STREAMING_ENDPOINT = DOORBELLS_ENDPOINT + "/live_view"
NEW_SESSION_ENDPOINT = "/clients_api/session"
RINGTONES_ENDPOINT = "/ringtones"
SIREN_ENDPOINT = DOORBELLS_ENDPOINT + "/siren_{1}"
SNAPSHOT_ENDPOINT = "/clients_api/snapshots/image/{0}"
SNAPSHOT_TIMESTAMP_ENDPOINT = "/clients_api/snapshots/timestamps"
TESTSOUND_CHIME_ENDPOINT = CHIMES_ENDPOINT + "/play_sound"
URL_DOORBELL_HISTORY = DOORBELLS_ENDPOINT + "/history"
URL_RECORDING = "/clients_api/dings/{0}/recording"
URL_RECORDING_SHARE_PLAY = "/clients_api/dings/{0}/share/play"
GROUP_DEVICES_ENDPOINT = GROUPS_ENDPOINT + "/{1}/devices"
SETTINGS_ENDPOINT = "/devices/v1/devices/{0}/settings"
# Alternative API for Intercom history, not used in favor of the DoorBell API
URL_INTERCOM_HISTORY = LOCATIONS_HISTORY_ENDPOINT + "?ringtercom"
INTERCOM_OPEN_ENDPOINT = "/commands/v1/devices/{0}/device_rpc"
INTERCOM_INVITATIONS_ENDPOINT = LOCATIONS_ENDPOINT + "/invitations"
INTERCOM_INVITATIONS_DELETE_ENDPOINT = LOCATIONS_ENDPOINT + "/invitations/{1}"
INTERCOM_ALLOWED_USERS = LOCATIONS_ENDPOINT + "/users"
# New API endpoints for web rtc streaming
RTC_STREAMING_TICKET_ENDPOINT = "/api/v1/clap/ticket/request/signalsocket"
RTC_STREAMING_WEB_SOCKET_ENDPOINT = "wss://api.prod.signalling.ring.devices.a2z.com:443/ws?api_version=4.0&auth_type=ring_solutions&client_id=ring_site-{0}&token={1}"
KIND_DING = "ding"
KIND_MOTION = "motion"
KIND_INTERCOM_UNLOCK = "intercom_unlock"
KIND_ALARM_MODE_NONE = "alarm_mode_none"
KIND_ALARM_MODE_SOME = "alarm_mode_some"
KIND_ALARM_SIREN = "alarm_siren"
KIND_ALARM_SILENCED = "alarm_silenced"
# chime test sound kinds
CHIME_TEST_SOUND_KINDS = (KIND_DING, KIND_MOTION)
# default values
CHIME_VOL_MIN = 0
CHIME_VOL_MAX = 11
DOORBELL_VOL_MIN = 0
DOORBELL_VOL_MAX = 11
MIC_VOL_MIN = 0
MIC_VOL_MAX = 11
VOICE_VOL_MIN = 0
VOICE_VOL_MAX = 11
OTHER_DOORBELL_VOL_MIN = 0
OTHER_DOORBELL_VOL_MAX = 8
DOORBELL_EXISTING_TYPE = {0: "Mechanical", 1: "Digital", 2: "Not Present"}
SIREN_DURATION_MIN = 0
SIREN_DURATION_MAX = 120
DOORBELL_EXISTING_DURATION_MIN = 0
DOORBELL_EXISTING_DURATION_MAX = 10
# device model kinds
CHIME_KINDS = ["chime", "chime_v2"]
CHIME_PRO_KINDS = ["chime_pro", "chime_pro_v2"]
DOORBELL_KINDS = ["doorbot", "doorbell", "doorbell_v3"]
DOORBELL_2_KINDS = ["doorbell_v4", "doorbell_v5"]
DOORBELL_3_KINDS = ["doorbell_scallop_lite"]
DOORBELL_4_KINDS = ["doorbell_oyster"] # Added
DOORBELL_3_PLUS_KINDS = ["doorbell_scallop"]
DOORBELL_PRO_KINDS = ["lpd_v1", "lpd_v2", "lpd_v3"]
DOORBELL_PRO_2_KINDS = ["lpd_v4"]
DOORBELL_ELITE_KINDS = ["jbox_v1"]
DOORBELL_WIRED_KINDS = ["doorbell_graham_cracker"]
DOORBELL_BATTERY_KINDS = ["df_doorbell_clownfish"]
PEEPHOLE_CAM_KINDS = ["doorbell_portal"]
DOORBELL_GEN2_KINDS = ["cocoa_doorbell", "cocoa_doorbell_v2"]
FLOODLIGHT_CAM_KINDS = ["hp_cam_v1", "floodlight_v2"]
FLOODLIGHT_CAM_PRO_KINDS = ["floodlight_pro"]
FLOODLIGHT_CAM_PLUS_KINDS = ["cocoa_floodlight"]
INDOOR_CAM_KINDS = ["stickup_cam_mini"]
INDOOR_CAM_GEN2_KINDS = ["stickup_cam_mini_v2"]
SPOTLIGHT_CAM_BATTERY_KINDS = ["stickup_cam_v4"]
SPOTLIGHT_CAM_WIRED_KINDS = ["hp_cam_v2", "spotlightw_v2"]
SPOTLIGHT_CAM_PLUS_KINDS = ["cocoa_spotlight"]
SPOTLIGHT_CAM_PRO_KINDS = ["stickup_cam_longfin"]
STICKUP_CAM_KINDS = ["stickup_cam", "stickup_cam_v3"]
STICKUP_CAM_BATTERY_KINDS = ["stickup_cam_lunar"]
STICKUP_CAM_ELITE_KINDS = ["stickup_cam_elite", "stickup_cam_wired"]
STICKUP_CAM_WIRED_KINDS = STICKUP_CAM_ELITE_KINDS # Deprecated
STICKUP_CAM_GEN3_KINDS = ["cocoa_camera"]
BEAM_KINDS = ["beams_ct200_transformer"]
INTERCOM_KINDS = ["intercom_handset_audio"]
# error strings
MSG_BOOLEAN_REQUIRED = "Boolean value is required."
MSG_EXISTING_TYPE = f"Integer value where {DOORBELL_EXISTING_TYPE}."
MSG_GENERIC_FAIL = "Sorry.. Something went wrong..."
FILE_EXISTS = "The file {0} already exists."
MSG_VOL_OUTBOUND = "Must be within the {0}-{1}."
MSG_ALLOWED_VALUES = "Only the following values are allowed: {0}."
MSG_EXPECTED_ATTRIBUTE_NOT_FOUND = "Couldn't find expected attribute: {0}."
PUSH_ACTION_DING = "com.ring.push.HANDLE_NEW_DING"
PUSH_ACTION_MOTION = "com.ring.push.HANDLE_NEW_motion"
PUSH_ACTION_INTERCOM_UNLOCK = "com.ring.push.INTERCOM_UNLOCK_FROM_APP"
PUSH_NOTIFICATION_DING = "com.ring.pn.live-event.ding"
PUSH_NOTIFICATION_MOTION = "com.ring.pn.live-event.motion"
PUSH_NOTIFICATION_INTERCOM = "com.ring.pn.live-event.intercom"
PUSH_NOTIFICATION_INTERCOM_UNLOCK = "com.ring.pn.intercom.virtual.unlock"
PUSH_NOTIFICATION_KINDS = {
PUSH_ACTION_DING: KIND_DING, # legacy
PUSH_NOTIFICATION_DING: KIND_DING,
PUSH_ACTION_MOTION: KIND_MOTION, # legacy
PUSH_NOTIFICATION_MOTION: KIND_MOTION,
PUSH_NOTIFICATION_INTERCOM: KIND_DING,
PUSH_ACTION_INTERCOM_UNLOCK: KIND_INTERCOM_UNLOCK,
PUSH_NOTIFICATION_INTERCOM_UNLOCK: KIND_INTERCOM_UNLOCK,
"com.ring.push.HANDLE_NEW_SECURITY_PANEL_MODE_NONE_NOTICE": KIND_ALARM_MODE_NONE,
"com.ring.push.HANDLE_NEW_SECURITY_PANEL_MODE_SOME_NOTICE": KIND_ALARM_MODE_SOME,
"com.ring.push.HANDLE_NEW_USER_SOUND_SIREN": KIND_ALARM_SIREN,
"com.ring.push.HANDLE_NEW_NON_ALARM_SIREN_SILENCED": KIND_ALARM_SILENCED,
}
POST_DATA_JSON = {
"api_version": API_VERSION,
"device_model": "ring-doorbell",
}
POST_DATA = {
"api_version": API_VERSION,
"device[os]": "android",
"device[app_brand]": "ring",
"device[metadata][device_model]": "KVM",
"device[metadata][device_name]": "Python",
"device[metadata][resolution]": "600x800",
"device[metadata][app_version]": "1.3.806",
"device[metadata][app_instalation_date]": "",
"device[metadata][manufacturer]": "Qemu",
"device[metadata][device_type]": "desktop",
"device[metadata][architecture]": "desktop",
"device[metadata][language]": "en",
}
PERSIST_TOKEN_DATA = {
"api_version": API_VERSION,
"device[metadata][device_model]": "KVM",
"device[metadata][device_name]": "Python",
"device[metadata][resolution]": "600x800",
"device[metadata][app_version]": "1.3.806",
"device[metadata][app_instalation_date]": "",
"device[metadata][manufacturer]": "Qemu",
"device[metadata][device_type]": "desktop",
"device[metadata][architecture]": "x86",
"device[metadata][language]": "en",
}
ICE_SERVERS = [
"stun:stun.kinesisvideo.us-east-1.amazonaws.com:443",
"stun:stun.kinesisvideo.us-east-2.amazonaws.com:443",
"stun:stun.kinesisvideo.us-west-2.amazonaws.com:443",
"stun:stun.l.google.com:19302",
"stun:stun1.l.google.com:19302",
"stun:stun2.l.google.com:19302",
"stun:stun3.l.google.com:19302",
"stun:stun4.l.google.com:19302",
]
|