@camstack/addon-provider-homeassistant 1.2.113 → 1.2.114
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 +3 -3
- package/dist/addon.mjs +3 -3
- package/dist/{dist-DU9rYiaM.js → dist-1-owndOS.js} +151 -24
- package/dist/{dist-65xKnX_d.mjs → dist-BPuEMYlM.mjs} +151 -24
- package/dist/ha-export/ha-export.addon.js +1 -1
- package/dist/ha-export/ha-export.addon.mjs +1 -1
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_dist = require("./dist-
|
|
2
|
+
const require_dist = require("./dist-1-owndOS.js");
|
|
3
3
|
let node_crypto = require("node:crypto");
|
|
4
4
|
let node_zlib = require("node:zlib");
|
|
5
5
|
//#region src/ha-device-source.ts
|
|
@@ -923,7 +923,7 @@ var HaBinarySensorDevice = class extends HaBaseChildDevice {
|
|
|
923
923
|
getStatus: async () => this.readSlice({
|
|
924
924
|
detected: false,
|
|
925
925
|
lastDetectedAt: null,
|
|
926
|
-
autoClearAfterMs:
|
|
926
|
+
autoClearAfterMs: null
|
|
927
927
|
}),
|
|
928
928
|
isDetected: async () => {
|
|
929
929
|
return this.runtimeState.getCapState("motion")?.detected === true;
|
|
@@ -977,7 +977,7 @@ function buildSlice(capName, active, lastChangedAt) {
|
|
|
977
977
|
case "motion": return {
|
|
978
978
|
detected: active,
|
|
979
979
|
lastDetectedAt: active ? lastChangedAt : null,
|
|
980
|
-
autoClearAfterMs:
|
|
980
|
+
autoClearAfterMs: null
|
|
981
981
|
};
|
|
982
982
|
}
|
|
983
983
|
}
|
package/dist/addon.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as presenceCapability, A as controlCapability, At as EventCategory, B as humiditySensorCapability, C as buildAddonRouteProvider, Ct as number, D as colorCapability, Dt as union, E as climateControlCapability, Et as string, F as eventEmitterCapability, G as motionCapability, H as lawnMowerControlCapability, I as fanControlCapability, J as notifierCapability, K as normalizeUnit, L as floodCapability, M as deviceAdoptionCapability, O as connectivityCapability, Ot as unknown, P as enumSensorCapability, Q as prepareNotification, R as gasCapability, S as brokerCapability, St as literal, T as carbonMonoxideCapability, Tt as record, U as lockControlCapability, V as imageCapability, W as mediaPlayerCapability, Y as numericSensorCapability, Z as powerMeterCapability, _ as automationControlCapability, _t as createEvent, at as temperatureSensorCapability, b as binaryCapability, bt as array, ct as valveCapability, d as TargetSchema, dt as weatherCapability, et as pressureSensorCapability, f as accessoriesCapability, ft as errMsg, g as ambientLightSensorCapability, gt as DeviceType, h as alarmPanelCapability, ht as DeviceRole, it as tamperCapability, j as coverCapability, k as contactCapability, kt as url, lt as vibrationCapability, m as airQualitySensorCapability, mt as DeviceFeature, n as BaseDevice, nt as smokeCapability, ot as updateCapability, p as addonRoutesCapability, q as notificationOutputCapability, r as BaseDeviceProvider, rt as switchCapability, s as EnumSensorDateTimeFormatSchema, st as vacuumControlCapability, tt as scriptRunnerCapability, ut as waterHeaterCapability, v as batteryCapability, w as buttonCapability, wt as object, x as brightnessCapability, xt as discriminatedUnion, y as bestLocationMatch, yt as _enum, z as humidifierCapability } from "./dist-
|
|
1
|
+
import { $ as presenceCapability, A as controlCapability, At as EventCategory, B as humiditySensorCapability, C as buildAddonRouteProvider, Ct as number, D as colorCapability, Dt as union, E as climateControlCapability, Et as string, F as eventEmitterCapability, G as motionCapability, H as lawnMowerControlCapability, I as fanControlCapability, J as notifierCapability, K as normalizeUnit, L as floodCapability, M as deviceAdoptionCapability, O as connectivityCapability, Ot as unknown, P as enumSensorCapability, Q as prepareNotification, R as gasCapability, S as brokerCapability, St as literal, T as carbonMonoxideCapability, Tt as record, U as lockControlCapability, V as imageCapability, W as mediaPlayerCapability, Y as numericSensorCapability, Z as powerMeterCapability, _ as automationControlCapability, _t as createEvent, at as temperatureSensorCapability, b as binaryCapability, bt as array, ct as valveCapability, d as TargetSchema, dt as weatherCapability, et as pressureSensorCapability, f as accessoriesCapability, ft as errMsg, g as ambientLightSensorCapability, gt as DeviceType, h as alarmPanelCapability, ht as DeviceRole, it as tamperCapability, j as coverCapability, k as contactCapability, kt as url, lt as vibrationCapability, m as airQualitySensorCapability, mt as DeviceFeature, n as BaseDevice, nt as smokeCapability, ot as updateCapability, p as addonRoutesCapability, q as notificationOutputCapability, r as BaseDeviceProvider, rt as switchCapability, s as EnumSensorDateTimeFormatSchema, st as vacuumControlCapability, tt as scriptRunnerCapability, ut as waterHeaterCapability, v as batteryCapability, w as buttonCapability, wt as object, x as brightnessCapability, xt as discriminatedUnion, y as bestLocationMatch, yt as _enum, z as humidifierCapability } from "./dist-BPuEMYlM.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { brotliCompressSync, deflateSync, gzipSync } from "node:zlib";
|
|
4
4
|
//#region src/ha-device-source.ts
|
|
@@ -922,7 +922,7 @@ var HaBinarySensorDevice = class extends HaBaseChildDevice {
|
|
|
922
922
|
getStatus: async () => this.readSlice({
|
|
923
923
|
detected: false,
|
|
924
924
|
lastDetectedAt: null,
|
|
925
|
-
autoClearAfterMs:
|
|
925
|
+
autoClearAfterMs: null
|
|
926
926
|
}),
|
|
927
927
|
isDetected: async () => {
|
|
928
928
|
return this.runtimeState.getCapState("motion")?.detected === true;
|
|
@@ -976,7 +976,7 @@ function buildSlice(capName, active, lastChangedAt) {
|
|
|
976
976
|
case "motion": return {
|
|
977
977
|
detected: active,
|
|
978
978
|
lastDetectedAt: active ? lastChangedAt : null,
|
|
979
|
-
autoClearAfterMs:
|
|
979
|
+
autoClearAfterMs: null
|
|
980
980
|
};
|
|
981
981
|
}
|
|
982
982
|
}
|
|
@@ -7361,8 +7361,23 @@ function errMsg(err) {
|
|
|
7361
7361
|
if (typeof err === "string") return err;
|
|
7362
7362
|
return String(err);
|
|
7363
7363
|
}
|
|
7364
|
-
|
|
7365
|
-
|
|
7364
|
+
new Set([
|
|
7365
|
+
"track",
|
|
7366
|
+
"summary",
|
|
7367
|
+
"face",
|
|
7368
|
+
"identity",
|
|
7369
|
+
"plate",
|
|
7370
|
+
"vehicle",
|
|
7371
|
+
"scene",
|
|
7372
|
+
"motion",
|
|
7373
|
+
"object",
|
|
7374
|
+
"audio"
|
|
7375
|
+
]);
|
|
7376
|
+
new Set([
|
|
7377
|
+
"motion",
|
|
7378
|
+
"object",
|
|
7379
|
+
"audio"
|
|
7380
|
+
]);
|
|
7366
7381
|
/**
|
|
7367
7382
|
* Build an `IAddonRouteProvider` from a list of routes. Implements
|
|
7368
7383
|
* both the operator-facing `getRoutes` (returning route descriptors
|
|
@@ -12774,8 +12789,17 @@ method(object({
|
|
|
12774
12789
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
12775
12790
|
namespace: string().optional(),
|
|
12776
12791
|
collection: string(),
|
|
12777
|
-
record:
|
|
12778
|
-
|
|
12792
|
+
record: object({
|
|
12793
|
+
id: string().optional(),
|
|
12794
|
+
data: record(string(), unknown())
|
|
12795
|
+
})
|
|
12796
|
+
}), object({
|
|
12797
|
+
/**
|
|
12798
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12799
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12800
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12801
|
+
*/
|
|
12802
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
12779
12803
|
namespace: string().optional(),
|
|
12780
12804
|
collection: string(),
|
|
12781
12805
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -12884,8 +12908,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
12884
12908
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
12885
12909
|
namespace: string().optional(),
|
|
12886
12910
|
collection: string(),
|
|
12887
|
-
record:
|
|
12888
|
-
|
|
12911
|
+
record: object({
|
|
12912
|
+
id: string().optional(),
|
|
12913
|
+
data: record(string(), unknown())
|
|
12914
|
+
})
|
|
12915
|
+
}), object({
|
|
12916
|
+
/**
|
|
12917
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12918
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12919
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12920
|
+
*/
|
|
12921
|
+
id: union([string(), number()]) }), {
|
|
12889
12922
|
kind: "mutation",
|
|
12890
12923
|
auth: "admin"
|
|
12891
12924
|
}), method(object({
|
|
@@ -19910,7 +19943,20 @@ var TrackSchema = object({
|
|
|
19910
19943
|
...TrackRetrainFields
|
|
19911
19944
|
});
|
|
19912
19945
|
var BaseEventFields = {
|
|
19913
|
-
|
|
19946
|
+
/**
|
|
19947
|
+
* A SQLite ROWID, assigned by the database (D474).
|
|
19948
|
+
*
|
|
19949
|
+
* Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
|
|
19950
|
+
* TWICE per row, in the row and in the primary-key index, across 2.1 million
|
|
19951
|
+
* motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
|
|
19952
|
+
* the rowid: the table itself is that B-tree, so the index stops existing
|
|
19953
|
+
* rather than getting smaller. No shorter string does that.
|
|
19954
|
+
*
|
|
19955
|
+
* Defined once here for all three event kinds, which is why they move
|
|
19956
|
+
* together: a per-table migration would have forked this and
|
|
19957
|
+
* `COMMON_BASE_COLUMNS` and reunited them two stages later.
|
|
19958
|
+
*/
|
|
19959
|
+
id: number().int(),
|
|
19914
19960
|
deviceId: number(),
|
|
19915
19961
|
timestamp: number()
|
|
19916
19962
|
};
|
|
@@ -19929,7 +19975,34 @@ var MotionEventSchema = object({
|
|
|
19929
19975
|
/** Omitted in slim projection. */
|
|
19930
19976
|
frameHeight: number().optional(),
|
|
19931
19977
|
/** Populated by B5 (recording playback URL for this event). */
|
|
19932
|
-
mediaUrl: string().optional()
|
|
19978
|
+
mediaUrl: string().optional(),
|
|
19979
|
+
/**
|
|
19980
|
+
* One row per motion EPISODE, not one per push (D475). `null` while the
|
|
19981
|
+
* episode is still open — a further rising edge extends it in place rather
|
|
19982
|
+
* than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
|
|
19983
|
+
* (the span from the first rising edge to the LAST one, deliberately NOT
|
|
19984
|
+
* `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
|
|
19985
|
+
* movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
|
|
19986
|
+
* motion for an instantaneous trigger).
|
|
19987
|
+
*
|
|
19988
|
+
* **Absent** (not merely `null`) on a row written before D475 — that means
|
|
19989
|
+
* "closed the old way, before this column existed", never "still open".
|
|
19990
|
+
* Nothing in this codebase may read an absent `durationMs` as an open
|
|
19991
|
+
* episode; only `null` means open.
|
|
19992
|
+
*/
|
|
19993
|
+
durationMs: number().nullable().optional(),
|
|
19994
|
+
/**
|
|
19995
|
+
* Ms offsets from `timestamp` (the episode's own first rising edge, so the
|
|
19996
|
+
* first entry is always `0`) of every genuine off→on transition the
|
|
19997
|
+
* episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
|
|
19998
|
+
* push: a firmware source that keepalives at ~1 Hz for the whole burst
|
|
19999
|
+
* (Reolink, Hikvision) produces exactly one edge; a source that reports an
|
|
20000
|
+
* explicit `false` mid-episode and then resumes before the quiet window
|
|
20001
|
+
* elapses produces another. Stored compactly — see `motion-edge-codec.ts`
|
|
20002
|
+
* — and decoded back to this shape on read. Absent/empty on a legacy row,
|
|
20003
|
+
* which must never be read as "no episode happened here".
|
|
20004
|
+
*/
|
|
20005
|
+
edges: array(number()).readonly().optional()
|
|
19933
20006
|
});
|
|
19934
20007
|
/**
|
|
19935
20008
|
* Which detection SOURCE produced an object event. `pipeline` = the ML
|
|
@@ -19984,6 +20057,23 @@ var ObjectEventSchema = object({
|
|
|
19984
20057
|
* includes it (it is light). Absent on rows written before this field.
|
|
19985
20058
|
*/
|
|
19986
20059
|
frameId: string().optional(),
|
|
20060
|
+
/**
|
|
20061
|
+
* A PRODUCER-chosen key that makes a synthetic event's emission idempotent
|
|
20062
|
+
* (D474).
|
|
20063
|
+
*
|
|
20064
|
+
* Only the package detector writes it, and it exists because the event id
|
|
20065
|
+
* stopped being choosable: the delivery and pick-up rows used to BE their
|
|
20066
|
+
* dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
|
|
20067
|
+
* second delivery for this entry" survived a restart. An `INTEGER` rowid is
|
|
20068
|
+
* assigned by SQLite, so that key had to move off the primary key rather
|
|
20069
|
+
* than be dropped — a detector that cannot recognise its own row re-delivers
|
|
20070
|
+
* every parcel on every boot.
|
|
20071
|
+
*
|
|
20072
|
+
* Absent on every other object event, and on every row written before this
|
|
20073
|
+
* field. Never a substitute for `id`: it is unique per (producer, occasion),
|
|
20074
|
+
* not per row, and nothing addresses a row by it.
|
|
20075
|
+
*/
|
|
20076
|
+
idempotencyKey: string().optional(),
|
|
19987
20077
|
/** Omitted in slim projection. */
|
|
19988
20078
|
trackId: string().optional(),
|
|
19989
20079
|
className: string(),
|
|
@@ -28322,26 +28412,59 @@ authKey: string().optional() }), object({
|
|
|
28322
28412
|
/** Human-readable error when `ok: false`. */
|
|
28323
28413
|
error: string().optional()
|
|
28324
28414
|
}), { kind: "mutation" });
|
|
28325
|
-
/**
|
|
28326
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
28327
|
-
* a timestamp of the last observation. Distinct from
|
|
28328
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
28329
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
28330
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
28331
|
-
*
|
|
28332
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
28333
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
28334
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
28335
|
-
* motion from every camera.
|
|
28336
|
-
*/
|
|
28337
28415
|
var MotionStatusSchema = object({
|
|
28338
28416
|
detected: boolean(),
|
|
28339
28417
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
28340
28418
|
lastDetectedAt: number().nullable(),
|
|
28341
28419
|
/**
|
|
28342
|
-
*
|
|
28343
|
-
*
|
|
28344
|
-
*
|
|
28420
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
28421
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
28422
|
+
* constant's doc for the one-authority rule.
|
|
28423
|
+
*
|
|
28424
|
+
* ## Reading this field still arms nothing
|
|
28425
|
+
*
|
|
28426
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
28427
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
28428
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
28429
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
28430
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
28431
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
28432
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
28433
|
+
* field would add a second falling-edge authority beside whichever one
|
|
28434
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
28435
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
28436
|
+
* a flapping source — debounce on their own side and say so, as
|
|
28437
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
28438
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
28439
|
+
*
|
|
28440
|
+
* ## Who writes it
|
|
28441
|
+
*
|
|
28442
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
28443
|
+
* `cooldown_expired`, which then writes this slice with
|
|
28444
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
28445
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
28446
|
+
* matters most for the sources that only ever push a rising one:
|
|
28447
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
28448
|
+
* a false.
|
|
28449
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
28450
|
+
* provider pushes the false itself, from the upstream system's own
|
|
28451
|
+
* state change. No phase machine is involved.
|
|
28452
|
+
*
|
|
28453
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
28454
|
+
*
|
|
28455
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
28456
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
28457
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
28458
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28459
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28460
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28461
|
+
* two authorities can disagree about one slice, which this repo
|
|
28462
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28463
|
+
* nothing, because it reads as verification.
|
|
28464
|
+
*
|
|
28465
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28466
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28467
|
+
* "sole writer" wording without also removing the other writers.
|
|
28345
28468
|
*/
|
|
28346
28469
|
autoClearAfterMs: number().nullable()
|
|
28347
28470
|
});
|
|
@@ -28411,7 +28534,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
28411
28534
|
*/
|
|
28412
28535
|
runtimeState: MotionStatusSchema,
|
|
28413
28536
|
/**
|
|
28414
|
-
* Runtime-state durability: **session** —
|
|
28537
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28538
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28539
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28540
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28541
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
28415
28542
|
*
|
|
28416
28543
|
* See `RuntimeStateDurability`. Enforced by
|
|
28417
28544
|
* `scripts/check-runtime-state-durability.ts`.
|
|
@@ -7361,8 +7361,23 @@ function errMsg(err) {
|
|
|
7361
7361
|
if (typeof err === "string") return err;
|
|
7362
7362
|
return String(err);
|
|
7363
7363
|
}
|
|
7364
|
-
|
|
7365
|
-
|
|
7364
|
+
new Set([
|
|
7365
|
+
"track",
|
|
7366
|
+
"summary",
|
|
7367
|
+
"face",
|
|
7368
|
+
"identity",
|
|
7369
|
+
"plate",
|
|
7370
|
+
"vehicle",
|
|
7371
|
+
"scene",
|
|
7372
|
+
"motion",
|
|
7373
|
+
"object",
|
|
7374
|
+
"audio"
|
|
7375
|
+
]);
|
|
7376
|
+
new Set([
|
|
7377
|
+
"motion",
|
|
7378
|
+
"object",
|
|
7379
|
+
"audio"
|
|
7380
|
+
]);
|
|
7366
7381
|
/**
|
|
7367
7382
|
* Build an `IAddonRouteProvider` from a list of routes. Implements
|
|
7368
7383
|
* both the operator-facing `getRoutes` (returning route descriptors
|
|
@@ -12774,8 +12789,17 @@ method(object({
|
|
|
12774
12789
|
}), array(SettingsRecordSchema).readonly()), method(object({
|
|
12775
12790
|
namespace: string().optional(),
|
|
12776
12791
|
collection: string(),
|
|
12777
|
-
record:
|
|
12778
|
-
|
|
12792
|
+
record: object({
|
|
12793
|
+
id: string().optional(),
|
|
12794
|
+
data: record(string(), unknown())
|
|
12795
|
+
})
|
|
12796
|
+
}), object({
|
|
12797
|
+
/**
|
|
12798
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12799
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12800
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12801
|
+
*/
|
|
12802
|
+
id: union([string(), number()]) }), { kind: "mutation" }), method(object({
|
|
12779
12803
|
namespace: string().optional(),
|
|
12780
12804
|
collection: string(),
|
|
12781
12805
|
records: array(BulkRecordSchema).readonly()
|
|
@@ -12884,8 +12908,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
12884
12908
|
}), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
|
|
12885
12909
|
namespace: string().optional(),
|
|
12886
12910
|
collection: string(),
|
|
12887
|
-
record:
|
|
12888
|
-
|
|
12911
|
+
record: object({
|
|
12912
|
+
id: string().optional(),
|
|
12913
|
+
data: record(string(), unknown())
|
|
12914
|
+
})
|
|
12915
|
+
}), object({
|
|
12916
|
+
/**
|
|
12917
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
12918
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
12919
|
+
* primary key — which is the only place an auto key is knowable.
|
|
12920
|
+
*/
|
|
12921
|
+
id: union([string(), number()]) }), {
|
|
12889
12922
|
kind: "mutation",
|
|
12890
12923
|
auth: "admin"
|
|
12891
12924
|
}), method(object({
|
|
@@ -19910,7 +19943,20 @@ var TrackSchema = object({
|
|
|
19910
19943
|
...TrackRetrainFields
|
|
19911
19944
|
});
|
|
19912
19945
|
var BaseEventFields = {
|
|
19913
|
-
|
|
19946
|
+
/**
|
|
19947
|
+
* A SQLite ROWID, assigned by the database (D474).
|
|
19948
|
+
*
|
|
19949
|
+
* Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
|
|
19950
|
+
* TWICE per row, in the row and in the primary-key index, across 2.1 million
|
|
19951
|
+
* motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
|
|
19952
|
+
* the rowid: the table itself is that B-tree, so the index stops existing
|
|
19953
|
+
* rather than getting smaller. No shorter string does that.
|
|
19954
|
+
*
|
|
19955
|
+
* Defined once here for all three event kinds, which is why they move
|
|
19956
|
+
* together: a per-table migration would have forked this and
|
|
19957
|
+
* `COMMON_BASE_COLUMNS` and reunited them two stages later.
|
|
19958
|
+
*/
|
|
19959
|
+
id: number().int(),
|
|
19914
19960
|
deviceId: number(),
|
|
19915
19961
|
timestamp: number()
|
|
19916
19962
|
};
|
|
@@ -19929,7 +19975,34 @@ var MotionEventSchema = object({
|
|
|
19929
19975
|
/** Omitted in slim projection. */
|
|
19930
19976
|
frameHeight: number().optional(),
|
|
19931
19977
|
/** Populated by B5 (recording playback URL for this event). */
|
|
19932
|
-
mediaUrl: string().optional()
|
|
19978
|
+
mediaUrl: string().optional(),
|
|
19979
|
+
/**
|
|
19980
|
+
* One row per motion EPISODE, not one per push (D475). `null` while the
|
|
19981
|
+
* episode is still open — a further rising edge extends it in place rather
|
|
19982
|
+
* than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
|
|
19983
|
+
* (the span from the first rising edge to the LAST one, deliberately NOT
|
|
19984
|
+
* `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
|
|
19985
|
+
* movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
|
|
19986
|
+
* motion for an instantaneous trigger).
|
|
19987
|
+
*
|
|
19988
|
+
* **Absent** (not merely `null`) on a row written before D475 — that means
|
|
19989
|
+
* "closed the old way, before this column existed", never "still open".
|
|
19990
|
+
* Nothing in this codebase may read an absent `durationMs` as an open
|
|
19991
|
+
* episode; only `null` means open.
|
|
19992
|
+
*/
|
|
19993
|
+
durationMs: number().nullable().optional(),
|
|
19994
|
+
/**
|
|
19995
|
+
* Ms offsets from `timestamp` (the episode's own first rising edge, so the
|
|
19996
|
+
* first entry is always `0`) of every genuine off→on transition the
|
|
19997
|
+
* episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
|
|
19998
|
+
* push: a firmware source that keepalives at ~1 Hz for the whole burst
|
|
19999
|
+
* (Reolink, Hikvision) produces exactly one edge; a source that reports an
|
|
20000
|
+
* explicit `false` mid-episode and then resumes before the quiet window
|
|
20001
|
+
* elapses produces another. Stored compactly — see `motion-edge-codec.ts`
|
|
20002
|
+
* — and decoded back to this shape on read. Absent/empty on a legacy row,
|
|
20003
|
+
* which must never be read as "no episode happened here".
|
|
20004
|
+
*/
|
|
20005
|
+
edges: array(number()).readonly().optional()
|
|
19933
20006
|
});
|
|
19934
20007
|
/**
|
|
19935
20008
|
* Which detection SOURCE produced an object event. `pipeline` = the ML
|
|
@@ -19984,6 +20057,23 @@ var ObjectEventSchema = object({
|
|
|
19984
20057
|
* includes it (it is light). Absent on rows written before this field.
|
|
19985
20058
|
*/
|
|
19986
20059
|
frameId: string().optional(),
|
|
20060
|
+
/**
|
|
20061
|
+
* A PRODUCER-chosen key that makes a synthetic event's emission idempotent
|
|
20062
|
+
* (D474).
|
|
20063
|
+
*
|
|
20064
|
+
* Only the package detector writes it, and it exists because the event id
|
|
20065
|
+
* stopped being choosable: the delivery and pick-up rows used to BE their
|
|
20066
|
+
* dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
|
|
20067
|
+
* second delivery for this entry" survived a restart. An `INTEGER` rowid is
|
|
20068
|
+
* assigned by SQLite, so that key had to move off the primary key rather
|
|
20069
|
+
* than be dropped — a detector that cannot recognise its own row re-delivers
|
|
20070
|
+
* every parcel on every boot.
|
|
20071
|
+
*
|
|
20072
|
+
* Absent on every other object event, and on every row written before this
|
|
20073
|
+
* field. Never a substitute for `id`: it is unique per (producer, occasion),
|
|
20074
|
+
* not per row, and nothing addresses a row by it.
|
|
20075
|
+
*/
|
|
20076
|
+
idempotencyKey: string().optional(),
|
|
19987
20077
|
/** Omitted in slim projection. */
|
|
19988
20078
|
trackId: string().optional(),
|
|
19989
20079
|
className: string(),
|
|
@@ -28322,26 +28412,59 @@ authKey: string().optional() }), object({
|
|
|
28322
28412
|
/** Human-readable error when `ok: false`. */
|
|
28323
28413
|
error: string().optional()
|
|
28324
28414
|
}), { kind: "mutation" });
|
|
28325
|
-
/**
|
|
28326
|
-
* Hardware / firmware motion sensor cap — binary detected state plus
|
|
28327
|
-
* a timestamp of the last observation. Distinct from
|
|
28328
|
-
* `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
|
|
28329
|
-
* `motion` is the lightweight readout from on-camera motion (Reolink
|
|
28330
|
-
* `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
|
|
28331
|
-
*
|
|
28332
|
-
* Native-motion providers also fan out to `detection.camera-native`
|
|
28333
|
-
* with `source: 'onboard'` so cross-cutting system services
|
|
28334
|
-
* (alert-center, advanced-notifier) can subscribe once and receive
|
|
28335
|
-
* motion from every camera.
|
|
28336
|
-
*/
|
|
28337
28415
|
var MotionStatusSchema = object({
|
|
28338
28416
|
detected: boolean(),
|
|
28339
28417
|
/** Ms epoch of the last detected-true observation. Null if never detected. */
|
|
28340
28418
|
lastDetectedAt: number().nullable(),
|
|
28341
28419
|
/**
|
|
28342
|
-
*
|
|
28343
|
-
*
|
|
28344
|
-
*
|
|
28420
|
+
* `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
|
|
28421
|
+
* `null` while false and on every `Sensor` device (D475) — see that
|
|
28422
|
+
* constant's doc for the one-authority rule.
|
|
28423
|
+
*
|
|
28424
|
+
* ## Reading this field still arms nothing
|
|
28425
|
+
*
|
|
28426
|
+
* It reads like an instruction to the consumer ("revert after N ms if
|
|
28427
|
+
* no fresh push arrives") and it is not one: nothing in this repo reads
|
|
28428
|
+
* the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
|
|
28429
|
+
* close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
|
|
28430
|
+
* imported constant, not as a read of `device.state.motion.value`, so this
|
|
28431
|
+
* field stays what it always was: DESCRIPTIVE output, mirroring an answer
|
|
28432
|
+
* computed elsewhere. Building a self-clear timer out of a READ of this
|
|
28433
|
+
* field would add a second falling-edge authority beside whichever one
|
|
28434
|
+
* already owns the device, and two that can disagree are worse than one.
|
|
28435
|
+
* Consumers that need a falling edge SHAPED differently — held open across
|
|
28436
|
+
* a flapping source — debounce on their own side and say so, as
|
|
28437
|
+
* `addon-export-alexa/src/motion-clear-hold.ts` and
|
|
28438
|
+
* `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
|
|
28439
|
+
*
|
|
28440
|
+
* ## Who writes it
|
|
28441
|
+
*
|
|
28442
|
+
* - **Cameras** — the runner's phase machine, `active → watching` on
|
|
28443
|
+
* `cooldown_expired`, which then writes this slice with
|
|
28444
|
+
* `detected: false` (`handlePhaseChanged` in
|
|
28445
|
+
* `pipeline-runner/index.ts`). It produces the FALLING edge, which
|
|
28446
|
+
* matters most for the sources that only ever push a rising one:
|
|
28447
|
+
* Reolink emits `MotionOnMotionChanged { detected: true }` and never
|
|
28448
|
+
* a false.
|
|
28449
|
+
* - **Sensors** (Home Assistant binary sensors, Homematic) — the
|
|
28450
|
+
* provider pushes the false itself, from the upstream system's own
|
|
28451
|
+
* state change. No phase machine is involved.
|
|
28452
|
+
*
|
|
28453
|
+
* ### The phase machine is CANONICAL, not sole — and that is a defect
|
|
28454
|
+
*
|
|
28455
|
+
* An earlier revision of this docblock (mine, 2026-09-12) claimed the
|
|
28456
|
+
* phase machine is the sole writer for a camera. It is not.
|
|
28457
|
+
* `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
|
|
28458
|
+
* `setCapSlice(motionCapability, …)` on their own rising edge, and
|
|
28459
|
+
* Hikvision's comment says why: it read THIS docblock, agreed the
|
|
28460
|
+
* runner is canonical, and wrote anyway to avoid per-tick churn. So
|
|
28461
|
+
* two authorities can disagree about one slice, which this repo
|
|
28462
|
+
* forbids, and the doc said otherwise — which is worse than saying
|
|
28463
|
+
* nothing, because it reads as verification.
|
|
28464
|
+
*
|
|
28465
|
+
* This predates D475 and is not fixed there: the fix touches every
|
|
28466
|
+
* camera provider. Recorded in D475's Consequences. Do not restore the
|
|
28467
|
+
* "sole writer" wording without also removing the other writers.
|
|
28345
28468
|
*/
|
|
28346
28469
|
autoClearAfterMs: number().nullable()
|
|
28347
28470
|
});
|
|
@@ -28411,7 +28534,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
|
|
|
28411
28534
|
*/
|
|
28412
28535
|
runtimeState: MotionStatusSchema,
|
|
28413
28536
|
/**
|
|
28414
|
-
* Runtime-state durability: **session** —
|
|
28537
|
+
* Runtime-state durability: **session** — every writer of this slice
|
|
28538
|
+
* writes only on an EDGE, so a restored `detected: true` would stay
|
|
28539
|
+
* frozen until the next one instead of being corrected. The next edge
|
|
28540
|
+
* re-publishes the real state. (On who the writers are, and why there
|
|
28541
|
+
* is more than one, see `autoClearAfterMs` above.)
|
|
28415
28542
|
*
|
|
28416
28543
|
* See `RuntimeStateDurability`. Enforced by
|
|
28417
28544
|
* `scripts/check-runtime-state-durability.ts`.
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
//#endregion
|
|
6
|
-
const require_dist = require("../dist-
|
|
6
|
+
const require_dist = require("../dist-1-owndOS.js");
|
|
7
7
|
let node_crypto = require("node:crypto");
|
|
8
8
|
//#region src/ha-export/topics.ts
|
|
9
9
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { At as EventCategory, C as buildAddonRouteProvider, Et as string, N as deviceExportCapability, X as oauthIntegrationCapability, a as COCO_TO_MACRO, c as FanDirectionSchema, i as CAMERA_SWITCH_ORDER, l as HvacModeSchema, o as CameraSwitchIdSchema, p as addonRoutesCapability, pt as BaseAddon, t as AlarmArmModeSchema, u as MediaPlayerRepeatSchema, vt as nodePin } from "../dist-
|
|
1
|
+
import { At as EventCategory, C as buildAddonRouteProvider, Et as string, N as deviceExportCapability, X as oauthIntegrationCapability, a as COCO_TO_MACRO, c as FanDirectionSchema, i as CAMERA_SWITCH_ORDER, l as HvacModeSchema, o as CameraSwitchIdSchema, p as addonRoutesCapability, pt as BaseAddon, t as AlarmArmModeSchema, u as MediaPlayerRepeatSchema, vt as nodePin } from "../dist-BPuEMYlM.mjs";
|
|
2
2
|
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
3
3
|
//#region src/ha-export/topics.ts
|
|
4
4
|
/**
|