@mega-yfue/eufy-sdk 0.5.0-beta.42 → 0.5.0-beta.44

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.
@@ -297,6 +297,8 @@ export declare class EufyMega extends EventEmitter {
297
297
  * manager's own log, since by then nothing is waiting to receive it.
298
298
  */
299
299
  private recycleStandaloneSession;
300
+ /** Reopen a wired station that {@link recycleStandaloneSession} closed, while the generation that warmed it is current. */
301
+ private reopenWiredStation;
300
302
  /**
301
303
  * Whether the DECODED property now reads what the write asked for.
302
304
  *
package/dist/index.js CHANGED
@@ -7891,6 +7891,10 @@ var ARMING_MEMBERS = {
7891
7891
  };
7892
7892
  }, "Turn the push notification of the device on a channel on or off in a guard mode (home/away).", (ctx) => ctx.model === "T8010")
7893
7893
  };
7894
+ function decodeAlarmPhase(signal) {
7895
+ const type = signal.source === "push" ? signal.payload?.["type"] : void 0;
7896
+ return type === CusPushAlarmType.HUB_STOP_BY_APP ? { phase: "stopped" } : {};
7897
+ }
7894
7898
  var ARMING = {
7895
7899
  capability: "arming",
7896
7900
  description: "Station/device guard (arming) mode.",
@@ -7905,8 +7909,9 @@ var ARMING = {
7905
7909
  * generic `CusPushEvent` channel, so these ids are shared with other families and resolve by
7906
7910
  * capability (see the barrel's event index).
7907
7911
  *
7908
- * The alarm ids carry a static `phase` so one event name covers the whole lifecycle, the same shape
7909
- * `battery` uses for its threshold pushes. The mode-switch push is known to identify WHICH mode and
7912
+ * The alarm ids carry a `phase` so one event name covers the whole lifecycle: the countdown push a
7913
+ * static `"delayed"`, the alarm push a `"triggered"` or `"stopped"` read from its alarm type (see
7914
+ * {@link decodeAlarmPhase}). The mode-switch push is known to identify WHICH mode and
7910
7915
  * what triggered the change, but neither has been observed on the wire here, so this emits the bare
7911
7916
  * transition and refreshes the `mode` read rather than trusting a decoded field.
7912
7917
  */
@@ -7917,7 +7922,13 @@ var ARMING = {
7917
7922
  emit: "armingModeChanged",
7918
7923
  refresh: { member: "mode" }
7919
7924
  },
7920
- { source: "push", match: CusPushEvent.ALARM, emit: "alarm", payload: { phase: "triggered" } },
7925
+ {
7926
+ source: "push",
7927
+ match: CusPushEvent.ALARM,
7928
+ emit: "alarm",
7929
+ payload: { phase: "triggered" },
7930
+ derive: decodeAlarmPhase
7931
+ },
7921
7932
  { source: "push", match: CusPushEvent.ALARM_DELAY, emit: "alarm", payload: { phase: "delayed" } }
7922
7933
  ]
7923
7934
  };
@@ -28069,10 +28080,24 @@ var EufyMega = class extends EventEmitter13 {
28069
28080
  recycleStandaloneSession(sn) {
28070
28081
  const releaseWrite = new Promise((resolve) => void setTimeout(resolve, SESSION_RECYCLE_WAIT_MS).unref?.());
28071
28082
  return Promise.race([
28072
- this.p2p.resetStandaloneSession(sn),
28083
+ this.p2p.resetStandaloneSession(sn).finally(() => this.reopenWiredStation(sn)),
28073
28084
  releaseWrite.then(() => this.opts.logger?.debug(`[session ${sn}] recycle still waiting on an attached viewer \u2014 releasing the write that asked for it`))
28074
28085
  ]);
28075
28086
  }
28087
+ /** Reopen a wired station that {@link recycleStandaloneSession} closed, while the generation that warmed it is current. */
28088
+ reopenWiredStation(sn) {
28089
+ const generation = this.realtimeGeneration;
28090
+ if (generation?.epoch !== this.realtimeEpoch)
28091
+ return;
28092
+ if (this.p2p.stationKeyOf(sn) !== sn || !this.registry.p2pDevices().some((d) => d.sn === sn))
28093
+ return;
28094
+ if (this.stationPower(sn) !== "wired")
28095
+ return;
28096
+ void this.p2p.ensureStation(sn, generation.abort.signal).catch((error) => {
28097
+ if (!generation.abort.signal.aborted)
28098
+ this.reportError(error);
28099
+ });
28100
+ }
28076
28101
  /**
28077
28102
  * Whether the DECODED property now reads what the write asked for.
28078
28103
  *