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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
//! `Client` methods for the `EerosAPI` domain (`eero-api src/eero/client.py`, eeros section).
//!
//! See `.claude/tasks/briefs/v8/g2-eeros.md` §3 for the full "facade name/shape divergences"
//! list this file reproduces: which methods pass `_eero_parent_kwargs`/`_network_parent_kwargs`,
//! which invalidate `eeros[{nid}_eeros]`, and the two "resolves `network_id` only for cache
//! invalidation, never forwards it to the domain call" quirks ([`Client::port_action`],
//! [`Client::nightlight_override`]).
use super::Client;
use crate::cache::CacheKey;
use crate::envelope::Envelope;
use crate::error::Error;
use serde_json::Value;
impl Client {
/// Gets the list of Eero devices (mesh nodes) on a network — returns the raw Eero API
/// response.
///
/// Ported from `get_eeros()` (`eero-api src/eero/client.py:565-592`). `auto_discover = true`
/// — see [`Client::get_network`]. On a cache miss, passes the cached network envelope (if
/// any) as `parent=`, so a fresh `resources.eeros` link wins over the hand-built template.
///
/// # Errors
///
/// See [`Client::get_network`].
pub async fn get_eeros(
&self,
network_id: Option<&str>,
refresh_cache: bool,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, true).await?;
let key = CacheKey::eeros(network_id.as_str());
if !refresh_cache && let Some(cached) = self.cache.get(&key) {
return Ok(cached);
}
let parent = self.network_parent(&network_id);
let response = self
.api
.eeros()
.get_eeros(&network_id, parent.as_ref())
.await?;
self.cache.put(key, response.clone());
Ok(response)
}
/// Gets information about a specific Eero device — returns the raw Eero API response.
///
/// Ported from `get_eero()` (`eero-api src/eero/client.py:594-616`). `auto_discover = true` —
/// see [`Client::get_network`]. **Never cached**: `refresh_cache` is accepted for signature
/// parity with Python but intentionally never consulted (`wiki/API-Reference.md:144`) — this
/// is always a live call. Passes the cached eero entry (if any) as `parent=`.
///
/// # Errors
///
/// See [`Client::get_network`].
pub async fn get_eero(
&self,
eero_id: &str,
network_id: Option<&str>,
refresh_cache: bool,
) -> Result<Envelope, Error> {
let _ = refresh_cache;
let network_id = self.ensure_network_id(network_id, true).await?;
let parent = self.eero_parent(&network_id, eero_id);
self.api.eeros().get_eero(eero_id, parent.as_ref()).await
}
/// Reboots a single Eero device — returns the raw Eero API response.
///
/// Ported from `reboot_eero()` (`eero-api src/eero/client.py:618-643`). `auto_discover = true`
/// — see [`Client::get_network`]. On success, invalidates `eeros[{nid}_eeros]`.
///
/// # Errors
///
/// See [`Client::get_network`]. The cache is left untouched on any `Err`.
pub async fn reboot_eero(
&self,
eero_id: &str,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, true).await?;
let parent = self.eero_parent(&network_id, eero_id);
let response = self
.api
.eeros()
.reboot_eero(eero_id, parent.as_ref())
.await?;
self.cache.invalidate(&CacheKey::eeros(network_id.as_str()));
Ok(response)
}
/// Sets an Eero device's Wi-Fi location label — returns the raw Eero API response.
///
/// Ported from `set_location()` (`eero-api src/eero/client.py:645-661`). `auto_discover =
/// false` — see [`Client::get_diagnostics`]. On success, invalidates `eeros[{nid}_eeros]`.
/// **Unverified against a live network.**
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_location(
&self,
eero_id: &str,
location: &str,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
let parent = self.eero_parent(&network_id, eero_id);
let response = self
.api
.eeros()
.set_location(eero_id, location, parent.as_ref())
.await?;
self.cache.invalidate(&CacheKey::eeros(network_id.as_str()));
Ok(response)
}
/// Gets a single Eero device's client connections — returns the raw Eero API response.
///
/// Ported from `get_connections()` (`eero-api src/eero/client.py:663-673`). `auto_discover =
/// false` — see [`Client::get_diagnostics`]. Not cached (`connections` has no cache bucket).
///
/// # Errors
///
/// See [`Client::get_diagnostics`].
pub async fn get_connections(
&self,
eero_id: &str,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
let parent = self.eero_parent(&network_id, eero_id);
self.api
.eeros()
.get_connections(eero_id, parent.as_ref())
.await
}
// ==================== LED & Nightlight ====================
/// Gets LED status for an Eero device — returns the raw Eero API response.
///
/// Ported from `get_led_status()` (`eero-api src/eero/client.py:1854-1861`). `auto_discover =
/// false` — see [`Client::get_diagnostics`]. Not cached.
///
/// # Errors
///
/// See [`Client::get_diagnostics`].
pub async fn get_led_status(
&self,
eero_id: &str,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
let parent = self.eero_parent(&network_id, eero_id);
self.api
.eeros()
.get_led_status(eero_id, parent.as_ref())
.await
}
/// Turns an Eero device's status LED on or off — returns the raw Eero API response.
///
/// Ported from `set_led()` (`eero-api src/eero/client.py:1863-1872`). `auto_discover = false`
/// — see [`Client::get_diagnostics`]. On success, invalidates `eeros[{nid}_eeros]`.
///
/// # Errors
///
/// See [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_led(
&self,
eero_id: &str,
enabled: bool,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
let parent = self.eero_parent(&network_id, eero_id);
let response = self
.api
.eeros()
.set_led(eero_id, enabled, parent.as_ref())
.await?;
self.cache.invalidate(&CacheKey::eeros(network_id.as_str()));
Ok(response)
}
/// Sets an Eero device's status LED brightness — returns the raw Eero API response.
///
/// Ported from `set_led_brightness()` (`eero-api src/eero/client.py:1874-1883`).
/// `auto_discover = false` — see [`Client::get_diagnostics`]. On success, invalidates
/// `eeros[{nid}_eeros]`.
///
/// # Errors
///
/// Returns `Error::Validation { field: "brightness", .. }` if `brightness` is outside
/// `0..=100` (v8.0.4 rejects rather than clamping — see
/// [`crate::endpoints::EerosApi::set_led_brightness`]). Otherwise see
/// [`Client::get_diagnostics`]. The cache is left untouched on any `Err`.
pub async fn set_led_brightness(
&self,
eero_id: &str,
brightness: i32,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
let parent = self.eero_parent(&network_id, eero_id);
let response = self
.api
.eeros()
.set_led_brightness(eero_id, brightness, parent.as_ref())
.await?;
self.cache.invalidate(&CacheKey::eeros(network_id.as_str()));
Ok(response)
}
/// Gets nightlight settings for an Eero Beacon device — returns the raw Eero API response.
///
/// Ported from `get_nightlight()` (`eero-api src/eero/client.py:1885-1892`). `auto_discover =
/// false` — see [`Client::get_diagnostics`]. Not cached.
///
/// # Errors
///
/// Returns [`Error::FeatureUnavailable`] if the eero has no nightlight. Otherwise see
/// [`Client::get_diagnostics`].
pub async fn get_nightlight(
&self,
eero_id: &str,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
let parent = self.eero_parent(&network_id, eero_id);
self.api
.eeros()
.get_nightlight(eero_id, parent.as_ref())
.await
}
/// Sets nightlight settings for an Eero Beacon device — returns the raw Eero API response.
///
/// Ported from `set_nightlight()` (`eero-api src/eero/client.py:1894-1920`). Every setting is
/// optional and independent, delegating unchanged to
/// [`crate::endpoints::EerosApi::set_nightlight`] — see that method's own docs for the
/// brightness validation, the "at least one field" rule, and the discovery/URL-resolution
/// order. `auto_discover = false` — see [`Client::get_diagnostics`]. On success, invalidates
/// `eeros[{nid}_eeros]`. **Unverified against a live network.**
///
/// # Errors
///
/// See [`crate::endpoints::EerosApi::set_nightlight`], and [`Client::get_diagnostics`]. The
/// cache is left untouched on any `Err`.
pub async fn set_nightlight(
&self,
eero_id: &str,
enabled: Option<bool>,
brightness_percentage: Option<i32>,
schedule: Option<Value>,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
let parent = self.eero_parent(&network_id, eero_id);
let response = self
.api
.eeros()
.set_nightlight(
eero_id,
enabled,
brightness_percentage,
schedule,
parent.as_ref(),
)
.await?;
self.cache.invalidate(&CacheKey::eeros(network_id.as_str()));
Ok(response)
}
/// Sets only the nightlight brightness for an Eero Beacon device — returns the raw Eero API
/// response.
///
/// Ported from `set_nightlight_brightness()` (`eero-api src/eero/client.py:1922-1935`); a
/// pure delegator to [`Client::set_nightlight`], sharing its cache invalidation and `parent=`
/// resolution exactly — matches `eeros.py:551-579`'s own delegation shape one layer up.
///
/// # Errors
///
/// See [`Client::set_nightlight`]. Never returns the "at least one field" validation error: a
/// `brightness_percentage` value is always supplied here.
pub async fn set_nightlight_brightness(
&self,
eero_id: &str,
brightness_percentage: i32,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
self.set_nightlight(eero_id, None, Some(brightness_percentage), None, network_id)
.await
}
/// Sets only the nightlight schedule for an Eero Beacon device — returns the raw Eero API
/// response.
///
/// Ported from `set_nightlight_schedule()` (`eero-api src/eero/client.py:1937-1950`); a pure
/// delegator to [`Client::set_nightlight`], sharing its cache invalidation and `parent=`
/// resolution exactly.
///
/// # Errors
///
/// See [`Client::set_nightlight`]. Never returns the "at least one field" validation error:
/// `schedule` is always supplied here.
pub async fn set_nightlight_schedule(
&self,
eero_id: &str,
schedule: Value,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
self.set_nightlight(eero_id, None, None, Some(schedule), network_id)
.await
}
/// Performs a node-level action on an Eero device — returns the raw Eero API response.
///
/// Ported from `node_action()` (`eero-api src/eero/client.py:3074-3087`). `auto_discover =
/// false` — see [`Client::get_diagnostics`]. On success, invalidates `eeros[{nid}_eeros]`.
/// **Unverified against a live network.**
///
/// # Errors
///
/// See [`crate::endpoints::EerosApi::node_action`], and [`Client::get_diagnostics`]. The
/// cache is left untouched on any `Err`.
pub async fn node_action(
&self,
eero_id: &str,
action: &str,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
let parent = self.eero_parent(&network_id, eero_id);
let response = self
.api
.eeros()
.node_action(eero_id, action, parent.as_ref())
.await?;
self.cache.invalidate(&CacheKey::eeros(network_id.as_str()));
Ok(response)
}
/// Performs a port-level action on an Eero device's interface — returns the raw Eero API
/// response.
///
/// Ported from `port_action()` (`eero-api src/eero/client.py:3088-3096`). `auto_discover =
/// false` — see [`Client::get_diagnostics`]. **Quirk, reproduced deliberately**: `network_id`
/// is resolved only to invalidate `eeros[{nid}_eeros]` on success — it is never forwarded to
/// [`crate::endpoints::EerosApi::port_action`], which has no `network_id` parameter at all
/// (see that method's own docs).
///
/// # Errors
///
/// See [`crate::endpoints::EerosApi::port_action`], and [`Client::get_diagnostics`]. The
/// cache is left untouched on any `Err`.
pub async fn port_action(
&self,
eero_id: &str,
interface_number: u32,
action: &str,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
let response = self
.api
.eeros()
.port_action(eero_id, interface_number, action)
.await?;
self.cache.invalidate(&CacheKey::eeros(network_id.as_str()));
Ok(response)
}
/// Cycles an Eero device's status LED through a colour sequence — returns the raw Eero API
/// response.
///
/// Ported from `led_cycle()` (`eero-api src/eero/client.py:3097-3104`). No `network_id`
/// parameter at all, matching [`crate::endpoints::EerosApi::led_cycle`] — addressed by
/// `eero_serial` alone, so nothing is invalidated (there is no network context to key a
/// cache invalidation on). **Unverified against a live network.**
///
/// # Errors
///
/// See [`crate::endpoints::EerosApi::led_cycle`].
pub async fn led_cycle(
&self,
eero_serial: &str,
colors: &[String],
duration: u32,
time_per_color: u32,
) -> Result<Envelope, Error> {
self.api
.eeros()
.led_cycle(eero_serial, colors, duration, time_per_color)
.await
}
/// Previews a nightlight brightness value without persisting it — returns the raw Eero API
/// response.
///
/// Ported from `nightlight_override()` (`eero-api src/eero/client.py:3105-3115`).
/// `auto_discover = false` — see [`Client::get_diagnostics`]. **Quirk, reproduced
/// deliberately**: `network_id` is resolved only to invalidate `eeros[{nid}_eeros]` on
/// success — it is never forwarded to
/// [`crate::endpoints::EerosApi::nightlight_override`], which has no `network_id` parameter
/// at all (see that method's own docs).
///
/// # Errors
///
/// See [`crate::endpoints::EerosApi::nightlight_override`], and [`Client::get_diagnostics`].
/// The cache is left untouched on any `Err`.
pub async fn nightlight_override(
&self,
eero_id: &str,
brightness_percentage: i32,
network_id: Option<&str>,
) -> Result<Envelope, Error> {
let network_id = self.ensure_network_id(network_id, false).await?;
let response = self
.api
.eeros()
.nightlight_override(eero_id, brightness_percentage)
.await?;
self.cache.invalidate(&CacheKey::eeros(network_id.as_str()));
Ok(response)
}
/// Gets an Eero device's support/diagnostics summary — returns the raw Eero API response.
///
/// Ported from `get_eero_support()` (`eero-api src/eero/client.py:3116-3122`). No
/// `network_id` parameter at all, matching
/// [`crate::endpoints::EerosApi::get_eero_support`] — addressed by `eero_serial` alone. Not
/// cached.
pub async fn get_eero_support(&self, eero_serial: &str) -> Result<Envelope, Error> {
self.api.eeros().get_eero_support(eero_serial).await
}
}