@mega-yfue/eufy-sdk 0.6.0-beta.25 → 0.6.0-beta.27

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.
package/dist/index.js CHANGED
@@ -3474,12 +3474,13 @@ function describe(description, fn, m) {
3474
3474
  function reports(requires, ctx) {
3475
3475
  return !requires || requires.some((p) => ctx.paramIds.has(p));
3476
3476
  }
3477
- function narrow(type, read, prop) {
3477
+ function narrow(type, read, prop, values) {
3478
3478
  if (type === "bool")
3479
3479
  return readBool(read, prop);
3480
3480
  if (type === "string")
3481
3481
  return readStr(read, prop);
3482
- return readNum(read, prop);
3482
+ const n = readNum(read, prop);
3483
+ return values && n !== void 0 && !(n in values) ? void 0 : n;
3483
3484
  }
3484
3485
  function reads(m, ctx) {
3485
3486
  return m.realtime === true || sent(m, ctx);
@@ -3532,7 +3533,9 @@ function bindMembers(members, deps) {
3532
3533
  if (reported && !m.writeOnly && !m.unexposed) {
3533
3534
  const decode = m.decode;
3534
3535
  const raw = () => read(prop)?.value ?? (borrowed === void 0 ? void 0 : read(borrowed)?.value);
3535
- const get = decode ? () => decode(raw(), rawDp2, ctx) : () => narrow(m.type, read, prop);
3536
+ const { values, dynamic } = resolvedEnum(m, ctx);
3537
+ const domain = (dynamic ? "enum" : m.kind) === "enum" ? values : void 0;
3538
+ const get = decode ? () => decode(raw(), rawDp2, ctx) : () => narrow(m.type, read, prop, domain);
3536
3539
  Object.defineProperty(out, name, { get, enumerable: true, configurable: true });
3537
3540
  }
3538
3541
  if (!m.write || m.unverified || !installs(m, ctx))
@@ -4776,6 +4779,9 @@ var BATTERY_MEMBERS = cellGated({
4776
4779
  * The headline percentage, and this capability's detection evidence: reporting 1101 is what proves a
4777
4780
  * device is battery-powered, which is also the fact `MediaProvider` reads to decide a stream needs a
4778
4781
  * power budget. Published flat as `battery` — `level` alone is claimed by `suction` too.
4782
+ *
4783
+ * Withheld on a device that resolved `lock`, whose own `battery` member reads the same param 1101 and
4784
+ * owns the `battery` property there, so the two do not both claim it.
4779
4785
  */
4780
4786
  level: {
4781
4787
  param: BATTERY_PARAM.BATTERY,
@@ -4784,6 +4790,7 @@ var BATTERY_MEMBERS = cellGated({
4784
4790
  unit: "%",
4785
4791
  kind: "percent",
4786
4792
  provenance: "verified",
4793
+ available: (ctx) => !hasCapability(ctx, "lock"),
4787
4794
  description: "Battery level 0-100 (verified: param 1101)."
4788
4795
  },
4789
4796
  /**
@@ -4802,7 +4809,7 @@ var BATTERY_MEMBERS = cellGated({
4802
4809
  /**
4803
4810
  * 1293 is the READABLE indicator (6445 is write-only/cloud-hidden). Verified live on a T8124R via an
4804
4811
  * app-toggle before/after diff: 0 = Battery, 1 = External Solar Panel. Values beyond 0/1 (some models
4805
- * report 5) are shown raw — `enumValues` only labels the two that are confirmed.
4812
+ * report 5) read as `undefined` — `enumValues` holds only the two that are confirmed.
4806
4813
  *
4807
4814
  * The write is a `1350` SET_PAYLOAD, inner cmd 1293, `{charge_mode:N}`, `mValue3` 0 (the app uses 0,
4808
4815
  * not the cmd id), and the setter accepts a NAME as well as the index the getter answers.
@@ -4817,7 +4824,7 @@ var BATTERY_MEMBERS = cellGated({
4817
4824
  requires: [BATTERY_PARAM.POWER_CHARGE],
4818
4825
  args: [{ name: "source", kind: "enum", description: "The raw value, or the name `battery`/`external`." }],
4819
4826
  ...accepts(),
4820
- description: "Configured power source (1293): 0 = Battery, 1 = External Solar Panel. Verified live on T8124R. The richer raw APP_CMD_SET_POWER_SOURCE blob is surfaced separately as `powerSourceInfo` (6445). Format varies by model (plain int or JSON {power_source:N}); values beyond 0/1 shown raw.",
4827
+ description: "Configured power source (1293): 0 = Battery, 1 = External Solar Panel. Verified live on T8124R. The richer raw APP_CMD_SET_POWER_SOURCE blob is surfaced separately as `powerSourceInfo` (6445). Format varies by model (plain int or JSON {power_source:N}); a value beyond 0/1 reads undefined.",
4821
4828
  write: (v, ctx) => setPayload(BATTERY_PARAM.POWER_CHARGE, { charge_mode: v === "external" ? 1 : v === "battery" ? 0 : asBool(v) ? 1 : 0 }, ctx, 0, void 0, "auto")
4822
4829
  },
4823
4830
  /**
@@ -6199,6 +6206,10 @@ var CAMERA_MEMBERS = {
6199
6206
  * sensor omits it, and the wire accepts the value regardless — the device's own reported set is the
6200
6207
  * only statement of which of the three it has. `coerceEnumValue` rejects a value outside
6201
6208
  * {@link NightVision} rather than coercing it. The payload key on the wire is `night_sion`.
6209
+ *
6210
+ * 1277 carries more than these three on some models: the V6 app's per-model mappings put modes on
6211
+ * 3, 5, 6 and 8 as well, and which model takes which mapping is not in the app bundle. A reported value
6212
+ * outside the published options reads as `undefined` rather than as an unnamed number.
6202
6213
  */
6203
6214
  nightVision: {
6204
6215
  param: CAMERA_CMD.NIGHT_VISION_TYPE,
@@ -14187,7 +14198,7 @@ var Device = class _Device {
14187
14198
  const spec = this.specByName.get(name);
14188
14199
  if (!spec)
14189
14200
  continue;
14190
- const value = spec.raw ? void 0 : narrow(spec.type, (n) => this.state.get(n), name);
14201
+ const value = spec.raw ? void 0 : narrow(spec.type, (n) => this.state.get(n), name, spec.kind === "enum" ? spec.enumValues : void 0);
14191
14202
  out.push(value === void 0 ? { property: name } : { property: name, value });
14192
14203
  }
14193
14204
  return out;