eero-api 8.4.2__tar.gz → 8.4.4__tar.gz
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.
- {eero_api-8.4.2/src/eero_api.egg-info → eero_api-8.4.4}/PKG-INFO +1 -1
- {eero_api-8.4.2 → eero_api-8.4.4}/pyproject.toml +2 -2
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/__init__.py +1 -1
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/schedule.py +283 -62
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/sqm.py +20 -20
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/client.py +144 -80
- {eero_api-8.4.2 → eero_api-8.4.4/src/eero_api.egg-info}/PKG-INFO +1 -1
- {eero_api-8.4.2 → eero_api-8.4.4}/LICENSE +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/README.md +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/setup.cfg +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/setup.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/__init__.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/_params.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/_writes.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/ac_compat.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/account.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/auth.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/auth_storage.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/backup.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/backup_access_points.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/base.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/blacklist.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/burst_reporters.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/data_usage.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/ddns.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/devices.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/dhcp.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/diagnostics.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/dns.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/dns_policies.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/eeros.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/entitlements.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/events.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/forwards.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/insights.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/links.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/members.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/networks.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/notifications.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/ouicheck.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/permissions.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/power_saving.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/profiles.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/reservations.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/routing.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/security.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/subnets.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/support.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/thread.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/transfer.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/updates.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/wan.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/api/wpa3.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/const.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/errors.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/exceptions.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/logging.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero/py.typed +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero_api.egg-info/SOURCES.txt +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero_api.egg-info/dependency_links.txt +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero_api.egg-info/requires.txt +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/src/eero_api.egg-info/top_level.txt +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/tests/test_errors.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/tests/test_exceptions.py +0 -0
- {eero_api-8.4.2 → eero_api-8.4.4}/tests/test_logging.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "eero-api"
|
|
7
|
-
version = "8.4.
|
|
7
|
+
version = "8.4.4"
|
|
8
8
|
description = "Modern async Python client for Eero network management"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.12"
|
|
@@ -121,7 +121,7 @@ asyncio_mode = "auto"
|
|
|
121
121
|
|
|
122
122
|
[tool.commitizen]
|
|
123
123
|
name = "cz_conventional_commits"
|
|
124
|
-
version = "8.4.
|
|
124
|
+
version = "8.4.4"
|
|
125
125
|
version_files = [
|
|
126
126
|
"pyproject.toml:project.version",
|
|
127
127
|
"src/eero/__init__.py:__version__",
|
|
@@ -3,24 +3,43 @@
|
|
|
3
3
|
IMPORTANT: This module returns RAW responses from the Eero Cloud API.
|
|
4
4
|
All data extraction, field mapping, and transformation must be done by downstream clients.
|
|
5
5
|
|
|
6
|
-
Scheduled pauses are sub-resources of a profile
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
``schedule`` array
|
|
6
|
+
Scheduled pauses are sub-resources of a profile. They are created with a POST
|
|
7
|
+
to ``networks/{id}/profiles/{profile}/schedules`` and are updated/deleted
|
|
8
|
+
through their own URL (``.../schedules/{id}``). They are not readable through
|
|
9
|
+
either of those: a GET on the collection or on a pause's own URL returns 404
|
|
10
|
+
(live-verified 2026-12-01), so the only read path is the ``schedule`` array on
|
|
11
|
+
the profile resource itself (see `ScheduleAPI.get_schedules`). Each element of
|
|
12
|
+
that array carries ``url``, ``name``, ``enabled``, ``days``, ``start`` and
|
|
13
|
+
``end`` and no ``id``.
|
|
14
|
+
|
|
15
|
+
Live-verified 2026-12-01 against a throwaway profile:
|
|
16
|
+
|
|
17
|
+
* Day names must be capitalised (``"Monday"``); lowercase is refused with 400.
|
|
18
|
+
The SDK accepts any case and sends the capitalised form.
|
|
19
|
+
* POST (create) and PUT (update) return the full PROFILE envelope, not the
|
|
20
|
+
pause. DELETE succeeds with a 2xx.
|
|
21
|
+
* PUT is a full replace: ``start`` and ``end`` are required (400 otherwise),
|
|
22
|
+
and an omitted ``enabled`` resets a disabled pause to enabled.
|
|
23
|
+
`ScheduleAPI.update_schedule` therefore reads, merges and writes all five
|
|
24
|
+
fields.
|
|
11
25
|
|
|
12
26
|
.. warning::
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
not retry a failed write.
|
|
27
|
+
`ScheduleAPI.update_schedule` is a non-atomic read-modify-write and still
|
|
28
|
+
logs a warning via `eero.api._writes.warn_uncharacterised_write`: a PUT
|
|
29
|
+
body carrying all five fields has not been sent live. Do not retry a
|
|
30
|
+
failed write.
|
|
18
31
|
"""
|
|
19
32
|
|
|
20
|
-
from typing import Any, Dict, List, Mapping, Optional
|
|
33
|
+
from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple
|
|
34
|
+
from urllib.parse import urlsplit
|
|
21
35
|
|
|
22
36
|
from ..const import API_ENDPOINT, API_VERSION_DEFAULT
|
|
23
|
-
from ..exceptions import
|
|
37
|
+
from ..exceptions import (
|
|
38
|
+
EeroAPIException,
|
|
39
|
+
EeroAuthenticationException,
|
|
40
|
+
EeroNotFoundException,
|
|
41
|
+
EeroValidationException,
|
|
42
|
+
)
|
|
24
43
|
from ..logging import get_secure_logger
|
|
25
44
|
from ._params import resolve_nested_url
|
|
26
45
|
from ._writes import as_envelope, warn_uncharacterised_write
|
|
@@ -32,20 +51,52 @@ _LOGGER = get_secure_logger(__name__)
|
|
|
32
51
|
|
|
33
52
|
#: The shape of a scheduled pause's own path, after the version segment.
|
|
34
53
|
_SCHEDULE_FAMILY = "networks/{id}/profiles/{id}/schedules/{id}"
|
|
54
|
+
_UPDATE_FIELDS = ("name", "days", "start", "end", "enabled")
|
|
55
|
+
_PROFILE_FAMILY = "networks/{id}/profiles/{id}"
|
|
35
56
|
|
|
36
|
-
#: All seven days, used as the default scope for `enable_bedtime`.
|
|
57
|
+
#: All seven days, used as the default scope for `enable_bedtime`. The API
|
|
58
|
+
#: requires the capitalised form.
|
|
37
59
|
ALL_DAYS = (
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
60
|
+
"Monday",
|
|
61
|
+
"Tuesday",
|
|
62
|
+
"Wednesday",
|
|
63
|
+
"Thursday",
|
|
64
|
+
"Friday",
|
|
65
|
+
"Saturday",
|
|
66
|
+
"Sunday",
|
|
45
67
|
)
|
|
46
68
|
|
|
47
|
-
WEEKDAYS =
|
|
48
|
-
WEEKEND =
|
|
69
|
+
WEEKDAYS = ALL_DAYS[:5]
|
|
70
|
+
WEEKEND = ALL_DAYS[5:]
|
|
71
|
+
|
|
72
|
+
_DAYS_BY_LOWER = {day.lower(): day for day in ALL_DAYS}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _normalise_days(days: Any) -> List[str]:
|
|
76
|
+
"""Return ``days`` as the capitalised names the API requires.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
days: A non-empty list or tuple of English day names in any case
|
|
80
|
+
(``"monday"``, ``"MONDAY"``, ``"Monday"``).
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
The same days, in the same order, capitalised (``"Monday"``).
|
|
84
|
+
|
|
85
|
+
Raises:
|
|
86
|
+
EeroValidationException: If ``days`` is not a list or tuple, is
|
|
87
|
+
empty, or contains anything other than the seven day names.
|
|
88
|
+
"""
|
|
89
|
+
if isinstance(days, str) or not isinstance(days, Sequence) or not days:
|
|
90
|
+
raise EeroValidationException("days", "must be a non-empty list of day names")
|
|
91
|
+
normalised: List[str] = []
|
|
92
|
+
for day in days:
|
|
93
|
+
canonical = _DAYS_BY_LOWER.get(day.strip().lower()) if isinstance(day, str) else None
|
|
94
|
+
if canonical is None:
|
|
95
|
+
raise EeroValidationException(
|
|
96
|
+
"days", f"each day must be one of {', '.join(ALL_DAYS)} (any case)"
|
|
97
|
+
)
|
|
98
|
+
normalised.append(canonical)
|
|
99
|
+
return normalised
|
|
49
100
|
|
|
50
101
|
|
|
51
102
|
def _resolve_schedule_url(schedule: Any) -> str:
|
|
@@ -65,9 +116,11 @@ def _resolve_schedule_url(schedule: Any) -> str:
|
|
|
65
116
|
(``/<version>/networks/{id}/profiles/{id}/schedules/{id}``), or
|
|
66
117
|
neither a string nor a mapping.
|
|
67
118
|
|
|
68
|
-
A path or URL a caller supplies
|
|
69
|
-
|
|
70
|
-
|
|
119
|
+
A path or URL a caller supplies, and the ``url`` of an envelope, are both
|
|
120
|
+
confined to that shape, so a write cannot be redirected to another
|
|
121
|
+
resource on the API host. The confinement of envelopes matters because
|
|
122
|
+
`create_schedule` and `update_schedule` return the full PROFILE envelope:
|
|
123
|
+
handing one to `delete_schedule` would otherwise DELETE the profile. A bare
|
|
71
124
|
identifier is refused: a pause lives under a network and a profile that
|
|
72
125
|
the update and delete methods are not given, so the id alone cannot be
|
|
73
126
|
resolved, and placing it under the version root would address whatever
|
|
@@ -78,6 +131,7 @@ def _resolve_schedule_url(schedule: Any) -> str:
|
|
|
78
131
|
url = self_url(envelope) if envelope is not None else None
|
|
79
132
|
if url is None:
|
|
80
133
|
raise EeroValidationException("schedule", "envelope has no resolvable 'url' field")
|
|
134
|
+
require_family_path(url, _SCHEDULE_FAMILY, field="schedule")
|
|
81
135
|
return url
|
|
82
136
|
if isinstance(schedule, str):
|
|
83
137
|
if not (schedule.startswith("/") or schedule.lower().startswith(("http://", "https://"))):
|
|
@@ -94,14 +148,61 @@ def _resolve_schedule_url(schedule: Any) -> str:
|
|
|
94
148
|
)
|
|
95
149
|
|
|
96
150
|
|
|
151
|
+
def schedule_owner(schedule: Any) -> Tuple[str, str]:
|
|
152
|
+
"""Return the ``(network_id, profile_id)`` that own a scheduled pause.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
schedule: A pause path, URL or envelope, as accepted by
|
|
156
|
+
`update_schedule` and `delete_schedule`.
|
|
157
|
+
|
|
158
|
+
Returns:
|
|
159
|
+
The network and profile identifiers carried by the pause's URL.
|
|
160
|
+
|
|
161
|
+
Raises:
|
|
162
|
+
EeroValidationException: If ``schedule`` cannot be resolved to a
|
|
163
|
+
scheduled pause's URL.
|
|
164
|
+
"""
|
|
165
|
+
network_id, profile_id, _ = require_family_path(
|
|
166
|
+
_resolve_schedule_url(schedule), _SCHEDULE_FAMILY, field="schedule"
|
|
167
|
+
)
|
|
168
|
+
return network_id, profile_id
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def _schedule_list(profile_response: Mapping[str, Any]) -> List[Dict[str, Any]]:
|
|
172
|
+
"""Return the ``schedule`` array of a profile response, or ``[]``."""
|
|
173
|
+
data = profile_response.get("data")
|
|
174
|
+
schedule = data.get("schedule") if isinstance(data, Mapping) else None
|
|
175
|
+
return schedule if isinstance(schedule, list) else []
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def _ids_of(url: Any) -> Optional[Tuple[str, ...]]:
|
|
179
|
+
"""Return the (network, profile, schedule) ids of a schedule URL, or ``None``.
|
|
180
|
+
|
|
181
|
+
Ignores the API version, so ``/2.3/...`` and ``/2.2/...`` match.
|
|
182
|
+
"""
|
|
183
|
+
if not isinstance(url, str):
|
|
184
|
+
return None
|
|
185
|
+
try:
|
|
186
|
+
return require_family_path(url, _SCHEDULE_FAMILY, field="schedule")
|
|
187
|
+
except EeroValidationException:
|
|
188
|
+
return None
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def _path_of(url: str) -> str:
|
|
192
|
+
"""Return a URL's path without a trailing slash, for host-agnostic matching."""
|
|
193
|
+
return urlsplit(url).path.rstrip("/")
|
|
194
|
+
|
|
195
|
+
|
|
97
196
|
class ScheduleAPI(AuthenticatedAPI):
|
|
98
197
|
"""Schedule API for Eero.
|
|
99
198
|
|
|
100
199
|
Manages internet access schedules (scheduled pauses) for profiles,
|
|
101
200
|
including bedtime restrictions and custom time blocks.
|
|
102
201
|
|
|
103
|
-
|
|
104
|
-
|
|
202
|
+
Every method returns the raw JSON response from the Eero Cloud API,
|
|
203
|
+
``{"meta": {...}, "data": {...}}``, except `get_schedules`, whose ``data``
|
|
204
|
+
is derived: the ``schedule`` array of the profile response (the elements
|
|
205
|
+
themselves are unmodified).
|
|
105
206
|
"""
|
|
106
207
|
|
|
107
208
|
def __init__(self, auth_api: AuthAPI) -> None:
|
|
@@ -141,6 +242,31 @@ class ScheduleAPI(AuthenticatedAPI):
|
|
|
141
242
|
version=API_VERSION_DEFAULT,
|
|
142
243
|
)
|
|
143
244
|
|
|
245
|
+
def _profile_url(self, network: str, profile: str, parent: Optional[Mapping[str, Any]]) -> str:
|
|
246
|
+
"""Resolve a profile's own URL.
|
|
247
|
+
|
|
248
|
+
Args:
|
|
249
|
+
network: ID of the network the profile belongs to.
|
|
250
|
+
profile: The profile's bare ID, path, or absolute URL.
|
|
251
|
+
parent: The profile's own cached envelope, if the caller has
|
|
252
|
+
one; its own ``url`` is preferred when present.
|
|
253
|
+
|
|
254
|
+
Returns:
|
|
255
|
+
The absolute profile URL.
|
|
256
|
+
|
|
257
|
+
Raises:
|
|
258
|
+
EeroValidationException: If the profile cannot be resolved, or
|
|
259
|
+
``parent`` carries a ``url`` that is not a profile's URL
|
|
260
|
+
(``/<version>/networks/{id}/profiles/{id}``), e.g. a network
|
|
261
|
+
envelope.
|
|
262
|
+
"""
|
|
263
|
+
envelope = as_envelope(parent)
|
|
264
|
+
own = self_url(envelope) if envelope is not None else None
|
|
265
|
+
if own is not None:
|
|
266
|
+
require_family_path(own, _PROFILE_FAMILY, field="parent")
|
|
267
|
+
return own
|
|
268
|
+
return resolve_nested_url(network, profile, prefix="profiles", version=API_VERSION_DEFAULT)
|
|
269
|
+
|
|
144
270
|
async def get_schedules(
|
|
145
271
|
self,
|
|
146
272
|
network: str,
|
|
@@ -148,27 +274,42 @@ class ScheduleAPI(AuthenticatedAPI):
|
|
|
148
274
|
*,
|
|
149
275
|
parent: Optional[Mapping[str, Any]] = None,
|
|
150
276
|
) -> Dict[str, Any]:
|
|
151
|
-
"""Get the scheduled pauses for a profile
|
|
277
|
+
"""Get the scheduled pauses for a profile.
|
|
278
|
+
|
|
279
|
+
.. note::
|
|
280
|
+
Unlike the other reads in this SDK, this is derived from the
|
|
281
|
+
profile resource: the schedules collection GET returns 404
|
|
282
|
+
whether or not pauses exist (live-verified 2026-12-01), so this
|
|
283
|
+
GETs the profile itself and returns its ``schedule`` array. This
|
|
284
|
+
is the one place the module reshapes a response; the ``meta`` is
|
|
285
|
+
the profile response's, and each element is passed through
|
|
286
|
+
unmodified (``url``, ``name``, ``enabled``, ``days``, ``start``,
|
|
287
|
+
``end``; no ``id``).
|
|
152
288
|
|
|
153
289
|
Args:
|
|
154
290
|
network: ID of the network the profile belongs to.
|
|
155
291
|
profile: The profile's bare ID, path, or absolute URL.
|
|
156
|
-
parent: The profile's own cached envelope, if the caller has
|
|
292
|
+
parent: The profile's own cached envelope, if the caller has
|
|
293
|
+
one. Its own ``url`` is used when present. Never mutated.
|
|
157
294
|
|
|
158
295
|
Returns:
|
|
159
|
-
|
|
296
|
+
``{"meta": {...}, "data": [...]}`` where ``data`` is the
|
|
297
|
+
profile's ``schedule`` list (empty when the profile has none).
|
|
160
298
|
|
|
161
299
|
Raises:
|
|
162
300
|
EeroAuthenticationException: If not authenticated
|
|
301
|
+
EeroValidationException: If ``parent`` is not the profile's own
|
|
302
|
+
envelope (its ``url`` is not a profile path)
|
|
163
303
|
EeroAPIException: If the API returns an error
|
|
164
304
|
"""
|
|
165
305
|
auth_token = await self._auth_api.get_auth_token()
|
|
166
306
|
if not auth_token:
|
|
167
307
|
raise EeroAuthenticationException("Not authenticated")
|
|
168
308
|
|
|
169
|
-
url = self.
|
|
309
|
+
url = self._profile_url(network, profile, parent)
|
|
170
310
|
_LOGGER.debug("Getting schedules for profile %s", profile)
|
|
171
|
-
|
|
311
|
+
response = await self.get(url, auth_token=auth_token)
|
|
312
|
+
return {"meta": response.get("meta"), "data": _schedule_list(response)}
|
|
172
313
|
|
|
173
314
|
async def create_schedule(
|
|
174
315
|
self,
|
|
@@ -188,27 +329,44 @@ class ScheduleAPI(AuthenticatedAPI):
|
|
|
188
329
|
network: ID of the network the profile belongs to.
|
|
189
330
|
profile: The profile's bare ID, path, or absolute URL.
|
|
190
331
|
name: Name of the schedule.
|
|
191
|
-
days: Days the pause applies to, e.g. ``["
|
|
332
|
+
days: Days the pause applies to, e.g. ``["Monday", "Tuesday"]``.
|
|
333
|
+
Any case is accepted; the capitalised form is sent.
|
|
192
334
|
start: Start time (``HH:MM``).
|
|
193
335
|
end: End time (``HH:MM``).
|
|
194
336
|
enabled: Whether the schedule is active. Defaults to ``True``.
|
|
195
337
|
parent: The profile's own cached envelope, if the caller has one.
|
|
196
338
|
|
|
197
339
|
Returns:
|
|
198
|
-
Raw API response:
|
|
340
|
+
Raw API response: the full PROFILE envelope
|
|
341
|
+
({"meta": {...}, "data": {...}}), not the new pause. Read the
|
|
342
|
+
pause from ``data["schedule"]``.
|
|
199
343
|
|
|
200
344
|
Raises:
|
|
201
345
|
EeroAuthenticationException: If not authenticated
|
|
346
|
+
EeroValidationException: If ``days`` is empty or holds anything
|
|
347
|
+
other than the seven day names
|
|
202
348
|
EeroAPIException: If the API returns an error
|
|
349
|
+
|
|
350
|
+
.. note::
|
|
351
|
+
Live-verified 2026-12-01 on a throwaway profile: a POST with
|
|
352
|
+
capitalised days and ``enabled: false`` created a disabled pause,
|
|
353
|
+
confirmed by read-back of the profile's ``schedule`` array. The
|
|
354
|
+
response is the full profile envelope. Lowercase day names are
|
|
355
|
+
refused with 400, which is why days are normalised here.
|
|
203
356
|
"""
|
|
204
357
|
auth_token = await self._auth_api.get_auth_token()
|
|
205
358
|
if not auth_token:
|
|
206
359
|
raise EeroAuthenticationException("Not authenticated")
|
|
207
360
|
|
|
208
361
|
url = self._schedules_url(network, profile, parent)
|
|
209
|
-
payload = {
|
|
362
|
+
payload = {
|
|
363
|
+
"name": name,
|
|
364
|
+
"days": _normalise_days(days),
|
|
365
|
+
"start": start,
|
|
366
|
+
"end": end,
|
|
367
|
+
"enabled": enabled,
|
|
368
|
+
}
|
|
210
369
|
|
|
211
|
-
warn_uncharacterised_write(_LOGGER, "create_schedule")
|
|
212
370
|
_LOGGER.debug("Creating schedule '%s' for profile %s", name, profile)
|
|
213
371
|
return await self.post(url, auth_token=auth_token, json=payload)
|
|
214
372
|
|
|
@@ -222,53 +380,110 @@ class ScheduleAPI(AuthenticatedAPI):
|
|
|
222
380
|
end: Optional[str] = None,
|
|
223
381
|
enabled: Optional[bool] = None,
|
|
224
382
|
) -> Dict[str, Any]:
|
|
225
|
-
"""Update a scheduled pause
|
|
383
|
+
"""Update a scheduled pause by read, merge, write.
|
|
384
|
+
|
|
385
|
+
The API's PUT is a full replace: ``start`` and ``end`` are required
|
|
386
|
+
(400 otherwise) and an omitted ``enabled`` resets a disabled pause to
|
|
387
|
+
enabled. So this reads the owning profile, takes the pause's current
|
|
388
|
+
``name``, ``days``, ``start``, ``end`` and ``enabled``, overlays the
|
|
389
|
+
fields supplied, and PUTs all five. A pause is always read fresh; a
|
|
390
|
+
cached envelope passed as ``schedule`` is used only to locate it.
|
|
226
391
|
|
|
227
392
|
Args:
|
|
228
|
-
schedule: The pause's own path or absolute URL (as
|
|
229
|
-
`get_schedules
|
|
230
|
-
A bare id is rejected: this method is not given the
|
|
231
|
-
and profile the pause lives under.
|
|
232
|
-
name: New name, or ``None`` to
|
|
233
|
-
days: New days
|
|
234
|
-
start: New start time, or ``None`` to
|
|
235
|
-
end: New end time, or ``None`` to
|
|
236
|
-
enabled: New enabled state, or ``None`` to
|
|
393
|
+
schedule: The pause's own path or absolute URL (as found in
|
|
394
|
+
`get_schedules`), or an element/envelope carrying its
|
|
395
|
+
``url``. A bare id is rejected: this method is not given the
|
|
396
|
+
network and profile the pause lives under.
|
|
397
|
+
name: New name, or ``None`` to keep the current one.
|
|
398
|
+
days: New days (any case), or ``None`` to keep the current ones.
|
|
399
|
+
start: New start time (``HH:MM``), or ``None`` to keep it.
|
|
400
|
+
end: New end time (``HH:MM``), or ``None`` to keep it.
|
|
401
|
+
enabled: New enabled state, or ``None`` to keep it.
|
|
237
402
|
|
|
238
403
|
Returns:
|
|
239
|
-
Raw API response:
|
|
404
|
+
Raw API response: the full PROFILE envelope
|
|
405
|
+
({"meta": {...}, "data": {...}}), not the pause.
|
|
240
406
|
|
|
241
407
|
Raises:
|
|
242
408
|
EeroAuthenticationException: If not authenticated
|
|
243
|
-
EeroValidationException: If
|
|
244
|
-
|
|
245
|
-
|
|
409
|
+
EeroValidationException: If no field is supplied, ``days`` is
|
|
410
|
+
invalid, ``schedule`` is a bare id, or it cannot be resolved
|
|
411
|
+
to a scheduled pause's URL
|
|
412
|
+
EeroNotFoundException: If the profile has no pause at that URL
|
|
413
|
+
EeroAPIException: If the API returns an error, or the current
|
|
414
|
+
pause lacks a field (name, days, start, end, enabled) that the
|
|
415
|
+
caller did not supply; raised before any PUT is sent
|
|
416
|
+
|
|
417
|
+
.. warning::
|
|
418
|
+
Live-verified 2026-12-01: a PUT with ``name``, ``days``, ``start``
|
|
419
|
+
and ``end`` and no ``enabled`` renamed the pause and reset
|
|
420
|
+
``enabled`` to true; a PUT with only ``name`` was refused with
|
|
421
|
+
400. A PUT carrying all five fields including ``enabled``, which
|
|
422
|
+
is what this method sends, has not been sent live, so it still
|
|
423
|
+
logs `warn_uncharacterised_write`.
|
|
424
|
+
|
|
425
|
+
The read-modify-write is not atomic: a change made by someone
|
|
426
|
+
else between the read and the write is overwritten. Never retry
|
|
427
|
+
a failed write in a loop.
|
|
246
428
|
"""
|
|
247
429
|
auth_token = await self._auth_api.get_auth_token()
|
|
248
430
|
if not auth_token:
|
|
249
431
|
raise EeroAuthenticationException("Not authenticated")
|
|
250
432
|
|
|
251
|
-
|
|
433
|
+
changes: Dict[str, Any] = {}
|
|
252
434
|
if name is not None:
|
|
253
|
-
|
|
435
|
+
changes["name"] = name
|
|
254
436
|
if days is not None:
|
|
255
|
-
|
|
437
|
+
changes["days"] = _normalise_days(days)
|
|
256
438
|
if start is not None:
|
|
257
|
-
|
|
439
|
+
changes["start"] = start
|
|
258
440
|
if end is not None:
|
|
259
|
-
|
|
441
|
+
changes["end"] = end
|
|
260
442
|
if enabled is not None:
|
|
261
|
-
|
|
443
|
+
changes["enabled"] = enabled
|
|
262
444
|
|
|
263
|
-
if not
|
|
445
|
+
if not changes:
|
|
264
446
|
raise EeroValidationException(
|
|
265
447
|
"schedule",
|
|
266
448
|
"at least one of name, days, start, end, enabled must be supplied",
|
|
267
449
|
)
|
|
268
450
|
|
|
269
451
|
url = _resolve_schedule_url(schedule)
|
|
452
|
+
wanted_ids = require_family_path(url, _SCHEDULE_FAMILY, field="schedule")
|
|
453
|
+
profile_url = url.rstrip("/").rsplit("/schedules/", 1)[0]
|
|
454
|
+
|
|
455
|
+
_LOGGER.debug("Reading schedules before updating %s", url)
|
|
456
|
+
profile_response = await self.get(profile_url, auth_token=auth_token)
|
|
457
|
+
wanted = _path_of(url)
|
|
458
|
+
current = next(
|
|
459
|
+
(
|
|
460
|
+
item
|
|
461
|
+
for item in _schedule_list(profile_response)
|
|
462
|
+
if isinstance(item, Mapping) and _ids_of(item.get("url")) == wanted_ids
|
|
463
|
+
),
|
|
464
|
+
None,
|
|
465
|
+
)
|
|
466
|
+
if current is None:
|
|
467
|
+
raise EeroNotFoundException("schedule", wanted)
|
|
468
|
+
|
|
469
|
+
# A None current value counts as missing; it is never sent back.
|
|
470
|
+
payload: Dict[str, Any] = {
|
|
471
|
+
key: current[key] for key in _UPDATE_FIELDS if current.get(key) is not None
|
|
472
|
+
}
|
|
473
|
+
payload.update(changes)
|
|
474
|
+
if "days" in payload:
|
|
475
|
+
payload["days"] = _normalise_days(payload["days"])
|
|
476
|
+
missing = [key for key in _UPDATE_FIELDS if key not in payload]
|
|
477
|
+
if missing:
|
|
478
|
+
raise EeroAPIException(
|
|
479
|
+
None,
|
|
480
|
+
f"cannot update {wanted}: the current schedule has no "
|
|
481
|
+
f"{', '.join(missing)} and none was supplied; the PUT replaces the "
|
|
482
|
+
"whole schedule, so no request was sent",
|
|
483
|
+
)
|
|
484
|
+
|
|
270
485
|
warn_uncharacterised_write(_LOGGER, "update_schedule")
|
|
271
|
-
_LOGGER.debug("Updating schedule at %s: %s", url, sorted(
|
|
486
|
+
_LOGGER.debug("Updating schedule at %s: %s", url, sorted(changes))
|
|
272
487
|
return await self.put(url, auth_token=auth_token, json=payload)
|
|
273
488
|
|
|
274
489
|
async def delete_schedule(self, schedule: Any) -> Dict[str, Any]:
|
|
@@ -287,13 +502,16 @@ class ScheduleAPI(AuthenticatedAPI):
|
|
|
287
502
|
EeroValidationException: If ``schedule`` is a bare id, or cannot
|
|
288
503
|
be resolved to a scheduled pause's URL
|
|
289
504
|
EeroAPIException: If the API returns an error
|
|
505
|
+
|
|
506
|
+
.. note::
|
|
507
|
+
Live-verified 2026-12-01: a DELETE on a pause's own URL returned
|
|
508
|
+
2xx and the profile's ``schedule`` array was empty on read-back.
|
|
290
509
|
"""
|
|
291
510
|
auth_token = await self._auth_api.get_auth_token()
|
|
292
511
|
if not auth_token:
|
|
293
512
|
raise EeroAuthenticationException("Not authenticated")
|
|
294
513
|
|
|
295
514
|
url = _resolve_schedule_url(schedule)
|
|
296
|
-
warn_uncharacterised_write(_LOGGER, "delete_schedule")
|
|
297
515
|
_LOGGER.debug("Deleting schedule at %s", url)
|
|
298
516
|
return await self.delete(url, auth_token=auth_token)
|
|
299
517
|
|
|
@@ -306,8 +524,9 @@ class ScheduleAPI(AuthenticatedAPI):
|
|
|
306
524
|
) -> List[Dict[str, Any]]:
|
|
307
525
|
"""Delete every scheduled pause currently set on a profile.
|
|
308
526
|
|
|
309
|
-
Issues one read (`get_schedules
|
|
310
|
-
existing pause -- N deletes for N pauses.
|
|
527
|
+
Issues one read (`get_schedules`, i.e. a GET of the profile)
|
|
528
|
+
followed by one DELETE per existing pause -- N deletes for N pauses.
|
|
529
|
+
Each DELETE is live-verified (see `delete_schedule`). This is never retried;
|
|
311
530
|
a pause that fails to delete is left in place and its response
|
|
312
531
|
(or the raised exception) is not swallowed.
|
|
313
532
|
|
|
@@ -322,6 +541,8 @@ class ScheduleAPI(AuthenticatedAPI):
|
|
|
322
541
|
|
|
323
542
|
Raises:
|
|
324
543
|
EeroAuthenticationException: If not authenticated
|
|
544
|
+
EeroValidationException: If ``parent`` is not the profile's own
|
|
545
|
+
envelope (its ``url`` is not a profile path)
|
|
325
546
|
EeroAPIException: If the API returns an error for the read, or
|
|
326
547
|
for any individual delete (raised immediately, aborting any
|
|
327
548
|
remaining deletes).
|
|
@@ -362,7 +583,7 @@ class ScheduleAPI(AuthenticatedAPI):
|
|
|
362
583
|
profile: The profile's bare ID, path, or absolute URL.
|
|
363
584
|
start_time: Time to start blocking (``HH:MM``, e.g. ``"21:00"``).
|
|
364
585
|
end_time: Time to end blocking (``HH:MM``, e.g. ``"07:00"``).
|
|
365
|
-
days: Days to apply. Defaults to all seven days.
|
|
586
|
+
days: Days to apply (any case). Defaults to all seven days.
|
|
366
587
|
parent: The profile's own cached envelope, if the caller has one.
|
|
367
588
|
|
|
368
589
|
Returns:
|
|
@@ -4,8 +4,8 @@ IMPORTANT: This module returns RAW responses from the Eero Cloud API.
|
|
|
4
4
|
All data extraction, field mapping, and transformation must be done by downstream clients.
|
|
5
5
|
|
|
6
6
|
SQM is a single boolean toggle on the network's ``settings`` resource,
|
|
7
|
-
written as a
|
|
8
|
-
per-direction bandwidth limits or an explicit "auto" mode.
|
|
7
|
+
written as a flat JSON body (``{"sqm": true}``) -- there is no API counterpart
|
|
8
|
+
for per-direction bandwidth limits or an explicit "auto" mode.
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
11
|
from typing import Any, Dict, Mapping, Optional
|
|
@@ -13,7 +13,7 @@ from typing import Any, Dict, Mapping, Optional
|
|
|
13
13
|
from ..const import API_ENDPOINT
|
|
14
14
|
from ..exceptions import EeroAuthenticationException
|
|
15
15
|
from ..logging import get_secure_logger
|
|
16
|
-
from ._writes import as_envelope
|
|
16
|
+
from ._writes import as_envelope
|
|
17
17
|
from .auth import AuthAPI
|
|
18
18
|
from .base import AuthenticatedAPI
|
|
19
19
|
from .links import Envelope, resource_url, self_url, sub_resource_url
|
|
@@ -81,17 +81,21 @@ class SqmAPI(AuthenticatedAPI):
|
|
|
81
81
|
) -> Dict[str, Any]:
|
|
82
82
|
"""Enable or disable SQM (Smart Queue Management) - returns raw Eero API response.
|
|
83
83
|
|
|
84
|
-
Issues a PUT
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
..
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
Issues a PUT to the network's ``settings`` link with a flat JSON
|
|
85
|
+
body, ``{"sqm": <bool>}``. The response is the full network
|
|
86
|
+
envelope, with the new value under ``data.sqm``.
|
|
87
|
+
|
|
88
|
+
.. note::
|
|
89
|
+
Live-verified 2026-12-01 by read-back of the network's ``sqm``
|
|
90
|
+
field: ``{"sqm": true}`` flipped it to true and ``{"sqm": false}``
|
|
91
|
+
restored it, each confirmed seconds and minutes after the write.
|
|
92
|
+
The earlier query-parameter form (``?sqm=true`` with no body)
|
|
93
|
+
returned 200 without applying anything, which is why it was
|
|
94
|
+
replaced. No node rebooted in that verification (one network, so
|
|
95
|
+
not a guarantee): settings-class writes elsewhere in this API
|
|
96
|
+
have restarted the mesh, so read `get_sqm_settings` first, only
|
|
97
|
+
write when the stored value differs from the desired one, and
|
|
98
|
+
never retry in a loop.
|
|
95
99
|
|
|
96
100
|
Args:
|
|
97
101
|
network_id: A bare network ID, API-returned path, or absolute URL.
|
|
@@ -114,9 +118,5 @@ class SqmAPI(AuthenticatedAPI):
|
|
|
114
118
|
url = sub_resource_url(
|
|
115
119
|
network_id, "networks/{id}/settings", link="settings", parent=as_envelope(parent)
|
|
116
120
|
)
|
|
117
|
-
|
|
118
|
-
return await self.put(
|
|
119
|
-
url,
|
|
120
|
-
auth_token=auth_token,
|
|
121
|
-
params={"sqm": "true" if enabled else "false"},
|
|
122
|
-
)
|
|
121
|
+
_LOGGER.debug("Setting SQM to %s for network %s", enabled, network_id)
|
|
122
|
+
return await self.put(url, auth_token=auth_token, json={"sqm": bool(enabled)})
|
|
@@ -16,6 +16,7 @@ from aiohttp import ClientSession, ClientTimeout
|
|
|
16
16
|
from .api import EeroAPI
|
|
17
17
|
from .api._params import require_bool, require_hour, require_non_empty_string
|
|
18
18
|
from .api.base import id_from_url
|
|
19
|
+
from .api.schedule import schedule_owner
|
|
19
20
|
from .const import DEFAULT_ACCEPT_LANGUAGE
|
|
20
21
|
from .exceptions import EeroException
|
|
21
22
|
|
|
@@ -1299,7 +1300,7 @@ class EeroClient:
|
|
|
1299
1300
|
"""
|
|
1300
1301
|
network_id = await self._ensure_network_id(network_id)
|
|
1301
1302
|
|
|
1302
|
-
cache_key =
|
|
1303
|
+
cache_key = self._profiles_list_cache_key(network_id)
|
|
1303
1304
|
if not refresh_cache and self._is_cache_valid("profiles", cache_key):
|
|
1304
1305
|
cached = self._get_from_cache("profiles", cache_key)
|
|
1305
1306
|
if cached:
|
|
@@ -1333,7 +1334,7 @@ class EeroClient:
|
|
|
1333
1334
|
"""
|
|
1334
1335
|
network_id = await self._ensure_network_id(network_id)
|
|
1335
1336
|
|
|
1336
|
-
cache_key =
|
|
1337
|
+
cache_key = self._profile_cache_key(network_id, profile_id)
|
|
1337
1338
|
if not refresh_cache and self._is_cache_valid("profiles", cache_key):
|
|
1338
1339
|
cached = self._get_from_cache("profiles", cache_key)
|
|
1339
1340
|
if cached:
|
|
@@ -1366,23 +1367,41 @@ class EeroClient:
|
|
|
1366
1367
|
|
|
1367
1368
|
return response
|
|
1368
1369
|
|
|
1370
|
+
@staticmethod
|
|
1371
|
+
def _bare_id(value: Any) -> str:
|
|
1372
|
+
"""Reduce a bare id, path or absolute URL to its trailing segment.
|
|
1373
|
+
|
|
1374
|
+
Unlike `id_from_url` this never raises: it runs in ``finally`` blocks,
|
|
1375
|
+
where an exception would mask the original one.
|
|
1376
|
+
"""
|
|
1377
|
+
if isinstance(value, str) and value:
|
|
1378
|
+
return id_from_url(value)
|
|
1379
|
+
return str(value)
|
|
1380
|
+
|
|
1381
|
+
def _profile_cache_key(self, network_id: str, profile_id: str) -> str:
|
|
1382
|
+
"""Key a single profile by bare network and profile ids.
|
|
1383
|
+
|
|
1384
|
+
A caller may pass a bare id, an API path or an absolute URL; all
|
|
1385
|
+
three share one entry, so a write that knows only the bare ids (such
|
|
1386
|
+
as a schedule write) evicts whichever form was read.
|
|
1387
|
+
"""
|
|
1388
|
+
return f"{self._bare_id(network_id)}_{self._bare_id(profile_id)}"
|
|
1389
|
+
|
|
1390
|
+
def _profiles_list_cache_key(self, network_id: str) -> str:
|
|
1391
|
+
"""Key a network's profiles list by its bare network id."""
|
|
1392
|
+
return f"{self._bare_id(network_id)}_profiles"
|
|
1393
|
+
|
|
1369
1394
|
def _invalidate_profile_cache(self, network_id: str, profile_id: str) -> None:
|
|
1370
1395
|
"""Invalidate profile-related cache entries."""
|
|
1371
1396
|
self._cache_epoch += 1
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
cache_key = f"{network_id}_profiles"
|
|
1377
|
-
if cache_key in self._cache.get("profiles", {}):
|
|
1378
|
-
del self._cache["profiles"][cache_key]
|
|
1397
|
+
profiles = self._cache.get("profiles", {})
|
|
1398
|
+
profiles.pop(self._profile_cache_key(network_id, profile_id), None)
|
|
1399
|
+
profiles.pop(self._profiles_list_cache_key(network_id), None)
|
|
1379
1400
|
|
|
1380
1401
|
def _invalidate_profiles_list_cache(self, network_id: str) -> None:
|
|
1381
1402
|
"""Invalidate the profiles list cache for a network."""
|
|
1382
1403
|
self._cache_epoch += 1
|
|
1383
|
-
|
|
1384
|
-
if cache_key in self._cache.get("profiles", {}):
|
|
1385
|
-
del self._cache["profiles"][cache_key]
|
|
1404
|
+
self._cache.get("profiles", {}).pop(self._profiles_list_cache_key(network_id), None)
|
|
1386
1405
|
|
|
1387
1406
|
def _invalidate_all_profile_caches(self, network_id: str) -> None:
|
|
1388
1407
|
"""Invalidate every cached profile of a network, and its profiles list.
|
|
@@ -1392,7 +1411,7 @@ class EeroClient:
|
|
|
1392
1411
|
unknown), so no single-profile entry of that network can be trusted.
|
|
1393
1412
|
"""
|
|
1394
1413
|
self._cache_epoch += 1
|
|
1395
|
-
prefix = f"{network_id}_"
|
|
1414
|
+
prefix = f"{self._bare_id(network_id)}_"
|
|
1396
1415
|
profiles = self._cache.get("profiles", {})
|
|
1397
1416
|
for cache_key in [key for key in profiles if key.startswith(prefix)]:
|
|
1398
1417
|
del profiles[cache_key]
|
|
@@ -2632,7 +2651,14 @@ class EeroClient:
|
|
|
2632
2651
|
async def get_schedules(
|
|
2633
2652
|
self, profile_id: str, network_id: Optional[str] = None
|
|
2634
2653
|
) -> Dict[str, Any]:
|
|
2635
|
-
"""Get the scheduled pauses for a profile
|
|
2654
|
+
"""Get the scheduled pauses for a profile.
|
|
2655
|
+
|
|
2656
|
+
Derived from the profile resource: the schedules collection GET
|
|
2657
|
+
returns 404 (live-verified 2026-12-01), so this returns
|
|
2658
|
+
``{"meta": ..., "data": <the profile's "schedule" list>}``. Each
|
|
2659
|
+
element has ``url``, ``name``, ``enabled``, ``days``, ``start`` and
|
|
2660
|
+
``end`` and no ``id``.
|
|
2661
|
+
"""
|
|
2636
2662
|
network_id = await self._ensure_network_id(network_id, auto_discover=False)
|
|
2637
2663
|
return await self._api.schedule.get_schedules(network_id, profile_id)
|
|
2638
2664
|
|
|
@@ -2649,15 +2675,19 @@ class EeroClient:
|
|
|
2649
2675
|
) -> Dict[str, Any]:
|
|
2650
2676
|
"""Create a scheduled pause for a profile - returns raw Eero API response.
|
|
2651
2677
|
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2678
|
+
Day names may be given in any case; the capitalised form the API
|
|
2679
|
+
requires is sent. The response is the full PROFILE envelope, not the
|
|
2680
|
+
new pause. Live-verified 2026-12-01 (capitalised days; lowercase is
|
|
2681
|
+
refused with 400). Do not retry a failed write in a loop.
|
|
2656
2682
|
"""
|
|
2657
2683
|
network_id = await self._ensure_network_id(network_id, auto_discover=False)
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2684
|
+
try:
|
|
2685
|
+
return await self._api.schedule.create_schedule(
|
|
2686
|
+
network_id, profile_id, name=name, days=days, start=start, end=end, enabled=enabled
|
|
2687
|
+
)
|
|
2688
|
+
finally:
|
|
2689
|
+
# A timeout can follow a create the server did apply.
|
|
2690
|
+
self._invalidate_profile_cache(network_id, profile_id)
|
|
2661
2691
|
|
|
2662
2692
|
async def update_schedule(
|
|
2663
2693
|
self,
|
|
@@ -2669,33 +2699,65 @@ class EeroClient:
|
|
|
2669
2699
|
end: Optional[str] = None,
|
|
2670
2700
|
enabled: Optional[bool] = None,
|
|
2671
2701
|
) -> Dict[str, Any]:
|
|
2672
|
-
"""Update a scheduled pause
|
|
2702
|
+
"""Update a scheduled pause - returns raw Eero API response.
|
|
2703
|
+
|
|
2704
|
+
The API's PUT is a full replace (``start``/``end`` required; an
|
|
2705
|
+
omitted ``enabled`` resets the pause to enabled), so this reads the
|
|
2706
|
+
profile, merges the supplied fields over the pause's current
|
|
2707
|
+
``name``, ``days``, ``start``, ``end`` and ``enabled``, and PUTs all
|
|
2708
|
+
five. The response is the full PROFILE envelope.
|
|
2673
2709
|
|
|
2674
2710
|
.. warning::
|
|
2675
|
-
|
|
2676
|
-
the read
|
|
2711
|
+
The read-modify-write is not atomic: a concurrent edit made
|
|
2712
|
+
between the read and the write is overwritten. A PUT carrying all
|
|
2713
|
+
five fields has not been sent live (a PUT without ``enabled``
|
|
2714
|
+
was verified 2026-12-01). Do not retry on failure.
|
|
2677
2715
|
|
|
2678
2716
|
Args:
|
|
2679
|
-
schedule: The pause's own path/absolute URL (
|
|
2680
|
-
`get_schedules
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2717
|
+
schedule: The pause's own path/absolute URL (the ``url`` of an
|
|
2718
|
+
element from `get_schedules`), or an element carrying it.
|
|
2719
|
+
The pause is always re-read; cached values are not merged.
|
|
2720
|
+
name: New name, or ``None`` to keep the current one.
|
|
2721
|
+
days: New days (any case), or ``None`` to keep the current ones.
|
|
2722
|
+
start: New start time, or ``None`` to keep it.
|
|
2723
|
+
end: New end time, or ``None`` to keep it.
|
|
2724
|
+
enabled: New enabled state, or ``None`` to keep it.
|
|
2725
|
+
|
|
2726
|
+
Raises:
|
|
2727
|
+
EeroValidationException: If ``schedule`` is not a pause's own
|
|
2728
|
+
path/URL (raised before any request).
|
|
2729
|
+
EeroNotFoundException: If the profile has no pause at that URL.
|
|
2686
2730
|
"""
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2731
|
+
# Resolved first so bad input raises unmasked, before any request.
|
|
2732
|
+
owner = schedule_owner(schedule)
|
|
2733
|
+
try:
|
|
2734
|
+
return await self._api.schedule.update_schedule(
|
|
2735
|
+
schedule, name=name, days=days, start=start, end=end, enabled=enabled
|
|
2736
|
+
)
|
|
2737
|
+
finally:
|
|
2738
|
+
# A timeout or 5xx can follow a write the server did apply.
|
|
2739
|
+
self._invalidate_profile_cache(*owner)
|
|
2690
2740
|
|
|
2691
2741
|
async def delete_schedule(self, schedule: Any) -> Dict[str, Any]:
|
|
2692
2742
|
"""Delete a scheduled pause via its own URL - returns raw Eero API response.
|
|
2693
2743
|
|
|
2744
|
+
Live-verified 2026-12-01. Only a pause's own URL is accepted; the
|
|
2745
|
+
envelope returned by `create_schedule` / `update_schedule` is the
|
|
2746
|
+
PROFILE and is refused. Invalidates the owning profile's cache.
|
|
2747
|
+
|
|
2694
2748
|
Args:
|
|
2695
|
-
schedule: The pause's own path/absolute URL, or
|
|
2696
|
-
|
|
2749
|
+
schedule: The pause's own path/absolute URL, or an element
|
|
2750
|
+
carrying it.
|
|
2751
|
+
|
|
2752
|
+
Raises:
|
|
2753
|
+
EeroValidationException: If ``schedule`` is not a pause's own
|
|
2754
|
+
path/URL (raised before any request).
|
|
2697
2755
|
"""
|
|
2698
|
-
|
|
2756
|
+
owner = schedule_owner(schedule)
|
|
2757
|
+
try:
|
|
2758
|
+
return await self._api.schedule.delete_schedule(schedule)
|
|
2759
|
+
finally:
|
|
2760
|
+
self._invalidate_profile_cache(*owner)
|
|
2699
2761
|
|
|
2700
2762
|
async def clear_profile_schedule(
|
|
2701
2763
|
self, profile_id: str, network_id: Optional[str] = None
|
|
@@ -2706,7 +2768,11 @@ class EeroClient:
|
|
|
2706
2768
|
A list of the raw API responses from each individual DELETE.
|
|
2707
2769
|
"""
|
|
2708
2770
|
network_id = await self._ensure_network_id(network_id, auto_discover=False)
|
|
2709
|
-
|
|
2771
|
+
try:
|
|
2772
|
+
return await self._api.schedule.clear_profile_schedule(network_id, profile_id)
|
|
2773
|
+
finally:
|
|
2774
|
+
# Deletes already sent stay applied when a later one fails.
|
|
2775
|
+
self._invalidate_profile_cache(network_id, profile_id)
|
|
2710
2776
|
|
|
2711
2777
|
async def enable_bedtime(
|
|
2712
2778
|
self,
|
|
@@ -2718,9 +2784,12 @@ class EeroClient:
|
|
|
2718
2784
|
) -> Dict[str, Any]:
|
|
2719
2785
|
"""Enable bedtime - returns raw Eero API response."""
|
|
2720
2786
|
network_id = await self._ensure_network_id(network_id, auto_discover=False)
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2787
|
+
try:
|
|
2788
|
+
return await self._api.schedule.enable_bedtime(
|
|
2789
|
+
network_id, profile_id, start_time, end_time, days
|
|
2790
|
+
)
|
|
2791
|
+
finally:
|
|
2792
|
+
self._invalidate_profile_cache(network_id, profile_id)
|
|
2724
2793
|
|
|
2725
2794
|
async def set_weekday_bedtime(
|
|
2726
2795
|
self,
|
|
@@ -2734,17 +2803,13 @@ class EeroClient:
|
|
|
2734
2803
|
"""Create a weekday (Monday-Friday) bedtime for a profile - returns raw Eero API response.
|
|
2735
2804
|
|
|
2736
2805
|
This CREATES a new schedule on every call; it does not update an
|
|
2737
|
-
existing one. The day set is ``eero.api.schedule.WEEKDAYS
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
unverified (#172), so to change an existing bedtime read
|
|
2745
|
-
:meth:`get_schedules` and delete and recreate it rather than rely
|
|
2746
|
-
on :meth:`update_schedule` omitting fields. Never retry a failed
|
|
2747
|
-
write in a loop.
|
|
2806
|
+
existing one. The day set is ``eero.api.schedule.WEEKDAYS``
|
|
2807
|
+
(capitalised names, as the API requires; the create call is
|
|
2808
|
+
live-verified 2026-12-01). To change an existing bedtime use
|
|
2809
|
+
:meth:`update_schedule`, which merges over the current values; note
|
|
2810
|
+
that it is still an uncharacterised write (a non-atomic
|
|
2811
|
+
read-merge-write that logs a warning). Never retry a failed write in
|
|
2812
|
+
a loop.
|
|
2748
2813
|
|
|
2749
2814
|
Args:
|
|
2750
2815
|
profile_id: ID of the profile
|
|
@@ -2764,11 +2829,12 @@ class EeroClient:
|
|
|
2764
2829
|
network_id = await self._ensure_network_id(network_id, auto_discover=False)
|
|
2765
2830
|
# No cached profile envelope is looked up here: only the caller's own.
|
|
2766
2831
|
parent_kwargs: Dict[str, Any] = {} if parent is None else {"parent": parent}
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2832
|
+
try:
|
|
2833
|
+
return await self._api.schedule.set_weekday_bedtime(
|
|
2834
|
+
network_id, profile_id, start_time, end_time, **parent_kwargs
|
|
2835
|
+
)
|
|
2836
|
+
finally:
|
|
2837
|
+
self._invalidate_profile_cache(network_id, profile_id)
|
|
2772
2838
|
|
|
2773
2839
|
async def set_weekend_bedtime(
|
|
2774
2840
|
self,
|
|
@@ -2782,17 +2848,13 @@ class EeroClient:
|
|
|
2782
2848
|
"""Create a weekend (Saturday-Sunday) bedtime for a profile - returns raw Eero API response.
|
|
2783
2849
|
|
|
2784
2850
|
This CREATES a new schedule on every call; it does not update an
|
|
2785
|
-
existing one. The day set is ``eero.api.schedule.WEEKEND
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
unverified (#172), so to change an existing bedtime read
|
|
2793
|
-
:meth:`get_schedules` and delete and recreate it rather than rely
|
|
2794
|
-
on :meth:`update_schedule` omitting fields. Never retry a failed
|
|
2795
|
-
write in a loop.
|
|
2851
|
+
existing one. The day set is ``eero.api.schedule.WEEKEND``
|
|
2852
|
+
(capitalised names, as the API requires; the create call is
|
|
2853
|
+
live-verified 2026-12-01). To change an existing bedtime use
|
|
2854
|
+
:meth:`update_schedule`, which merges over the current values; note
|
|
2855
|
+
that it is still an uncharacterised write (a non-atomic
|
|
2856
|
+
read-merge-write that logs a warning). Never retry a failed write in
|
|
2857
|
+
a loop.
|
|
2796
2858
|
|
|
2797
2859
|
Args:
|
|
2798
2860
|
profile_id: ID of the profile
|
|
@@ -2811,11 +2873,12 @@ class EeroClient:
|
|
|
2811
2873
|
"""
|
|
2812
2874
|
network_id = await self._ensure_network_id(network_id, auto_discover=False)
|
|
2813
2875
|
parent_kwargs: Dict[str, Any] = {} if parent is None else {"parent": parent}
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2876
|
+
try:
|
|
2877
|
+
return await self._api.schedule.set_weekend_bedtime(
|
|
2878
|
+
network_id, profile_id, start_time, end_time, **parent_kwargs
|
|
2879
|
+
)
|
|
2880
|
+
finally:
|
|
2881
|
+
self._invalidate_profile_cache(network_id, profile_id)
|
|
2819
2882
|
|
|
2820
2883
|
# ==================== DNS ====================
|
|
2821
2884
|
|
|
@@ -2919,13 +2982,14 @@ class EeroClient:
|
|
|
2919
2982
|
async def set_sqm(self, enabled: bool, network_id: Optional[str] = None) -> Dict[str, Any]:
|
|
2920
2983
|
"""Enable or disable SQM (Smart Queue Management) - returns raw Eero API response.
|
|
2921
2984
|
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2985
|
+
Sends a flat JSON body ``{"sqm": <bool>}`` to the network's
|
|
2986
|
+
``settings`` link; live-verified 2026-12-01 by read-back of the
|
|
2987
|
+
network's ``sqm`` field (the query-parameter form returned 200
|
|
2988
|
+
without applying). No node rebooted in that verification (one
|
|
2989
|
+
network, not a guarantee), but settings-class writes elsewhere in
|
|
2990
|
+
this API have restarted the mesh: read `get_sqm_settings` first,
|
|
2991
|
+
only write when the stored value differs from the desired one, and
|
|
2992
|
+
never retry in a loop.
|
|
2929
2993
|
"""
|
|
2930
2994
|
network_id = await self._ensure_network_id(network_id, auto_discover=False)
|
|
2931
2995
|
response = await self._api.sqm.set_sqm(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|