@mega-yfue/eufy-sdk 0.5.0-beta.53 → 0.5.0-beta.54
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/client/eufy-mega.d.ts +3 -3
- package/dist/core/contracts.d.ts +1 -1
- package/dist/index.js +10 -46
- package/dist/index.js.map +3 -3
- package/dist/transport/tuya/dp-codec.d.ts +2 -23
- package/package.json +1 -1
|
@@ -792,9 +792,9 @@ export declare class EufyMega extends EventEmitter {
|
|
|
792
792
|
* Subscribe the devices on one credential scope; a failing subscribe is reported, not fatal (one
|
|
793
793
|
* unreachable device must not stop the rest of the roster from coming up).
|
|
794
794
|
*
|
|
795
|
-
* A Tuya clean-line device
|
|
796
|
-
*
|
|
797
|
-
*
|
|
795
|
+
* A Tuya clean-line device (`eufy_home_tuya`) is not subscribed: its state lives on the Tuya cloud,
|
|
796
|
+
* and the broker refuses its `eufy_home` topics on every credential. Its DPs are read from the Tuya
|
|
797
|
+
* cloud instead.
|
|
798
798
|
*/
|
|
799
799
|
private subscribeMqttDevices;
|
|
800
800
|
/**
|
package/dist/core/contracts.d.ts
CHANGED
|
@@ -458,7 +458,7 @@ export interface CommandSink {
|
|
|
458
458
|
dispatch(cmd: Command): Promise<void>;
|
|
459
459
|
}
|
|
460
460
|
/**
|
|
461
|
-
* Inbound Tuya DP event contract — the transport parses
|
|
461
|
+
* Inbound Tuya DP event contract — the transport parses the Tuya cloud DP read
|
|
462
462
|
* (string-keyed object → numeric-keyed record) and delivers it through this interface. The
|
|
463
463
|
* transport owns the parse; a capability owns the semantics (which DP id means what). Mirrors
|
|
464
464
|
* {@link DpInboundFrame} for the AIoT MQTT path; the capability layer never names the Tuya framing.
|
package/dist/index.js
CHANGED
|
@@ -25743,33 +25743,6 @@ function parseTuyaDpEvent(payload) {
|
|
|
25743
25743
|
}
|
|
25744
25744
|
return Object.keys(result).length > 0 ? result : null;
|
|
25745
25745
|
}
|
|
25746
|
-
function parseTuyaDpReport(raw) {
|
|
25747
|
-
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
25748
|
-
return void 0;
|
|
25749
|
-
const envelope = raw;
|
|
25750
|
-
const payloadObj = jsonObject(envelope.payload);
|
|
25751
|
-
if (payloadObj) {
|
|
25752
|
-
const data2 = payloadObj.data;
|
|
25753
|
-
if (data2 && typeof data2 === "object" && !Array.isArray(data2)) {
|
|
25754
|
-
const dataObj = data2;
|
|
25755
|
-
const dps = dataObj.dps;
|
|
25756
|
-
if (dps && typeof dps === "object" && !Array.isArray(dps))
|
|
25757
|
-
return dps;
|
|
25758
|
-
const filtered = Object.fromEntries(Object.entries(dataObj).filter(([k]) => /^[1-9]\d*$/.test(k)));
|
|
25759
|
-
return Object.keys(filtered).length > 0 ? filtered : void 0;
|
|
25760
|
-
}
|
|
25761
|
-
}
|
|
25762
|
-
const topDps = envelope.dps;
|
|
25763
|
-
if (topDps && typeof topDps === "object" && !Array.isArray(topDps))
|
|
25764
|
-
return topDps;
|
|
25765
|
-
const data = envelope.data;
|
|
25766
|
-
if (data && typeof data === "object" && !Array.isArray(data)) {
|
|
25767
|
-
const dataDps = data.dps;
|
|
25768
|
-
if (dataDps && typeof dataDps === "object" && !Array.isArray(dataDps))
|
|
25769
|
-
return dataDps;
|
|
25770
|
-
}
|
|
25771
|
-
return void 0;
|
|
25772
|
-
}
|
|
25773
25746
|
var TuyaDpRouter = class {
|
|
25774
25747
|
listener;
|
|
25775
25748
|
/** Register the inbound listener. Replaces any previously registered one. */
|
|
@@ -29329,16 +29302,6 @@ var EufyMega = class extends EventEmitter13 {
|
|
|
29329
29302
|
transport.on("disconnect", (r) => this.emit("disconnect", r));
|
|
29330
29303
|
transport.on("message", (m) => {
|
|
29331
29304
|
this.emit("message", m);
|
|
29332
|
-
if (m.deviceSn) {
|
|
29333
|
-
const dev = this.registry.list().find((d) => d.sn === m.deviceSn);
|
|
29334
|
-
if (dev?.category === "eufy_home_tuya") {
|
|
29335
|
-
const dps = parseTuyaDpReport(m.raw);
|
|
29336
|
-
if (dps) {
|
|
29337
|
-
this.tuyaDpRouter.deliver(m.deviceSn, dps);
|
|
29338
|
-
return;
|
|
29339
|
-
}
|
|
29340
|
-
}
|
|
29341
|
-
}
|
|
29342
29305
|
if (m.deviceSn) {
|
|
29343
29306
|
const frame = parseBizMapFrame(m.raw);
|
|
29344
29307
|
if (frame) {
|
|
@@ -29372,23 +29335,24 @@ var EufyMega = class extends EventEmitter13 {
|
|
|
29372
29335
|
* Subscribe the devices on one credential scope; a failing subscribe is reported, not fatal (one
|
|
29373
29336
|
* unreachable device must not stop the rest of the roster from coming up).
|
|
29374
29337
|
*
|
|
29375
|
-
* A Tuya clean-line device
|
|
29376
|
-
*
|
|
29377
|
-
*
|
|
29338
|
+
* A Tuya clean-line device (`eufy_home_tuya`) is not subscribed: its state lives on the Tuya cloud,
|
|
29339
|
+
* and the broker refuses its `eufy_home` topics on every credential. Its DPs are read from the Tuya
|
|
29340
|
+
* cloud instead.
|
|
29378
29341
|
*/
|
|
29379
29342
|
async subscribeMqttDevices(scope, transport) {
|
|
29380
29343
|
for (const d of this.getMqttDevices().filter((dev) => mqttScopeFor(dev) === scope)) {
|
|
29381
|
-
try {
|
|
29382
|
-
await transport.subscribeDevice(d);
|
|
29383
|
-
await this.sendRealtimeInit(d.sn);
|
|
29384
|
-
} catch (e) {
|
|
29385
|
-
this.reportError(e);
|
|
29386
|
-
}
|
|
29387
29344
|
if (d.category === "eufy_home_tuya") {
|
|
29388
29345
|
this.tuya.fetchDps(d.sn).then((dps) => {
|
|
29389
29346
|
if (dps)
|
|
29390
29347
|
this.tuyaDpRouter.deliver(d.sn, dps);
|
|
29391
29348
|
}).catch((e) => this.reportError(e));
|
|
29349
|
+
continue;
|
|
29350
|
+
}
|
|
29351
|
+
try {
|
|
29352
|
+
await transport.subscribeDevice(d);
|
|
29353
|
+
await this.sendRealtimeInit(d.sn);
|
|
29354
|
+
} catch (e) {
|
|
29355
|
+
this.reportError(e);
|
|
29392
29356
|
}
|
|
29393
29357
|
}
|
|
29394
29358
|
}
|