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

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.
@@ -344,6 +344,8 @@ export type Command = {
344
344
  cmd: number;
345
345
  value: number;
346
346
  channel: number;
347
+ /** `"auto"`: the seal follows the session, level-2 with a key and level-1 without. Absent, level-2 only. */
348
+ form?: Extract<ScalarForm, "auto">;
347
349
  }
348
350
  /** P2P int-plus-string frame; the transport injects the authenticated account id string. */
349
351
  | {
package/dist/index.js CHANGED
@@ -3304,8 +3304,8 @@ function setJsonRaw(cmd, data, ctx, channel) {
3304
3304
  function setPayload(cmd, payload, ctx, mValue3, channel, form) {
3305
3305
  return { kind: "set-payload", cmd, payload, channel: channel ?? ctx.channel, mValue3, form };
3306
3306
  }
3307
- function setStationScalar(cmd, value, channel) {
3308
- return { kind: "p2p-station-scalar", cmd, value, channel };
3307
+ function setStationScalar(cmd, value, channel, form) {
3308
+ return { kind: "p2p-station-scalar", cmd, value, channel, ...form ? { form } : {} };
3309
3309
  }
3310
3310
  function describeDevice(ctx) {
3311
3311
  return `deviceType=${ctx.deviceType ?? "?"} model=${ctx.model ?? "?"} serial=${ctx.serial ?? "?"} channel=${ctx.channel} codec=${ctx.codec}`;
@@ -7970,7 +7970,8 @@ var ARMING_CMD = {
7970
7970
  * was captured on holds a level-2 key and seals it level-2, while an own-session camera that never
7971
7971
  * negotiates one carries the same envelope level-1. See `armingCommand`.
7972
7972
  *
7973
- * A T8410C takes the mode as a direct frame instead of this envelope; see {@link DIRECT_ARMING_MODELS}.
7973
+ * A T8410C and a T8410 take the mode as a direct frame instead of this envelope; see
7974
+ * {@link DIRECT_ARMING_MODELS} and {@link BROADCAST_ARMING_MODELS}.
7974
7975
  */
7975
7976
  SET_ARMING: 1224,
7976
7977
  /**
@@ -8010,7 +8011,7 @@ var ARMING_CMD = {
8010
8011
  var DEVICE_NOTIFY_FLAG = 8;
8011
8012
  var STANDALONE_ACTION_MODELS = /* @__PURE__ */ new Set(["T8170", "T8171"]);
8012
8013
  var DIRECT_ARMING_MODELS = /* @__PURE__ */ new Set(["T8410C"]);
8013
- var DIRECT_ARMING_MODES = /* @__PURE__ */ new Set(["away", "home", "disarmed"]);
8014
+ var BROADCAST_ARMING_MODELS = /* @__PURE__ */ new Set(["T8410"]);
8014
8015
  var STANDALONE_READ_MODELS = /* @__PURE__ */ new Set([...STANDALONE_ACTION_MODELS, "T8400", "T8442", "T8410"]);
8015
8016
  function ownAction(read, mode) {
8016
8017
  const value = Number(read(`${mode}Action`)?.value);
@@ -8043,10 +8044,11 @@ function armingCommand(mode, ctx) {
8043
8044
  if (!ctx.accountName) {
8044
8045
  throw new Error(`arming: missing account identity (user_name) [${describeDevice(ctx)}]`);
8045
8046
  }
8046
- if (DIRECT_ARMING_MODELS.has(ctx.model ?? "")) {
8047
- if (!DIRECT_ARMING_MODES.has(mode)) {
8048
- throw new Error(`arming: mode ${mode} is unconfirmed on the direct 1224 frame [${describeDevice(ctx)}]`);
8049
- }
8047
+ const model = ctx.model ?? "";
8048
+ if (BROADCAST_ARMING_MODELS.has(model)) {
8049
+ return setStationScalar(ARMING_CMD.SET_ARMING, ARMING_MODE_WIRE[mode], STATION_CHANNEL2, "auto");
8050
+ }
8051
+ if (DIRECT_ARMING_MODELS.has(model)) {
8050
8052
  return setStationScalar(ARMING_CMD.SET_ARMING, ARMING_MODE_WIRE[mode], ctx.channel);
8051
8053
  }
8052
8054
  return setPayload(ARMING_CMD.SET_ARMING, { mode_type: ARMING_MODE_WIRE[mode], user_name: ctx.accountName }, ctx, 0, void 0, "auto");
@@ -8104,7 +8106,7 @@ var ARMING_MEMBERS = {
8104
8106
  kind: "enum",
8105
8107
  enumValues: ARMING_MODE_LABELS,
8106
8108
  provenance: "verified",
8107
- description: "Guard mode (verified: param 1224 = GUARD_MODE, read/write mechanism confirmed). Reads and SETS all 9 modes the app defines \u2014 away/home/schedule/custom1/custom2/custom3/off/geo/disarmed. Three are byte-captured writes and six are live-confirmed (each sent and observed to report its own MODE_SWITCH); see ARMING_MODE_WIRE in arming.ts for the per-value evidence. On a T8410C only away, home and disarmed are writable.",
8109
+ description: "Guard mode (verified: param 1224 = GUARD_MODE, read/write mechanism confirmed). Reads and SETS all 9 modes the app defines \u2014 away/home/schedule/custom1/custom2/custom3/off/geo/disarmed. Three are byte-captured writes and six are live-confirmed (each sent and observed to report its own MODE_SWITCH); see ARMING_MODE_WIRE in arming.ts for the per-value evidence.",
8108
8110
  observation: {
8109
8111
  event: "armingModeChanged",
8110
8112
  reflects: (value) => ({ param: ARMING_CMD.SET_ARMING, expected: ARMING_MODE_WIRE[armingModeOf(value)] }),
@@ -22795,7 +22797,7 @@ var P2PCommandRouter = class _P2PCommandRouter {
22795
22797
  await this.sendSetPayloadEnvelope(sn, cmd.cmd, cmd.payload, cmd.channel, cmd.mValue3, void 0, cmd.form, cmd.level2Sender);
22796
22798
  return;
22797
22799
  case "p2p-station-scalar":
22798
- await this.sendStationScalar(sn, cmd.cmd, cmd.value, cmd.channel);
22800
+ await this.sendStationScalar(sn, cmd.cmd, cmd.value, cmd.channel, cmd.form);
22799
22801
  return;
22800
22802
  case "p2p-int-string":
22801
22803
  await this.sendIntString(sn, cmd.cmd, cmd.value, cmd.valueSub, cmd.channel);
@@ -22837,10 +22839,7 @@ var P2PCommandRouter = class _P2PCommandRouter {
22837
22839
  * control here is.
22838
22840
  */
22839
22841
  async rebootStation(sn) {
22840
- await this.sendBySessionLevel(sn, {
22841
- l2: (resolved) => this.replayLevel2Send(sn, `reboot ${sn}`, ({ session, accountId }) => session.sendRawLevel2Bytes(buildDirectBinaryBody(0, accountId), 255, P2P_ENVELOPE.RESTART_HUB, 8), resolved),
22842
- l1: (resolved) => this.replayLevel2Send(sn, `reboot ${sn}`, ({ session, accountId }) => session.sendRawLevel1Bytes(buildDirectBinaryBody(0, accountId), 255, P2P_ENVELOPE.RESTART_HUB), resolved)
22843
- });
22842
+ return this.sendStationScalar(sn, P2P_ENVELOPE.RESTART_HUB, 0, 255, "auto");
22844
22843
  }
22845
22844
  /**
22846
22845
  * A {@link MediaProvider} bound to one serial — resolves the session then calls `p2p/media`.
@@ -23736,9 +23735,19 @@ var P2PCommandRouter = class _P2PCommandRouter {
23736
23735
  * **Station-scoped scalar** (`p2p-station-scalar` intent): the 132-byte channel-less body
23737
23736
  * ({@link buildDirectBinaryBody} with no `channel`) on an EXPLICIT channel, signCode 8. The
23738
23737
  * HomeBase's own controls ride the station broadcast channel 255 (alarm/speaker volume 1235).
23738
+ *
23739
+ * `form` `"auto"` seals it at the session's level, as {@link sendBySessionLevel} defines it: level-2 on a
23740
+ * keyed session, the same body sealed level-1 on a keyless one. Absent, the send waits for the level-2 key.
23739
23741
  */
23740
- async sendStationScalar(sn, outerCmd, value, channel) {
23741
- await this.replayLevel2Send(sn, `station scalar cmd ${outerCmd}`, ({ session, accountId }) => session.sendRawLevel2Bytes(buildDirectBinaryBody(value, accountId), channel, outerCmd, 8));
23742
+ async sendStationScalar(sn, outerCmd, value, channel, form) {
23743
+ const describe2 = `station scalar cmd ${outerCmd}`;
23744
+ const l2 = (resolved) => this.replayLevel2Send(sn, describe2, ({ session, accountId }) => session.sendRawLevel2Bytes(buildDirectBinaryBody(value, accountId), channel, outerCmd, 8), resolved);
23745
+ if (form !== "auto")
23746
+ return l2();
23747
+ await this.sendBySessionLevel(sn, {
23748
+ l2,
23749
+ l1: (resolved) => this.replayLevel2Send(sn, describe2, ({ session, accountId }) => session.sendRawLevel1Bytes(buildDirectBinaryBody(value, accountId), channel, outerCmd), resolved)
23750
+ });
23742
23751
  }
23743
23752
  /** Send a level-1 int-plus-string frame with authenticated account identity injected by the transport. */
23744
23753
  async sendIntString(sn, commandType, value, valueSub, channel) {
@@ -28872,6 +28881,7 @@ var StoredImageCache = class {
28872
28881
  this.logger.warn("[stored-snapshot-cache] candidate failed", {
28873
28882
  class: failure,
28874
28883
  ...mediaFailureTag(error),
28884
+ ...error instanceof Error && !mediaFailureTag(error).cause ? { errorName: error.name } : {},
28875
28885
  observedAt: candidate.observedAt,
28876
28886
  retained: state.retained !== void 0
28877
28887
  });