python-ring 0.10.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- python_ring/__init__.py +44 -0
- python_ring/auth.py +283 -0
- python_ring/chime.py +135 -0
- python_ring/cli.py +977 -0
- python_ring/const.py +289 -0
- python_ring/doorbot.py +551 -0
- python_ring/event.py +46 -0
- python_ring/exceptions.py +17 -0
- python_ring/generic.py +267 -0
- python_ring/group.py +145 -0
- python_ring/listen/__init__.py +13 -0
- python_ring/listen/eventlistener.py +449 -0
- python_ring/listen/listenerconfig.py +21 -0
- python_ring/other.py +298 -0
- python_ring/py.typed +0 -0
- python_ring/ring.py +476 -0
- python_ring/stickup_cam.py +253 -0
- python_ring/util.py +157 -0
- python_ring/webrtcdevice.py +168 -0
- python_ring/webrtcstream.py +433 -0
- python_ring-0.10.0.dist-info/METADATA +103 -0
- python_ring-0.10.0.dist-info/RECORD +25 -0
- python_ring-0.10.0.dist-info/WHEEL +4 -0
- python_ring-0.10.0.dist-info/entry_points.txt +2 -0
- python_ring-0.10.0.dist-info/licenses/LICENSE +165 -0
python_ring/const.py
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# vim:sw=4:ts=4:et:
|
|
2
|
+
"""Constants and enums."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from enum import Enum, auto
|
|
7
|
+
from typing import Final
|
|
8
|
+
|
|
9
|
+
from python_ring.exceptions import RingError
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class OAuth:
|
|
13
|
+
"""OAuth class constants."""
|
|
14
|
+
|
|
15
|
+
ENDPOINT = "https://oauth.ring.com/oauth/token"
|
|
16
|
+
CLIENT_ID = "ring_official_android"
|
|
17
|
+
SCOPE: Final[list[str]] = ["client"]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class RingEventKind(Enum):
|
|
21
|
+
"""Enum of available ring events."""
|
|
22
|
+
|
|
23
|
+
DING = "ding"
|
|
24
|
+
MOTION = "motion"
|
|
25
|
+
INTERCOM_UNLOCK = "intercom_unlock"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class RingCapability(Enum):
|
|
29
|
+
"""Enum of available ring events."""
|
|
30
|
+
|
|
31
|
+
VIDEO = auto()
|
|
32
|
+
MOTION_DETECTION = auto()
|
|
33
|
+
HISTORY = auto()
|
|
34
|
+
LIGHT = auto()
|
|
35
|
+
SIREN = auto()
|
|
36
|
+
VOLUME = auto()
|
|
37
|
+
BATTERY = auto()
|
|
38
|
+
OPEN = auto()
|
|
39
|
+
KNOCK = auto()
|
|
40
|
+
PRE_ROLL = auto()
|
|
41
|
+
DING = auto()
|
|
42
|
+
|
|
43
|
+
@staticmethod
|
|
44
|
+
def from_name(name: str) -> RingCapability:
|
|
45
|
+
"""Return ring capability from string value."""
|
|
46
|
+
capability = name.replace("-", "_").upper()
|
|
47
|
+
for ring_capability in RingCapability:
|
|
48
|
+
if ring_capability.name == capability:
|
|
49
|
+
return ring_capability
|
|
50
|
+
msg = f"Unknown ring capability {name}"
|
|
51
|
+
raise RingError(msg)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
PACKAGE_NAME = "python_ring"
|
|
55
|
+
# timeout for HTTP requests
|
|
56
|
+
TIMEOUT = 10
|
|
57
|
+
|
|
58
|
+
# Ring's maximum for motion snooze and chime do not disturb
|
|
59
|
+
SNOOZE_MINUTES_MAX = 24 * 60
|
|
60
|
+
MSG_SNOOZE_OUTBOUND = "Must be between 1 and {} minutes."
|
|
61
|
+
|
|
62
|
+
# longer default timeout for recording downloads - typical video file sizes
|
|
63
|
+
# are ~12 MB and empirical testing reveals a ~20 second download time over a
|
|
64
|
+
# fast connection, suggesting speed is largely governed by capacity of Ring
|
|
65
|
+
# backend; to be safe, we factor in a worst case overhead and set it to 2
|
|
66
|
+
# minutes (this default can be overridden in method call)
|
|
67
|
+
DEFAULT_VIDEO_DOWNLOAD_TIMEOUT = 120
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# API endpoints
|
|
71
|
+
API_VERSION = "11"
|
|
72
|
+
API_URI = "https://api.ring.com"
|
|
73
|
+
API_URI_SNAPSHOT = "https://app-snaps.ring.com"
|
|
74
|
+
APP_API_URI = "https://prd-api-us.prd.rings.solutions"
|
|
75
|
+
USER_AGENT = "android:com.ringapp"
|
|
76
|
+
|
|
77
|
+
# random uuid, used to make a hardware id that doesn't change or clash
|
|
78
|
+
NAMESPACE_UUID = "379378b0-f747-4b67-a10f-3b13327e8879"
|
|
79
|
+
|
|
80
|
+
DEFAULT_LISTEN_EVENT_EXPIRES_IN = 180
|
|
81
|
+
# for Ring android app. 703521446232 for ring-site
|
|
82
|
+
FCM_RING_SENDER_ID = "876313859327"
|
|
83
|
+
FCM_API_KEY = "AIzaSyCv-hdFBmmdBBJadNy-TFwB-xN_H5m3Bk8"
|
|
84
|
+
FCM_PROJECT_ID = "ring-17770"
|
|
85
|
+
FCM_APP_ID = "1:876313859327:android:e10ec6ddb3c81f39"
|
|
86
|
+
|
|
87
|
+
CLI_TOKEN_FILE = "ring_token.cache" # noqa: S105
|
|
88
|
+
GCM_TOKEN_FILE = "ring_gcm_token.cache" # noqa: S105
|
|
89
|
+
CHIMES_ENDPOINT = "/clients_api/chimes/{0}"
|
|
90
|
+
DEVICES_ENDPOINT = "/clients_api/ring_devices"
|
|
91
|
+
DINGS_ENDPOINT = "/clients_api/dings/active"
|
|
92
|
+
DOORBELLS_ENDPOINT = "/clients_api/doorbots/{0}"
|
|
93
|
+
PERSIST_TOKEN_ENDPOINT = "/clients_api/device" # noqa: S105
|
|
94
|
+
SUBSCRIPTION_ENDPOINT = "/clients_api/device"
|
|
95
|
+
GROUPS_ENDPOINT = "/groups/v1/locations/{0}/groups"
|
|
96
|
+
LOCATIONS_HISTORY_ENDPOINT = "/evm/v2/history/locations/{0}"
|
|
97
|
+
LOCATIONS_ENDPOINT = "/clients_api/locations/{0}"
|
|
98
|
+
|
|
99
|
+
HEALTH_DOORBELL_ENDPOINT = DOORBELLS_ENDPOINT + "/health"
|
|
100
|
+
HEALTH_CHIMES_ENDPOINT = CHIMES_ENDPOINT + "/health"
|
|
101
|
+
CHIME_DO_NOT_DISTURB_ENDPOINT = CHIMES_ENDPOINT + "/do_not_disturb"
|
|
102
|
+
MOTION_SNOOZE_ENDPOINT = DOORBELLS_ENDPOINT + "/motion_snooze"
|
|
103
|
+
MOTION_SNOOZE_CLEAR_ENDPOINT = MOTION_SNOOZE_ENDPOINT + "/clear"
|
|
104
|
+
LIGHTS_ENDPOINT = DOORBELLS_ENDPOINT + "/floodlight_light_{1}"
|
|
105
|
+
LINKED_CHIMES_ENDPOINT = CHIMES_ENDPOINT + "/linked_doorbots"
|
|
106
|
+
LIVE_STREAMING_ENDPOINT = DOORBELLS_ENDPOINT + "/live_view"
|
|
107
|
+
NEW_SESSION_ENDPOINT = "/clients_api/session"
|
|
108
|
+
RINGTONES_ENDPOINT = "/ringtones"
|
|
109
|
+
SIREN_ENDPOINT = DOORBELLS_ENDPOINT + "/siren_{1}"
|
|
110
|
+
SNAPSHOT_ENDPOINT = "/clients_api/snapshots/image/{0}"
|
|
111
|
+
SNAPSHOT_TIMESTAMP_ENDPOINT = "/clients_api/snapshots/timestamps"
|
|
112
|
+
TAKE_SNAPSHOT_ENDPOINT = "/snapshots/next/{0}"
|
|
113
|
+
TESTSOUND_CHIME_ENDPOINT = CHIMES_ENDPOINT + "/play_sound"
|
|
114
|
+
URL_DOORBELL_HISTORY = DOORBELLS_ENDPOINT + "/history"
|
|
115
|
+
URL_RECORDING = "/clients_api/dings/{0}/recording"
|
|
116
|
+
URL_RECORDING_SHARE_PLAY = "/clients_api/dings/{0}/share/play"
|
|
117
|
+
GROUP_DEVICES_ENDPOINT = GROUPS_ENDPOINT + "/{1}/devices"
|
|
118
|
+
SETTINGS_ENDPOINT = "/devices/v1/devices/{0}/settings"
|
|
119
|
+
# Alternative API for Intercom history, not used in favor of the DoorBell API
|
|
120
|
+
URL_INTERCOM_HISTORY = LOCATIONS_HISTORY_ENDPOINT + "?ringtercom"
|
|
121
|
+
INTERCOM_OPEN_ENDPOINT = "/commands/v1/devices/{0}/device_rpc"
|
|
122
|
+
INTERCOM_INVITATIONS_ENDPOINT = LOCATIONS_ENDPOINT + "/invitations"
|
|
123
|
+
INTERCOM_INVITATIONS_DELETE_ENDPOINT = LOCATIONS_ENDPOINT + "/invitations/{1}"
|
|
124
|
+
INTERCOM_ALLOWED_USERS = LOCATIONS_ENDPOINT + "/users"
|
|
125
|
+
|
|
126
|
+
# New API endpoints for web rtc streaming
|
|
127
|
+
RTC_STREAMING_TICKET_ENDPOINT = "/api/v1/clap/ticket/request/signalsocket"
|
|
128
|
+
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}"
|
|
129
|
+
|
|
130
|
+
KIND_DING = "ding"
|
|
131
|
+
KIND_MOTION = "motion"
|
|
132
|
+
KIND_INTERCOM_UNLOCK = "intercom_unlock"
|
|
133
|
+
KIND_ALARM_MODE_NONE = "alarm_mode_none"
|
|
134
|
+
KIND_ALARM_MODE_SOME = "alarm_mode_some"
|
|
135
|
+
KIND_ALARM_SIREN = "alarm_siren"
|
|
136
|
+
KIND_ALARM_SILENCED = "alarm_silenced"
|
|
137
|
+
|
|
138
|
+
# chime test sound kinds
|
|
139
|
+
CHIME_TEST_SOUND_KINDS = (KIND_DING, KIND_MOTION)
|
|
140
|
+
|
|
141
|
+
# default values
|
|
142
|
+
CHIME_VOL_MIN = 0
|
|
143
|
+
CHIME_VOL_MAX = 11
|
|
144
|
+
|
|
145
|
+
DOORBELL_VOL_MIN = 0
|
|
146
|
+
DOORBELL_VOL_MAX = 11
|
|
147
|
+
|
|
148
|
+
MIC_VOL_MIN = 0
|
|
149
|
+
MIC_VOL_MAX = 11
|
|
150
|
+
|
|
151
|
+
VOICE_VOL_MIN = 0
|
|
152
|
+
VOICE_VOL_MAX = 11
|
|
153
|
+
|
|
154
|
+
OTHER_DOORBELL_VOL_MIN = 0
|
|
155
|
+
OTHER_DOORBELL_VOL_MAX = 8
|
|
156
|
+
|
|
157
|
+
DOORBELL_EXISTING_TYPE = {0: "Mechanical", 1: "Digital", 2: "Not Present"}
|
|
158
|
+
|
|
159
|
+
SIREN_DURATION_MIN = 0
|
|
160
|
+
SIREN_DURATION_MAX = 120
|
|
161
|
+
|
|
162
|
+
DOORBELL_EXISTING_DURATION_MIN = 0
|
|
163
|
+
DOORBELL_EXISTING_DURATION_MAX = 10
|
|
164
|
+
|
|
165
|
+
# device model kinds
|
|
166
|
+
CHIME_KINDS = ["chime", "chime_v2"]
|
|
167
|
+
CHIME_PRO_KINDS = ["chime_pro", "chime_pro_v2"]
|
|
168
|
+
CHIME_2ND_GEN_KINDS = ["chime_v4"]
|
|
169
|
+
|
|
170
|
+
DOORBELL_KINDS = ["doorbot", "doorbell", "doorbell_v3"]
|
|
171
|
+
DOORBELL_2_KINDS = ["doorbell_v4", "doorbell_v5"]
|
|
172
|
+
DOORBELL_3_KINDS = ["doorbell_scallop_lite"]
|
|
173
|
+
DOORBELL_4_KINDS = ["doorbell_oyster"] # Added
|
|
174
|
+
DOORBELL_3_PLUS_KINDS = ["doorbell_scallop"]
|
|
175
|
+
DOORBELL_PRO_KINDS = ["lpd_v1", "lpd_v2", "lpd_v3"]
|
|
176
|
+
DOORBELL_PRO_2_KINDS = ["lpd_v4"]
|
|
177
|
+
DOORBELL_PRO_4K_WIRED_KINDS = ["cocoa_doorbell_v5"]
|
|
178
|
+
DOORBELL_PRO_4K_BATTERY_KINDS = ["cocoa_doorbell_v6"]
|
|
179
|
+
DOORBELL_ELITE_KINDS = ["jbox_v1"]
|
|
180
|
+
DOORBELL_WIRED_KINDS = ["doorbell_graham_cracker", "doorbell_tahoe"]
|
|
181
|
+
DOORBELL_WIRED_PLUS_2_KINDS = ["cocoa_doorbell_v4w"]
|
|
182
|
+
DOORBELL_BATTERY_KINDS = ["df_doorbell_clownfish", "doorbell_sunray"]
|
|
183
|
+
DOORBELL_BATTERY_PRO_KINDS = ["cocoa_doorbell_v3"]
|
|
184
|
+
PEEPHOLE_CAM_KINDS = ["doorbell_portal"]
|
|
185
|
+
DOORBELL_GEN2_KINDS = ["cocoa_doorbell", "cocoa_doorbell_v2"]
|
|
186
|
+
|
|
187
|
+
FLOODLIGHT_CAM_KINDS = ["hp_cam_v1", "floodlight_v2"]
|
|
188
|
+
FLOODLIGHT_CAM_PRO_KINDS = ["floodlight_pro"]
|
|
189
|
+
FLOODLIGHT_CAM_PLUS_KINDS = ["cocoa_floodlight"]
|
|
190
|
+
FLOODLIGHT_CAM_2K_KINDS = ["osprey_floodlight"]
|
|
191
|
+
FLOODLIGHT_CAM_PRO_2_KINDS = ["cocoa_floodlight_v2"]
|
|
192
|
+
INDOOR_CAM_KINDS = ["stickup_cam_mini"]
|
|
193
|
+
INDOOR_CAM_GEN2_KINDS = ["stickup_cam_mini_v2"]
|
|
194
|
+
INDOOR_CAM_PLUS_KINDS = ["stickup_cam_mini_v3"]
|
|
195
|
+
INDOOR_CAM_PTZ_KINDS = ["stickup_cam_mini_ptz_v1"]
|
|
196
|
+
SPOTLIGHT_CAM_BATTERY_KINDS = ["stickup_cam_v4"]
|
|
197
|
+
SPOTLIGHT_CAM_WIRED_KINDS = ["hp_cam_v2", "spotlightw_v2"]
|
|
198
|
+
SPOTLIGHT_CAM_PLUS_KINDS = ["cocoa_spotlight"]
|
|
199
|
+
SPOTLIGHT_CAM_PRO_KINDS = ["stickup_cam_longfin"]
|
|
200
|
+
SPOTLIGHT_CAM_4K_PRO_KINDS = ["cocoa_spotlight_v2"]
|
|
201
|
+
STICKUP_CAM_KINDS = ["stickup_cam", "stickup_cam_v3"]
|
|
202
|
+
STICKUP_CAM_BATTERY_KINDS = ["stickup_cam_lunar"]
|
|
203
|
+
STICKUP_CAM_ELITE_KINDS = ["stickup_cam_elite", "stickup_cam_wired"]
|
|
204
|
+
STICKUP_CAM_WIRED_KINDS = STICKUP_CAM_ELITE_KINDS # Deprecated
|
|
205
|
+
STICKUP_CAM_GEN3_KINDS = ["cocoa_camera"]
|
|
206
|
+
OUTDOOR_CAM_PLUS_KINDS = ["cocoa_camera_v2"]
|
|
207
|
+
OUTDOOR_CAM_PRO_KINDS = ["cocoa_camera_v3"]
|
|
208
|
+
ELITE_CAM_140_KINDS = ["hexa_camera_2_v1"]
|
|
209
|
+
ELITE_CAM_360_KINDS = ["hexa_camera_6_v1"]
|
|
210
|
+
BEAM_KINDS = ["beams_ct200_transformer"]
|
|
211
|
+
|
|
212
|
+
INTERCOM_KINDS = ["intercom_handset_audio", "intercom_handset_video"]
|
|
213
|
+
INTERCOM_VIDEO_KINDS = ["intercom_handset_video"]
|
|
214
|
+
|
|
215
|
+
# error strings
|
|
216
|
+
MSG_BOOLEAN_REQUIRED = "Boolean value is required."
|
|
217
|
+
MSG_EXISTING_TYPE = f"Integer value where {DOORBELL_EXISTING_TYPE}."
|
|
218
|
+
MSG_GENERIC_FAIL = "Sorry.. Something went wrong..."
|
|
219
|
+
FILE_EXISTS = "The file {0} already exists."
|
|
220
|
+
MSG_VOL_OUTBOUND = "Must be within the {0}-{1}."
|
|
221
|
+
MSG_ALLOWED_VALUES = "Only the following values are allowed: {0}."
|
|
222
|
+
MSG_EXPECTED_ATTRIBUTE_NOT_FOUND = "Couldn't find expected attribute: {0}."
|
|
223
|
+
|
|
224
|
+
PUSH_ACTION_DING = "com.ring.push.HANDLE_NEW_DING"
|
|
225
|
+
PUSH_ACTION_MOTION = "com.ring.push.HANDLE_NEW_motion"
|
|
226
|
+
PUSH_ACTION_INTERCOM_UNLOCK = "com.ring.push.INTERCOM_UNLOCK_FROM_APP"
|
|
227
|
+
|
|
228
|
+
PUSH_NOTIFICATION_DING = "com.ring.pn.live-event.ding"
|
|
229
|
+
PUSH_NOTIFICATION_MOTION = "com.ring.pn.live-event.motion"
|
|
230
|
+
PUSH_NOTIFICATION_INTERCOM = "com.ring.pn.live-event.intercom"
|
|
231
|
+
PUSH_NOTIFICATION_INTERCOM_UNLOCK = "com.ring.pn.intercom.virtual.unlock"
|
|
232
|
+
|
|
233
|
+
PUSH_NOTIFICATION_KINDS = {
|
|
234
|
+
PUSH_ACTION_DING: KIND_DING, # legacy
|
|
235
|
+
PUSH_NOTIFICATION_DING: KIND_DING,
|
|
236
|
+
PUSH_ACTION_MOTION: KIND_MOTION, # legacy
|
|
237
|
+
PUSH_NOTIFICATION_MOTION: KIND_MOTION,
|
|
238
|
+
PUSH_NOTIFICATION_INTERCOM: KIND_DING,
|
|
239
|
+
PUSH_ACTION_INTERCOM_UNLOCK: KIND_INTERCOM_UNLOCK,
|
|
240
|
+
PUSH_NOTIFICATION_INTERCOM_UNLOCK: KIND_INTERCOM_UNLOCK,
|
|
241
|
+
"com.ring.push.HANDLE_NEW_SECURITY_PANEL_MODE_NONE_NOTICE": KIND_ALARM_MODE_NONE,
|
|
242
|
+
"com.ring.push.HANDLE_NEW_SECURITY_PANEL_MODE_SOME_NOTICE": KIND_ALARM_MODE_SOME,
|
|
243
|
+
"com.ring.push.HANDLE_NEW_USER_SOUND_SIREN": KIND_ALARM_SIREN,
|
|
244
|
+
"com.ring.push.HANDLE_NEW_NON_ALARM_SIREN_SILENCED": KIND_ALARM_SILENCED,
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
POST_DATA_JSON = {
|
|
248
|
+
"api_version": API_VERSION,
|
|
249
|
+
"device_model": "ring-doorbell",
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
POST_DATA = {
|
|
253
|
+
"api_version": API_VERSION,
|
|
254
|
+
"device[os]": "android",
|
|
255
|
+
"device[app_brand]": "ring",
|
|
256
|
+
"device[metadata][device_model]": "KVM",
|
|
257
|
+
"device[metadata][device_name]": "Python",
|
|
258
|
+
"device[metadata][resolution]": "600x800",
|
|
259
|
+
"device[metadata][app_version]": "1.3.806",
|
|
260
|
+
"device[metadata][app_instalation_date]": "",
|
|
261
|
+
"device[metadata][manufacturer]": "Qemu",
|
|
262
|
+
"device[metadata][device_type]": "desktop",
|
|
263
|
+
"device[metadata][architecture]": "desktop",
|
|
264
|
+
"device[metadata][language]": "en",
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
PERSIST_TOKEN_DATA = {
|
|
268
|
+
"api_version": API_VERSION,
|
|
269
|
+
"device[metadata][device_model]": "KVM",
|
|
270
|
+
"device[metadata][device_name]": "Python",
|
|
271
|
+
"device[metadata][resolution]": "600x800",
|
|
272
|
+
"device[metadata][app_version]": "1.3.806",
|
|
273
|
+
"device[metadata][app_instalation_date]": "",
|
|
274
|
+
"device[metadata][manufacturer]": "Qemu",
|
|
275
|
+
"device[metadata][device_type]": "desktop",
|
|
276
|
+
"device[metadata][architecture]": "x86",
|
|
277
|
+
"device[metadata][language]": "en",
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
ICE_SERVERS = [
|
|
281
|
+
"stun:stun.kinesisvideo.us-east-1.amazonaws.com:443",
|
|
282
|
+
"stun:stun.kinesisvideo.us-east-2.amazonaws.com:443",
|
|
283
|
+
"stun:stun.kinesisvideo.us-west-2.amazonaws.com:443",
|
|
284
|
+
"stun:stun.l.google.com:19302",
|
|
285
|
+
"stun:stun1.l.google.com:19302",
|
|
286
|
+
"stun:stun2.l.google.com:19302",
|
|
287
|
+
"stun:stun3.l.google.com:19302",
|
|
288
|
+
"stun:stun4.l.google.com:19302",
|
|
289
|
+
]
|