@camstack/addon-provider-tuya 0.2.97 → 0.2.98
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/addon.js +151 -22
- package/dist/addon.mjs +151 -22
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -8123,6 +8123,23 @@ function errMsg(err) {
|
|
|
8123
8123
|
if (typeof err === "string") return err;
|
|
8124
8124
|
return String(err);
|
|
8125
8125
|
}
|
|
8126
|
+
new Set([
|
|
8127
|
+
"track",
|
|
8128
|
+
"summary",
|
|
8129
|
+
"face",
|
|
8130
|
+
"identity",
|
|
8131
|
+
"plate",
|
|
8132
|
+
"vehicle",
|
|
8133
|
+
"scene",
|
|
8134
|
+
"motion",
|
|
8135
|
+
"object",
|
|
8136
|
+
"audio"
|
|
8137
|
+
]);
|
|
8138
|
+
new Set([
|
|
8139
|
+
"motion",
|
|
8140
|
+
"object",
|
|
8141
|
+
"audio"
|
|
8142
|
+
]);
|
|
8126
8143
|
var EncodeProfileSchema = object({
|
|
8127
8144
|
video: object({
|
|
8128
8145
|
codec: _enum([
|
|
@@ -13323,8 +13340,17 @@ method(object({
|
|
|
13323
13340
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
13324
13341
|
namespace: string().optional(),
|
|
13325
13342
|
collection: string(),
|
|
13326
|
-
record:
|
|
13327
|
-
|
|
13343
|
+
record: object({
|
|
13344
|
+
id: string().optional(),
|
|
13345
|
+
data: record(string(), unknown())
|
|
13346
|
+
})
|
|
13347
|
+
}), object({
|
|
13348
|
+
/**
|
|
13349
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
13350
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
13351
|
+
* primary key — which is the only place an auto key is knowable.
|
|
13352
|
+
*/
|
|
13353
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
13328
13354
|
namespace: string().optional(),
|
|
13329
13355
|
collection: string(),
|
|
13330
13356
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -13433,8 +13459,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
13433
13459
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
13434
13460
|
namespace: string().optional(),
|
|
13435
13461
|
collection: string(),
|
|
13436
|
-
record:
|
|
13437
|
-
|
|
13462
|
+
record: object({
|
|
13463
|
+
id: string().optional(),
|
|
13464
|
+
data: record(string(), unknown())
|
|
13465
|
+
})
|
|
13466
|
+
}), object({
|
|
13467
|
+
/**
|
|
13468
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
13469
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
13470
|
+
* primary key — which is the only place an auto key is knowable.
|
|
13471
|
+
*/
|
|
13472
|
+
id: union([string(), number()]) }), {
|
|
13438
13473
|
kind: "mutation",
|
|
13439
13474
|
auth: "admin"
|
|
13440
13475
|
}), method(object({
|
|
@@ -20359,7 +20394,20 @@ var TrackSchema = object({
|
|
|
20359
20394
|
...TrackRetrainFields
|
|
20360
20395
|
});
|
|
20361
20396
|
var BaseEventFields = {
|
|
20362
|
-
|
|
20397
|
+
/**
|
|
20398
|
+
* A SQLite ROWID, assigned by the database (D474).
|
|
20399
|
+
*
|
|
20400
|
+
* Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
|
|
20401
|
+
* TWICE per row, in the row and in the primary-key index, across 2.1 million
|
|
20402
|
+
* motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
|
|
20403
|
+
* the rowid: the table itself is that B-tree, so the index stops existing
|
|
20404
|
+
* rather than getting smaller. No shorter string does that.
|
|
20405
|
+
*
|
|
20406
|
+
* Defined once here for all three event kinds, which is why they move
|
|
20407
|
+
* together: a per-table migration would have forked this and
|
|
20408
|
+
* `COMMON_BASE_COLUMNS` and reunited them two stages later.
|
|
20409
|
+
*/
|
|
20410
|
+
id: number().int(),
|
|
20363
20411
|
deviceId: number(),
|
|
20364
20412
|
timestamp: number()
|
|
20365
20413
|
};
|
|
@@ -20378,7 +20426,34 @@ var MotionEventSchema = object({
|
|
|
20378
20426
|
/** Omitted in slim projection. */
|
|
20379
20427
|
frameHeight: number().optional(),
|
|
20380
20428
|
/** Populated by B5 (recording playback URL for this event). */
|
|
20381
|
-
mediaUrl: string().optional()
|
|
20429
|
+
mediaUrl: string().optional(),
|
|
20430
|
+
/**
|
|
20431
|
+
* One row per motion EPISODE, not one per push (D475). `null` while the
|
|
20432
|
+
* episode is still open — a further rising edge extends it in place rather
|
|
20433
|
+
* than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
|
|
20434
|
+
* (the span from the first rising edge to the LAST one, deliberately NOT
|
|
20435
|
+
* `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
|
|
20436
|
+
* movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
|
|
20437
|
+
* motion for an instantaneous trigger).
|
|
20438
|
+
*
|
|
20439
|
+
* **Absent** (not merely `null`) on a row written before D475 — that means
|
|
20440
|
+
* "closed the old way, before this column existed", never "still open".
|
|
20441
|
+
* Nothing in this codebase may read an absent `durationMs` as an open
|
|
20442
|
+
* episode; only `null` means open.
|
|
20443
|
+
*/
|
|
20444
|
+
durationMs: number().nullable().optional(),
|
|
20445
|
+
/**
|
|
20446
|
+
* Ms offsets from `timestamp` (the episode's own first rising edge, so the
|
|
20447
|
+
* first entry is always `0`) of every genuine off→on transition the
|
|
20448
|
+
* episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
|
|
20449
|
+
* push: a firmware source that keepalives at ~1 Hz for the whole burst
|
|
20450
|
+
* (Reolink, Hikvision) produces exactly one edge; a source that reports an
|
|
20451
|
+
* explicit `false` mid-episode and then resumes before the quiet window
|
|
20452
|
+
* elapses produces another. Stored compactly — see `motion-edge-codec.ts`
|
|
20453
|
+
* — and decoded back to this shape on read. Absent/empty on a legacy row,
|
|
20454
|
+
* which must never be read as "no episode happened here".
|
|
20455
|
+
*/
|
|
20456
|
+
edges: array(number()).readonly().optional()
|
|
20382
20457
|
});
|
|
20383
20458
|
/**
|
|
20384
20459
|
* Which detection SOURCE produced an object event. `pipeline` = the ML
|
|
@@ -20433,6 +20508,23 @@ var ObjectEventSchema = object({
|
|
|
20433
20508
|
* includes it (it is light). Absent on rows written before this field.
|
|
20434
20509
|
*/
|
|
20435
20510
|
frameId: string().optional(),
|
|
20511
|
+
/**
|
|
20512
|
+
* A PRODUCER-chosen key that makes a synthetic event's emission idempotent
|
|
20513
|
+
* (D474).
|
|
20514
|
+
*
|
|
20515
|
+
* Only the package detector writes it, and it exists because the event id
|
|
20516
|
+
* stopped being choosable: the delivery and pick-up rows used to BE their
|
|
20517
|
+
* dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
|
|
20518
|
+
* second delivery for this entry" survived a restart. An `INTEGER` rowid is
|
|
20519
|
+
* assigned by SQLite, so that key had to move off the primary key rather
|
|
20520
|
+
* than be dropped — a detector that cannot recognise its own row re-delivers
|
|
20521
|
+
* every parcel on every boot.
|
|
20522
|
+
*
|
|
20523
|
+
* Absent on every other object event, and on every row written before this
|
|
20524
|
+
* field. Never a substitute for `id`: it is unique per (producer, occasion),
|
|
20525
|
+
* not per row, and nothing addresses a row by it.
|
|
20526
|
+
*/
|
|
20527
|
+
idempotencyKey: string().optional(),
|
|
20436
20528
|
/** Omitted in slim projection. */
|
|
20437
20529
|
trackId: string().optional(),
|
|
20438
20530
|
className: string(),
|
|
@@ -28690,26 +28782,59 @@ authKey: string().optional() }), object({
|
|
|
28690
28782
|
/** Human-readable error when `ok: false`. */
|
|
28691
28783
|
error: string().optional()
|
|
28692
28784
|
}), { kind: "mutation" });
|
|
28693
|
-
/**
|
|
28694
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
28695
|
-
* a timestamp of the last observation. Distinct from
|
|
28696
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
28697
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
28698
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
28699
|
-
*
|
|
28700
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
28701
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
28702
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
28703
|
-
* motion from every camera.
|
|
28704
|
-
*/
|
|
28705
28785
|
var MotionStatusSchema = object({
|
|
28706
28786
|
detected: boolean(),
|
|
28707
28787
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
28708
28788
|
lastDetectedAt: number().nullable(),
|
|
28709
28789
|
/**
|
|
28710
|
-
*
|
|
28711
|
-
*
|
|
28712
|
-
*
|
|
28790
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
28791
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
28792
|
+
* constant's doc for the one-authority rule.
|
|
28793
|
+
*
|
|
28794
|
+
* ## Reading this field still arms nothing
|
|
28795
|
+
*
|
|
28796
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
28797
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
28798
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
28799
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
28800
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
28801
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
28802
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
28803
|
+
* field would add a second falling-edge authority beside whichever one
|
|
28804
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
28805
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
28806
|
+
* a flapping source — debounce on their own side and say so, as
|
|
28807
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
28808
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
28809
|
+
*
|
|
28810
|
+
* ## Who writes it
|
|
28811
|
+
*
|
|
28812
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
28813
|
+
* `cooldown_expired`, which then writes this slice with
|
|
28814
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
28815
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
28816
|
+
* matters most for the sources that only ever push a rising one:
|
|
28817
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
28818
|
+
* a false.
|
|
28819
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
28820
|
+
* provider pushes the false itself, from the upstream system's own
|
|
28821
|
+
* state change. No phase machine is involved.
|
|
28822
|
+
*
|
|
28823
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
28824
|
+
*
|
|
28825
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
28826
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
28827
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
28828
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28829
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28830
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28831
|
+
* two authorities can disagree about one slice, which this repo
|
|
28832
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28833
|
+
* nothing, because it reads as verification.
|
|
28834
|
+
*
|
|
28835
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28836
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28837
|
+
* "sole writer" wording without also removing the other writers.
|
|
28713
28838
|
*/
|
|
28714
28839
|
autoClearAfterMs: number().nullable()
|
|
28715
28840
|
});
|
|
@@ -28779,7 +28904,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
28779
28904
|
*/
|
|
28780
28905
|
runtimeState: MotionStatusSchema,
|
|
28781
28906
|
/**
|
|
28782
|
-
* Runtime-state durability: **session** —
|
|
28907
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28908
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28909
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28910
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28911
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
28783
28912
|
*
|
|
28784
28913
|
* See `RuntimeStateDurability`. Enforced by
|
|
28785
28914
|
* `scripts/check-runtime-state-durability.ts`.
|
package/dist/addon.mjs
CHANGED
|
@@ -8122,6 +8122,23 @@ function errMsg(err) {
|
|
|
8122
8122
|
if (typeof err === "string") return err;
|
|
8123
8123
|
return String(err);
|
|
8124
8124
|
}
|
|
8125
|
+
new Set([
|
|
8126
|
+
"track",
|
|
8127
|
+
"summary",
|
|
8128
|
+
"face",
|
|
8129
|
+
"identity",
|
|
8130
|
+
"plate",
|
|
8131
|
+
"vehicle",
|
|
8132
|
+
"scene",
|
|
8133
|
+
"motion",
|
|
8134
|
+
"object",
|
|
8135
|
+
"audio"
|
|
8136
|
+
]);
|
|
8137
|
+
new Set([
|
|
8138
|
+
"motion",
|
|
8139
|
+
"object",
|
|
8140
|
+
"audio"
|
|
8141
|
+
]);
|
|
8125
8142
|
var EncodeProfileSchema = object({
|
|
8126
8143
|
video: object({
|
|
8127
8144
|
codec: _enum([
|
|
@@ -13322,8 +13339,17 @@ method(object({
|
|
|
13322
13339
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
13323
13340
|
namespace: string().optional(),
|
|
13324
13341
|
collection: string(),
|
|
13325
|
-
record:
|
|
13326
|
-
|
|
13342
|
+
record: object({
|
|
13343
|
+
id: string().optional(),
|
|
13344
|
+
data: record(string(), unknown())
|
|
13345
|
+
})
|
|
13346
|
+
}), object({
|
|
13347
|
+
/**
|
|
13348
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
13349
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
13350
|
+
* primary key — which is the only place an auto key is knowable.
|
|
13351
|
+
*/
|
|
13352
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
13327
13353
|
namespace: string().optional(),
|
|
13328
13354
|
collection: string(),
|
|
13329
13355
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -13432,8 +13458,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
13432
13458
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
13433
13459
|
namespace: string().optional(),
|
|
13434
13460
|
collection: string(),
|
|
13435
|
-
record:
|
|
13436
|
-
|
|
13461
|
+
record: object({
|
|
13462
|
+
id: string().optional(),
|
|
13463
|
+
data: record(string(), unknown())
|
|
13464
|
+
})
|
|
13465
|
+
}), object({
|
|
13466
|
+
/**
|
|
13467
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
13468
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
13469
|
+
* primary key — which is the only place an auto key is knowable.
|
|
13470
|
+
*/
|
|
13471
|
+
id: union([string(), number()]) }), {
|
|
13437
13472
|
kind: "mutation",
|
|
13438
13473
|
auth: "admin"
|
|
13439
13474
|
}), method(object({
|
|
@@ -20358,7 +20393,20 @@ var TrackSchema = object({
|
|
|
20358
20393
|
...TrackRetrainFields
|
|
20359
20394
|
});
|
|
20360
20395
|
var BaseEventFields = {
|
|
20361
|
-
|
|
20396
|
+
/**
|
|
20397
|
+
* A SQLite ROWID, assigned by the database (D474).
|
|
20398
|
+
*
|
|
20399
|
+
* Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
|
|
20400
|
+
* TWICE per row, in the row and in the primary-key index, across 2.1 million
|
|
20401
|
+
* motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
|
|
20402
|
+
* the rowid: the table itself is that B-tree, so the index stops existing
|
|
20403
|
+
* rather than getting smaller. No shorter string does that.
|
|
20404
|
+
*
|
|
20405
|
+
* Defined once here for all three event kinds, which is why they move
|
|
20406
|
+
* together: a per-table migration would have forked this and
|
|
20407
|
+
* `COMMON_BASE_COLUMNS` and reunited them two stages later.
|
|
20408
|
+
*/
|
|
20409
|
+
id: number().int(),
|
|
20362
20410
|
deviceId: number(),
|
|
20363
20411
|
timestamp: number()
|
|
20364
20412
|
};
|
|
@@ -20377,7 +20425,34 @@ var MotionEventSchema = object({
|
|
|
20377
20425
|
/** Omitted in slim projection. */
|
|
20378
20426
|
frameHeight: number().optional(),
|
|
20379
20427
|
/** Populated by B5 (recording playback URL for this event). */
|
|
20380
|
-
mediaUrl: string().optional()
|
|
20428
|
+
mediaUrl: string().optional(),
|
|
20429
|
+
/**
|
|
20430
|
+
* One row per motion EPISODE, not one per push (D475). `null` while the
|
|
20431
|
+
* episode is still open — a further rising edge extends it in place rather
|
|
20432
|
+
* than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
|
|
20433
|
+
* (the span from the first rising edge to the LAST one, deliberately NOT
|
|
20434
|
+
* `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
|
|
20435
|
+
* movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
|
|
20436
|
+
* motion for an instantaneous trigger).
|
|
20437
|
+
*
|
|
20438
|
+
* **Absent** (not merely `null`) on a row written before D475 — that means
|
|
20439
|
+
* "closed the old way, before this column existed", never "still open".
|
|
20440
|
+
* Nothing in this codebase may read an absent `durationMs` as an open
|
|
20441
|
+
* episode; only `null` means open.
|
|
20442
|
+
*/
|
|
20443
|
+
durationMs: number().nullable().optional(),
|
|
20444
|
+
/**
|
|
20445
|
+
* Ms offsets from `timestamp` (the episode's own first rising edge, so the
|
|
20446
|
+
* first entry is always `0`) of every genuine off→on transition the
|
|
20447
|
+
* episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
|
|
20448
|
+
* push: a firmware source that keepalives at ~1 Hz for the whole burst
|
|
20449
|
+
* (Reolink, Hikvision) produces exactly one edge; a source that reports an
|
|
20450
|
+
* explicit `false` mid-episode and then resumes before the quiet window
|
|
20451
|
+
* elapses produces another. Stored compactly — see `motion-edge-codec.ts`
|
|
20452
|
+
* — and decoded back to this shape on read. Absent/empty on a legacy row,
|
|
20453
|
+
* which must never be read as "no episode happened here".
|
|
20454
|
+
*/
|
|
20455
|
+
edges: array(number()).readonly().optional()
|
|
20381
20456
|
});
|
|
20382
20457
|
/**
|
|
20383
20458
|
* Which detection SOURCE produced an object event. `pipeline` = the ML
|
|
@@ -20432,6 +20507,23 @@ var ObjectEventSchema = object({
|
|
|
20432
20507
|
* includes it (it is light). Absent on rows written before this field.
|
|
20433
20508
|
*/
|
|
20434
20509
|
frameId: string().optional(),
|
|
20510
|
+
/**
|
|
20511
|
+
* A PRODUCER-chosen key that makes a synthetic event's emission idempotent
|
|
20512
|
+
* (D474).
|
|
20513
|
+
*
|
|
20514
|
+
* Only the package detector writes it, and it exists because the event id
|
|
20515
|
+
* stopped being choosable: the delivery and pick-up rows used to BE their
|
|
20516
|
+
* dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
|
|
20517
|
+
* second delivery for this entry" survived a restart. An `INTEGER` rowid is
|
|
20518
|
+
* assigned by SQLite, so that key had to move off the primary key rather
|
|
20519
|
+
* than be dropped — a detector that cannot recognise its own row re-delivers
|
|
20520
|
+
* every parcel on every boot.
|
|
20521
|
+
*
|
|
20522
|
+
* Absent on every other object event, and on every row written before this
|
|
20523
|
+
* field. Never a substitute for `id`: it is unique per (producer, occasion),
|
|
20524
|
+
* not per row, and nothing addresses a row by it.
|
|
20525
|
+
*/
|
|
20526
|
+
idempotencyKey: string().optional(),
|
|
20435
20527
|
/** Omitted in slim projection. */
|
|
20436
20528
|
trackId: string().optional(),
|
|
20437
20529
|
className: string(),
|
|
@@ -28689,26 +28781,59 @@ authKey: string().optional() }), object({
|
|
|
28689
28781
|
/** Human-readable error when `ok: false`. */
|
|
28690
28782
|
error: string().optional()
|
|
28691
28783
|
}), { kind: "mutation" });
|
|
28692
|
-
/**
|
|
28693
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
28694
|
-
* a timestamp of the last observation. Distinct from
|
|
28695
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
28696
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
28697
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
28698
|
-
*
|
|
28699
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
28700
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
28701
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
28702
|
-
* motion from every camera.
|
|
28703
|
-
*/
|
|
28704
28784
|
var MotionStatusSchema = object({
|
|
28705
28785
|
detected: boolean(),
|
|
28706
28786
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
28707
28787
|
lastDetectedAt: number().nullable(),
|
|
28708
28788
|
/**
|
|
28709
|
-
*
|
|
28710
|
-
*
|
|
28711
|
-
*
|
|
28789
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
28790
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
28791
|
+
* constant's doc for the one-authority rule.
|
|
28792
|
+
*
|
|
28793
|
+
* ## Reading this field still arms nothing
|
|
28794
|
+
*
|
|
28795
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
28796
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
28797
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
28798
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
28799
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
28800
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
28801
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
28802
|
+
* field would add a second falling-edge authority beside whichever one
|
|
28803
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
28804
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
28805
|
+
* a flapping source — debounce on their own side and say so, as
|
|
28806
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
28807
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
28808
|
+
*
|
|
28809
|
+
* ## Who writes it
|
|
28810
|
+
*
|
|
28811
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
28812
|
+
* `cooldown_expired`, which then writes this slice with
|
|
28813
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
28814
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
28815
|
+
* matters most for the sources that only ever push a rising one:
|
|
28816
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
28817
|
+
* a false.
|
|
28818
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
28819
|
+
* provider pushes the false itself, from the upstream system's own
|
|
28820
|
+
* state change. No phase machine is involved.
|
|
28821
|
+
*
|
|
28822
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
28823
|
+
*
|
|
28824
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
28825
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
28826
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
28827
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28828
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28829
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28830
|
+
* two authorities can disagree about one slice, which this repo
|
|
28831
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28832
|
+
* nothing, because it reads as verification.
|
|
28833
|
+
*
|
|
28834
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28835
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28836
|
+
* "sole writer" wording without also removing the other writers.
|
|
28712
28837
|
*/
|
|
28713
28838
|
autoClearAfterMs: number().nullable()
|
|
28714
28839
|
});
|
|
@@ -28778,7 +28903,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
28778
28903
|
*/
|
|
28779
28904
|
runtimeState: MotionStatusSchema,
|
|
28780
28905
|
/**
|
|
28781
|
-
* Runtime-state durability: **session** —
|
|
28906
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28907
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28908
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28909
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28910
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
28782
28911
|
*
|
|
28783
28912
|
* See `RuntimeStateDurability`. Enforced by
|
|
28784
28913
|
* `scripts/check-runtime-state-durability.ts`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-tuya",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.98",
|
|
4
4
|
"description": "Tuya / Smart Life device-provider addon for CamStack — account-onboarded (Tuya IoT cloud fetch of device localKeys) + LOCAL DP control via the @apocaliss92/nodetuya encrypted-LAN client, exposing switch / water-heater-family kettle entities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|