@camstack/addon-export-hap 1.2.112 → 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/hap-export.addon.js +892 -128
- package/dist/hap-export.addon.mjs +892 -128
- package/package.json +1 -1
package/dist/hap-export.addon.js
CHANGED
|
@@ -84,7 +84,7 @@ function carryForward(base, existing, keys) {
|
|
|
84
84
|
return out;
|
|
85
85
|
}
|
|
86
86
|
//#endregion
|
|
87
|
-
//#region ../types/dist/event-category-
|
|
87
|
+
//#region ../types/dist/event-category-BVDXG4tB.mjs
|
|
88
88
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
89
89
|
EventCategory["SystemBoot"] = "system.boot";
|
|
90
90
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -701,6 +701,20 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
701
701
|
* pull-reconcile from the provider's `getStatus` on reconnect. */
|
|
702
702
|
EventCategory["MeshNetworkChanged"] = "network.mesh.changed";
|
|
703
703
|
EventCategory["BackupCompleted"] = "backup.completed";
|
|
704
|
+
/**
|
|
705
|
+
* A whole backup RUN finished — every destination attempted, win or lose.
|
|
706
|
+
*
|
|
707
|
+
* `backup.completed` fires once per DESTINATION, which is the right grain for
|
|
708
|
+
* a progress UI and the wrong one for a notification: an operator with three
|
|
709
|
+
* destinations would be told three times. And a run where two of three
|
|
710
|
+
* destinations succeeded is not a clean success — a single "backup
|
|
711
|
+
* completed" that hid the failed one would be a lie, so the count of each is
|
|
712
|
+
* carried here and the message says both.
|
|
713
|
+
*
|
|
714
|
+
* Emitted by the backup orchestrator only after the destination loop, so a
|
|
715
|
+
* run that dies during the BUILD phase produces no completion at all.
|
|
716
|
+
*/
|
|
717
|
+
EventCategory["BackupRunCompleted"] = "backup.run-completed";
|
|
704
718
|
EventCategory["BackupRestored"] = "backup.restored";
|
|
705
719
|
EventCategory["NotificationDispatched"] = "notification.dispatched";
|
|
706
720
|
EventCategory["NotificationFailed"] = "notification.failed";
|
|
@@ -5431,7 +5445,7 @@ var ZodIssueCode = {
|
|
|
5431
5445
|
var ZodFirstPartyTypeKind;
|
|
5432
5446
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5433
5447
|
//#endregion
|
|
5434
|
-
//#region ../types/dist/sleep-
|
|
5448
|
+
//#region ../types/dist/sleep-DEuj7E3j.mjs
|
|
5435
5449
|
/**
|
|
5436
5450
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5437
5451
|
* window to float samples (D455).
|
|
@@ -7432,7 +7446,7 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
7432
7446
|
input: unknown()
|
|
7433
7447
|
}), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
7434
7448
|
//#endregion
|
|
7435
|
-
//#region ../types/dist/canonical-hash-
|
|
7449
|
+
//#region ../types/dist/canonical-hash-Ch5bSjFG.mjs
|
|
7436
7450
|
var AUDIO_ENCODER_BY_CODEC = {
|
|
7437
7451
|
opus: "libopus",
|
|
7438
7452
|
aac: "aac",
|
|
@@ -7535,6 +7549,7 @@ function buildVideoArgs(video, outputArgs) {
|
|
|
7535
7549
|
];
|
|
7536
7550
|
if (video.preset !== void 0) args.push("-preset", video.preset);
|
|
7537
7551
|
if (video.tune !== void 0) args.push("-tune", video.tune);
|
|
7552
|
+
if (video.singleSlicePerFrame === true && video.encoder === "libx264") args.push("-x264-params", "sliced-threads=0");
|
|
7538
7553
|
if (video.profile !== void 0) args.push("-profile:v", video.profile);
|
|
7539
7554
|
if (video.level !== void 0) args.push("-level", video.level);
|
|
7540
7555
|
if (video.pixelFormat !== void 0) args.push("-pix_fmt", video.pixelFormat);
|
|
@@ -7936,7 +7951,7 @@ import { errMsg } from '@camstack/types'
|
|
|
7936
7951
|
* Extract a human-readable message from an unknown error value.
|
|
7937
7952
|
* Replaces the ubiquitous `errMsg(err)` pattern.
|
|
7938
7953
|
*/
|
|
7939
|
-
function errMsg$
|
|
7954
|
+
function errMsg$16(err) {
|
|
7940
7955
|
if (err instanceof Error) return err.message;
|
|
7941
7956
|
if (typeof err === "string") return err;
|
|
7942
7957
|
return String(err);
|
|
@@ -8013,7 +8028,23 @@ var EncodeProfileSchema = object({
|
|
|
8013
8028
|
"zerolatency",
|
|
8014
8029
|
"film",
|
|
8015
8030
|
"animation"
|
|
8016
|
-
]).optional()
|
|
8031
|
+
]).optional(),
|
|
8032
|
+
/**
|
|
8033
|
+
* ONE slice per access unit.
|
|
8034
|
+
*
|
|
8035
|
+
* `-tune zerolatency` turns on x264's sliced threads, and a frame then leaves
|
|
8036
|
+
* the encoder as five NAL slices that share one RTP timestamp and carry one
|
|
8037
|
+
* marker bit. A libwebrtc depacketiser sees five frame-starts and one
|
|
8038
|
+
* frame-end per frame: the first pictures render and the video then freezes
|
|
8039
|
+
* for good while the audio, on its own plane, plays on. Measured on this hub
|
|
8040
|
+
* 2026-09-13 against the Echo, and reduced to one slice by this flag alone.
|
|
8041
|
+
*
|
|
8042
|
+
* A NAMED field and not a raw flag, because {@link EgressEncodeSchema} omits
|
|
8043
|
+
* `outputArgs` on purpose: an opaque array is part of the sharing key, so two
|
|
8044
|
+
* consumers meaning the same thing spelled differently would stop sharing one
|
|
8045
|
+
* child. Absent means "whatever the encoder does" — today's behaviour.
|
|
8046
|
+
*/
|
|
8047
|
+
singleSlicePerFrame: boolean().optional()
|
|
8017
8048
|
}),
|
|
8018
8049
|
audio: union([literal("passthrough"), object({
|
|
8019
8050
|
codec: _enum([
|
|
@@ -8042,6 +8073,28 @@ var EncodeProfileSchema = object({
|
|
|
8042
8073
|
outputArgs: array(string()).optional()
|
|
8043
8074
|
});
|
|
8044
8075
|
/**
|
|
8076
|
+
* THE target rule: which of two sizes serves a consumer better.
|
|
8077
|
+
*
|
|
8078
|
+
* "Prefer at or above the target so the consumer downscales instead of
|
|
8079
|
+
* upscaling; among those the SMALLEST, because the extra pixels are thrown
|
|
8080
|
+
* away and the decode is not; among the rest the LARGEST, because it is the
|
|
8081
|
+
* closest we can get." One sentence, and until now it was written twice — once
|
|
8082
|
+
* here in lines, once in `stream-selection.ts` in pixels, for the same two
|
|
8083
|
+
* exporters. The two agreed, which is luck, not a property.
|
|
8084
|
+
*
|
|
8085
|
+
* The `size` is whatever measure the caller ranks by: the cap ranks by LINES
|
|
8086
|
+
* (a consumer's requirement is stated in p), the RTSP picker by PIXELS (it
|
|
8087
|
+
* compares entries of possibly different aspect). The rule is the same either
|
|
8088
|
+
* way and the measure is the caller's business.
|
|
8089
|
+
*
|
|
8090
|
+
* Returns a sort delta: negative when `a` should come first.
|
|
8091
|
+
*/
|
|
8092
|
+
function compareToTarget(a, b, target) {
|
|
8093
|
+
const aReaches = a >= target;
|
|
8094
|
+
if (aReaches !== b >= target) return aReaches ? -1 : 1;
|
|
8095
|
+
return aReaches ? a - b : b - a;
|
|
8096
|
+
}
|
|
8097
|
+
/**
|
|
8045
8098
|
* The shape every live egress starts from: H.264 Baseline 3.1 at 720p25.
|
|
8046
8099
|
* Baseline because it is the one profile every consumer in this repo decodes
|
|
8047
8100
|
* (Echo, iOS, an old browser); 3.1 because that is what the SDPs advertise.
|
|
@@ -8063,7 +8116,7 @@ var BASE_LIVE_EGRESS_PROFILE = {
|
|
|
8063
8116
|
audio: "passthrough"
|
|
8064
8117
|
};
|
|
8065
8118
|
({ ...BASE_LIVE_EGRESS_PROFILE }), { ...BASE_LIVE_EGRESS_PROFILE.video };
|
|
8066
|
-
({ ...BASE_LIVE_EGRESS_PROFILE });
|
|
8119
|
+
({ ...BASE_LIVE_EGRESS_PROFILE }), { ...BASE_LIVE_EGRESS_PROFILE.video };
|
|
8067
8120
|
/** VBV window for a consumer whose budget is enforced per second (HomeKit). */
|
|
8068
8121
|
var RATE_CONTROL_TIGHT = {
|
|
8069
8122
|
kind: "cbr",
|
|
@@ -9954,6 +10007,47 @@ var LogChannelWindowSchema = object({
|
|
|
9954
10007
|
/** `null` = every camera. A non-empty list narrows to those numeric ids. */
|
|
9955
10008
|
deviceIds: array(number().int()).readonly().nullable()
|
|
9956
10009
|
});
|
|
10010
|
+
/**
|
|
10011
|
+
* Shared stream-selection picker for export addons.
|
|
10012
|
+
*
|
|
10013
|
+
* Both `addon-export-alexa` and `addon-export-hap` resolve the
|
|
10014
|
+
* operator's `streamPreference` setting against the broker's RTSP
|
|
10015
|
+
* entries before dialling a camera. Each addon used to roll its own:
|
|
10016
|
+
* Alexa had `pickPreferredRtspEntry` under `handlers/`, HAP had an
|
|
10017
|
+
* inline `"prefer /mid, then /high, then first"` chain inside its
|
|
10018
|
+
* camera-streams mapper. The chains drifted (Alexa honoured
|
|
10019
|
+
* `streamPreference`, HAP didn't; only Alexa got the smart
|
|
10020
|
+
* resolution-targeted auto-pick) and the cross-addon import rule
|
|
10021
|
+
* blocks deduping in either direction.
|
|
10022
|
+
*
|
|
10023
|
+
* Lifting the picker into `@camstack/types` lets every exporter call
|
|
10024
|
+
* the same code path with the consumer's target resolution baked into
|
|
10025
|
+
* the call site — Alexa passes 1280×720, HomeKit passes 1920×1080,
|
|
10026
|
+
* the picker handles the rest.
|
|
10027
|
+
*
|
|
10028
|
+
* Selection algorithm:
|
|
10029
|
+
* - pref === '<profile>' → profile-keyed entries (from
|
|
10030
|
+
* `getProfileRtspEntries`) match on `e.profile`;
|
|
10031
|
+
* legacy raw entries match on the brokerId
|
|
10032
|
+
* suffix (`brokerId` ENDS WITH `/${pref}`, shape
|
|
10033
|
+
* `${deviceId}/${camStreamId}`). Addons store the
|
|
10034
|
+
* bare profile/camStream id in their
|
|
10035
|
+
* `ExportDeviceSettings.streamPreference`. Falls
|
|
10036
|
+
* back to 'auto' when no enabled entry matches
|
|
10037
|
+
* either way.
|
|
10038
|
+
* - pref === 'auto' → when `targetResolution` is given, pick the
|
|
10039
|
+
* entry whose source resolution is closest to
|
|
10040
|
+
* it (prefer ≥ target so the consumer
|
|
10041
|
+
* downscales instead of upscaling). Without a
|
|
10042
|
+
* target, fall back to first-enabled. If no
|
|
10043
|
+
* entry advertises a resolution at all
|
|
10044
|
+
* (broker hasn't probed yet), also fall back
|
|
10045
|
+
* to first-enabled so cold start still serves.
|
|
10046
|
+
*
|
|
10047
|
+
* Returns `null` when nothing is publishable — callers fold that into
|
|
10048
|
+
* the consumer's "no stream" error (Alexa: STREAM_TYPE_UNSUPPORTED;
|
|
10049
|
+
* HAP: a thrown error inside `startFfmpegForSession`).
|
|
10050
|
+
*/
|
|
9957
10051
|
function pickPreferredRtspEntry(entries, pref, deviceId, options = {}) {
|
|
9958
10052
|
if (entries.length === 0) return null;
|
|
9959
10053
|
const prefix = `${deviceId}/`;
|
|
@@ -9983,30 +10077,23 @@ function pickPreferredRtspEntry(entries, pref, deviceId, options = {}) {
|
|
|
9983
10077
|
return toPicked(eligible[0]);
|
|
9984
10078
|
}
|
|
9985
10079
|
/**
|
|
9986
|
-
* Pick the entry whose `resolution` is closest to `target
|
|
9987
|
-
*
|
|
9988
|
-
*
|
|
9989
|
-
*
|
|
9990
|
-
*
|
|
10080
|
+
* Pick the entry whose `resolution` is closest to `target`, by the ONE target
|
|
10081
|
+
* rule ({@link compareToTarget}): prefer at or above the target so the consumer
|
|
10082
|
+
* downscales instead of upscaling; among those the smallest; among the rest the
|
|
10083
|
+
* largest.
|
|
10084
|
+
*
|
|
10085
|
+
* This function used to implement that rule itself, in pixels, while
|
|
10086
|
+
* `rankStreams` implemented it again in lines — the same sentence written twice
|
|
10087
|
+
* for the same two exporters, agreeing by luck rather than by construction.
|
|
10088
|
+
* Only the MEASURE is this picker's own: it compares whole pixel counts because
|
|
10089
|
+
* its entries can differ in aspect, where the cap's requirement is stated in p.
|
|
9991
10090
|
*/
|
|
9992
10091
|
function pickClosestResolution(entries, target) {
|
|
9993
10092
|
const targetPixels = target.width * target.height;
|
|
9994
|
-
|
|
9995
|
-
|
|
9996
|
-
|
|
9997
|
-
|
|
9998
|
-
const pixels = e.resolution.width * e.resolution.height;
|
|
9999
|
-
if (pixels >= targetPixels) {
|
|
10000
|
-
if (!bestAbove || pixels < bestAbove.pixels) bestAbove = {
|
|
10001
|
-
entry: e,
|
|
10002
|
-
pixels
|
|
10003
|
-
};
|
|
10004
|
-
} else if (!bestBelow || pixels > bestBelow.pixels) bestBelow = {
|
|
10005
|
-
entry: e,
|
|
10006
|
-
pixels
|
|
10007
|
-
};
|
|
10008
|
-
}
|
|
10009
|
-
return bestAbove?.entry ?? bestBelow?.entry;
|
|
10093
|
+
return [...entries.flatMap((entry) => entry.resolution === void 0 ? [] : [{
|
|
10094
|
+
entry,
|
|
10095
|
+
pixels: entry.resolution.width * entry.resolution.height
|
|
10096
|
+
}])].sort((a, b) => compareToTarget(a.pixels, b.pixels, targetPixels))[0]?.entry;
|
|
10010
10097
|
}
|
|
10011
10098
|
var MODEL_FORMATS = [
|
|
10012
10099
|
"onnx",
|
|
@@ -12194,6 +12281,58 @@ method(ListInputSchema, array(BrokerInfoSchema$1)), method(GetInputSchema, Broke
|
|
|
12194
12281
|
auth: "admin"
|
|
12195
12282
|
}), method(GetStateInputSchema, unknown().nullable()), method(_void(), RegistryStatusSchema);
|
|
12196
12283
|
DeviceType.Camera;
|
|
12284
|
+
/**
|
|
12285
|
+
* The signals a device can emit to WAKE its own stream.
|
|
12286
|
+
*
|
|
12287
|
+
* A camera whose stream is built on demand sleeps until something asks for it,
|
|
12288
|
+
* and "something" cannot be a consumer that is merely attached — a Frigate-style
|
|
12289
|
+
* puller holds a session open for ever, and treating that as demand would keep
|
|
12290
|
+
* a battery camera awake for ever, which is the whole thing the battery is for
|
|
12291
|
+
* (D173). So the wake has to come from the CAMERA: an event it noticed by
|
|
12292
|
+
* itself, with no stream running.
|
|
12293
|
+
*
|
|
12294
|
+
* ## The vocabulary is the PROVIDER'S, not ours
|
|
12295
|
+
*
|
|
12296
|
+
* Like `consumables`, this cap declares no vocabulary of its own. A provider
|
|
12297
|
+
* names each signal with a `code` it chooses and a `label` an operator reads.
|
|
12298
|
+
* Reolink offers motion and camera-native detection; another provider may offer
|
|
12299
|
+
* a tamper, a doorbell press, a PIR, or something no camera in this fleet has
|
|
12300
|
+
* yet. A fixed enum here would mean every new signal is a framework release.
|
|
12301
|
+
*
|
|
12302
|
+
* It is deliberately NOT derived from the caps a device already binds. Whether
|
|
12303
|
+
* a camera CAN push firmware motion is expressed by `motionSources` containing
|
|
12304
|
+
* `'onboard'`, and whether it does AI on-camera by the `native-object-detection`
|
|
12305
|
+
* binding — but both answer "what drives the detection pipeline", which is a
|
|
12306
|
+
* different question from "what may wake a sleeping stream". A camera can do
|
|
12307
|
+
* the first and not be trusted with the second, and the operator picks per
|
|
12308
|
+
* camera. Two questions, two authorities.
|
|
12309
|
+
*
|
|
12310
|
+
* ## Availability is not permission
|
|
12311
|
+
*
|
|
12312
|
+
* `listSignals` says what the device CAN emit. Whether a given signal actually
|
|
12313
|
+
* wakes the stream is the operator's per-camera choice, held by the broker
|
|
12314
|
+
* alongside the cooldown — see the stream-broker cap's wake settings. A
|
|
12315
|
+
* provider declaring a signal is not a provider enabling it.
|
|
12316
|
+
*/
|
|
12317
|
+
/** One signal a device can emit. */
|
|
12318
|
+
var StreamSignalSchema = object({
|
|
12319
|
+
/** Stable id chosen by the provider, e.g. `'motion'`, `'person'`, `'tamper'`. */
|
|
12320
|
+
code: string().min(1),
|
|
12321
|
+
/** What an operator reads in the picker. The provider's own wording. */
|
|
12322
|
+
label: string().min(1),
|
|
12323
|
+
/**
|
|
12324
|
+
* Whether the provider recommends this signal ON when a camera is first set
|
|
12325
|
+
* up. A provider knows which of its signals are cheap and reliable; an
|
|
12326
|
+
* operator should not have to discover that by trial. Reolink recommends
|
|
12327
|
+
* both of its own.
|
|
12328
|
+
*/
|
|
12329
|
+
recommended: boolean()
|
|
12330
|
+
});
|
|
12331
|
+
object({
|
|
12332
|
+
signals: array(StreamSignalSchema),
|
|
12333
|
+
lastFetchedAt: number()
|
|
12334
|
+
});
|
|
12335
|
+
Object.values(DeviceType), method(_void(), array(StreamSignalSchema).readonly());
|
|
12197
12336
|
/** Stream delivery format. (Relocated from the retired `streaming-engine` cap.) */
|
|
12198
12337
|
var StreamFormatSchema = _enum([
|
|
12199
12338
|
"webrtc",
|
|
@@ -12590,6 +12729,22 @@ var EgressTranscodeSchema = object({
|
|
|
12590
12729
|
camStreamId: string().nullable()
|
|
12591
12730
|
});
|
|
12592
12731
|
method(object({
|
|
12732
|
+
deviceId: number().int().nonnegative(),
|
|
12733
|
+
/** The provider's signal code. */
|
|
12734
|
+
code: string().min(1),
|
|
12735
|
+
/** Ms epoch. Absent ⇒ now. */
|
|
12736
|
+
at: number().optional()
|
|
12737
|
+
}), object({
|
|
12738
|
+
/** Whether the broker acted on it, and if not, why. */
|
|
12739
|
+
accepted: boolean(),
|
|
12740
|
+
reason: _enum([
|
|
12741
|
+
"woke",
|
|
12742
|
+
"hold-extended",
|
|
12743
|
+
"not-enabled",
|
|
12744
|
+
"no-consumer",
|
|
12745
|
+
"unknown-code"
|
|
12746
|
+
])
|
|
12747
|
+
}), { kind: "mutation" }), method(object({
|
|
12593
12748
|
deviceId: number().int().nonnegative(),
|
|
12594
12749
|
camStreamId: string().min(1),
|
|
12595
12750
|
kind: CamStreamKindSchema,
|
|
@@ -12844,6 +12999,16 @@ var PickStreamRequirementsSchema = object({
|
|
|
12844
12999
|
acceptCodecs: array(StreamCodecSchema).readonly().optional(),
|
|
12845
13000
|
/** Minimum vertical resolution. Streams shorter than this are dropped. */
|
|
12846
13001
|
minHeight: number().int().positive().optional(),
|
|
13002
|
+
/**
|
|
13003
|
+
* Maximum vertical resolution. Streams TALLER than this are dropped.
|
|
13004
|
+
*
|
|
13005
|
+
* A consumer can have a ceiling as real as its floor: Alexa documents
|
|
13006
|
+
* 480p to 1080p, and a 4K stream is as unusable to an Echo as a 360p one.
|
|
13007
|
+
* Without this the ceiling had to be re-implemented by every caller — and
|
|
13008
|
+
* one caller implementing it privately is how a second scoring authority
|
|
13009
|
+
* gets born.
|
|
13010
|
+
*/
|
|
13011
|
+
maxHeight: number().int().positive().optional(),
|
|
12847
13012
|
/** Minimum horizontal resolution. */
|
|
12848
13013
|
minWidth: number().int().positive().optional(),
|
|
12849
13014
|
/**
|
|
@@ -12860,7 +13025,22 @@ var PickStreamRequirementsSchema = object({
|
|
|
12860
13025
|
* transcoded" guard: if the device is already serving the consumer's
|
|
12861
13026
|
* codec end-to-end, there's nothing to optimise.
|
|
12862
13027
|
*/
|
|
12863
|
-
requireSiblingCodec: array(StreamCodecSchema).readonly().optional()
|
|
13028
|
+
requireSiblingCodec: array(StreamCodecSchema).readonly().optional(),
|
|
13029
|
+
/**
|
|
13030
|
+
* Whether a stream the consumer CANNOT decode may still be picked, on the
|
|
13031
|
+
* understanding that it will be transcoded.
|
|
13032
|
+
*
|
|
13033
|
+
* Default `false` — today's behaviour, and the right one for a bypass
|
|
13034
|
+
* question ("is there a stream I can forward untouched?"). Set `true` to
|
|
13035
|
+
* ask the larger question: "what is the best stream for me, transcoding if
|
|
13036
|
+
* I must?" A stream that satisfies `acceptCodecs` always outranks one that
|
|
13037
|
+
* does not, so a passthrough is never lost to a transcode; the answer says
|
|
13038
|
+
* which it is in {@link PickedCamStreamSchema.transcodes}.
|
|
13039
|
+
*
|
|
13040
|
+
* This is what lets one picker serve both the bypass and the full source
|
|
13041
|
+
* choice, instead of a consumer scoring privately when the bypass misses.
|
|
13042
|
+
*/
|
|
13043
|
+
allowTranscode: boolean().optional()
|
|
12864
13044
|
}).readonly();
|
|
12865
13045
|
var PickStreamPreferencesSchema = object({
|
|
12866
13046
|
/**
|
|
@@ -12874,12 +13054,32 @@ var PickStreamPreferencesSchema = object({
|
|
|
12874
13054
|
* picks the tallest stream; `'lowest'` picks the shortest (used by
|
|
12875
13055
|
* memory-constrained consumers / Apple Home guest sessions).
|
|
12876
13056
|
*/
|
|
12877
|
-
resolutionPreference: _enum(["highest", "lowest"]).optional()
|
|
13057
|
+
resolutionPreference: _enum(["highest", "lowest"]).optional(),
|
|
13058
|
+
/**
|
|
13059
|
+
* The height the consumer actually wants to DELIVER.
|
|
13060
|
+
*
|
|
13061
|
+
* Not a constraint — an ordering. With it set, the SMALLEST stream at or
|
|
13062
|
+
* above the target wins, and only if nothing reaches it does the tallest
|
|
13063
|
+
* take over. Pulling 1296 lines to draw 720 on a 1280x800 Echo panel costs
|
|
13064
|
+
* a decode and buys nothing, and `resolutionPreference: 'highest'` cannot
|
|
13065
|
+
* express that: it says "as big as possible", which is a different wish.
|
|
13066
|
+
*
|
|
13067
|
+
* Ignored when absent, so every existing caller keeps its ordering.
|
|
13068
|
+
*/
|
|
13069
|
+
targetHeight: number().int().positive().optional()
|
|
12878
13070
|
}).readonly();
|
|
12879
13071
|
var PickedCamStreamSchema = object({
|
|
12880
13072
|
camStreamId: string(),
|
|
12881
13073
|
codec: string().optional(),
|
|
12882
13074
|
resolution: CamStreamResolutionSchema.optional(),
|
|
13075
|
+
/**
|
|
13076
|
+
* Whether serving this stream requires a decode + re-encode.
|
|
13077
|
+
*
|
|
13078
|
+
* `false` is a stream the consumer can take as it stands. Only ever `true`
|
|
13079
|
+
* when the caller asked for it with `allowTranscode`, so a caller that did
|
|
13080
|
+
* not ask cannot be handed a cost it never agreed to pay.
|
|
13081
|
+
*/
|
|
13082
|
+
transcodes: boolean(),
|
|
12883
13083
|
/** One-line explanation of why this stream won — for logs / debug UI. */
|
|
12884
13084
|
reason: string()
|
|
12885
13085
|
});
|
|
@@ -16986,7 +17186,7 @@ var AlarmArmModeSchema = _enum([
|
|
|
16986
17186
|
"vacation",
|
|
16987
17187
|
"custom_bypass"
|
|
16988
17188
|
]);
|
|
16989
|
-
object({
|
|
17189
|
+
var AlarmPanelStatusSchema = object({
|
|
16990
17190
|
/** Current lifecycle state. */
|
|
16991
17191
|
state: AlarmStateSchema,
|
|
16992
17192
|
/** Subset of arm modes the panel accepts. UI renders one button per
|
|
@@ -17149,6 +17349,8 @@ var NcSystemEventKindSchema = _enum([
|
|
|
17149
17349
|
"device-enabled",
|
|
17150
17350
|
"device-battery-low",
|
|
17151
17351
|
"device-battery-normal",
|
|
17352
|
+
"device-consumable-low",
|
|
17353
|
+
"device-consumable-normal",
|
|
17152
17354
|
"stream-online",
|
|
17153
17355
|
"stream-offline",
|
|
17154
17356
|
"node-online",
|
|
@@ -17167,6 +17369,7 @@ var NcSystemEventKindSchema = _enum([
|
|
|
17167
17369
|
"addon-updated",
|
|
17168
17370
|
"server-updated",
|
|
17169
17371
|
"export-completed",
|
|
17372
|
+
"backup-completed",
|
|
17170
17373
|
"camera-online",
|
|
17171
17374
|
"camera-offline",
|
|
17172
17375
|
"camera-disabled",
|
|
@@ -24408,10 +24611,28 @@ DeviceType.Camera, method(object({ deviceId: number().int().nonnegative() }), ar
|
|
|
24408
24611
|
}), boolean()), method(object({
|
|
24409
24612
|
deviceId: number().int().nonnegative(),
|
|
24410
24613
|
sessionId: string()
|
|
24411
|
-
}), object({
|
|
24412
|
-
|
|
24413
|
-
|
|
24414
|
-
|
|
24614
|
+
}), object({
|
|
24615
|
+
pendingRenegotiation: object({
|
|
24616
|
+
target: WebrtcStreamTargetSchema,
|
|
24617
|
+
epoch: number()
|
|
24618
|
+
}).nullable(),
|
|
24619
|
+
/**
|
|
24620
|
+
* Whether the session still EXISTS.
|
|
24621
|
+
*
|
|
24622
|
+
* A consumer that holds a resource for the life of a session needs to
|
|
24623
|
+
* be able to ask, because a session does not always end the way it
|
|
24624
|
+
* began. Measured on this hub 2026-09-13: an Echo that got stuck never
|
|
24625
|
+
* sent `SessionDisconnected`, so the Alexa exporter's
|
|
24626
|
+
* `releaseEgressTranscode` never ran, and a 2304x1296 HEVC to 720p
|
|
24627
|
+
* H.264 transcode kept running for NOBODY for more than twenty
|
|
24628
|
+
* minutes. The WebRTC session had logged `WebRTC session closed`
|
|
24629
|
+
* minutes earlier — the broker knew; the holder had no way to ask.
|
|
24630
|
+
*
|
|
24631
|
+
* `false` for a session id the provider has never heard of, which is
|
|
24632
|
+
* the same answer as "it ended": either way nothing is holding it up.
|
|
24633
|
+
*/
|
|
24634
|
+
alive: boolean()
|
|
24635
|
+
}));
|
|
24415
24636
|
object({
|
|
24416
24637
|
/** All accessory children of the parent. */
|
|
24417
24638
|
childDeviceIds: array(number()).readonly(),
|
|
@@ -36976,6 +37197,12 @@ Object.freeze({
|
|
|
36976
37197
|
addonId: null,
|
|
36977
37198
|
access: "create"
|
|
36978
37199
|
},
|
|
37200
|
+
"streamBroker.reportStreamSignal": {
|
|
37201
|
+
capName: "stream-broker",
|
|
37202
|
+
capScope: "system",
|
|
37203
|
+
addonId: null,
|
|
37204
|
+
access: "create"
|
|
37205
|
+
},
|
|
36979
37206
|
"streamBroker.restartProfile": {
|
|
36980
37207
|
capName: "stream-broker",
|
|
36981
37208
|
capScope: "system",
|
|
@@ -37060,6 +37287,12 @@ Object.freeze({
|
|
|
37060
37287
|
addonId: null,
|
|
37061
37288
|
access: "create"
|
|
37062
37289
|
},
|
|
37290
|
+
"streamSignals.listSignals": {
|
|
37291
|
+
capName: "stream-signals",
|
|
37292
|
+
capScope: "device",
|
|
37293
|
+
addonId: null,
|
|
37294
|
+
access: "view"
|
|
37295
|
+
},
|
|
37063
37296
|
"switch.setState": {
|
|
37064
37297
|
capName: "switch",
|
|
37065
37298
|
capScope: "device",
|
|
@@ -39432,6 +39665,11 @@ Object.freeze({
|
|
|
39432
39665
|
form: "single",
|
|
39433
39666
|
optional: false
|
|
39434
39667
|
}],
|
|
39668
|
+
"streamBroker.reportStreamSignal": [{
|
|
39669
|
+
name: "deviceId",
|
|
39670
|
+
form: "single",
|
|
39671
|
+
optional: false
|
|
39672
|
+
}],
|
|
39435
39673
|
"streamBroker.restartProfile": [{
|
|
39436
39674
|
name: "deviceId",
|
|
39437
39675
|
form: "single",
|
|
@@ -40220,7 +40458,7 @@ var Fmp4FragmentChild = class {
|
|
|
40220
40458
|
meta: {
|
|
40221
40459
|
sourceId: this.args.sourceId,
|
|
40222
40460
|
decodeHwAccel: requested,
|
|
40223
|
-
error: errMsg$
|
|
40461
|
+
error: errMsg$16(err)
|
|
40224
40462
|
}
|
|
40225
40463
|
});
|
|
40226
40464
|
this.killChild();
|
|
@@ -40399,7 +40637,7 @@ var Fmp4FragmentChild = class {
|
|
|
40399
40637
|
tags: { deviceId: this.args.deviceId },
|
|
40400
40638
|
meta: {
|
|
40401
40639
|
sourceId: this.args.sourceId,
|
|
40402
|
-
error: errMsg$
|
|
40640
|
+
error: errMsg$16(err)
|
|
40403
40641
|
}
|
|
40404
40642
|
});
|
|
40405
40643
|
}
|
|
@@ -87053,9 +87291,126 @@ function clearPairingFiles(accessoryUuid, logger) {
|
|
|
87053
87291
|
} });
|
|
87054
87292
|
}
|
|
87055
87293
|
}
|
|
87294
|
+
/**
|
|
87295
|
+
* Whether this device's accessory belongs on the bridge.
|
|
87296
|
+
*
|
|
87297
|
+
* A camera is `false` whatever the operator picked — the answer is HomeKit's,
|
|
87298
|
+
* not ours, and an operator who switched it on before the field was gated must
|
|
87299
|
+
* not end up with a camera nobody can pair.
|
|
87300
|
+
*
|
|
87301
|
+
* Absent means ON for everything else: the field did not exist for entries
|
|
87302
|
+
* persisted before it, and the default the operator asked for is the bridge.
|
|
87303
|
+
*/
|
|
87304
|
+
function shouldBridge(input) {
|
|
87305
|
+
if (input.mapperKind === "camera") return false;
|
|
87306
|
+
return input.useBridge !== false;
|
|
87307
|
+
}
|
|
87308
|
+
/** Whether the bridge has room for one more. */
|
|
87309
|
+
function bridgeHasRoom(current) {
|
|
87310
|
+
return current < 149;
|
|
87311
|
+
}
|
|
87312
|
+
//#endregion
|
|
87313
|
+
//#region src/bridge-host.ts
|
|
87314
|
+
/**
|
|
87315
|
+
* THE bridge accessory — one per node, created on demand, holding every
|
|
87316
|
+
* non-camera accessory the operator routed onto it.
|
|
87317
|
+
*
|
|
87318
|
+
* One mDNS advertisement, one HAP connection, one pairing, N accessories
|
|
87319
|
+
* inside. The alternative — what this addon did until now — gives every
|
|
87320
|
+
* switch, sensor and alarm panel its own port, its own advertisement and its
|
|
87321
|
+
* own "Add Accessory" in the Home app. Cameras stay standalone, because
|
|
87322
|
+
* HomeKit forbids bridging them (`bridge-policy.ts`).
|
|
87323
|
+
*
|
|
87324
|
+
* ONE bridge, deliberately. The ceiling is 149 accessories
|
|
87325
|
+
* ({@link MAX_BRIDGED_ACCESSORIES}) and this hub exposes 46 devices in total,
|
|
87326
|
+
* cameras included; a second bridge is a thing to build when the count
|
|
87327
|
+
* approaches the ceiling, not before, and the refusal at the ceiling is
|
|
87328
|
+
* explicit rather than a library throw.
|
|
87329
|
+
*
|
|
87330
|
+
* The bridge is LAZY: it is published the first time an accessory needs it,
|
|
87331
|
+
* so a fleet of nothing but cameras advertises no empty bridge. It is not
|
|
87332
|
+
* unpublished when the last accessory leaves — an unpublish would drop the
|
|
87333
|
+
* pairing record the operator already entered a code for, and an empty bridge
|
|
87334
|
+
* in the Home app is a far smaller cost than a re-pair.
|
|
87335
|
+
*/
|
|
87336
|
+
var BridgeHost = class {
|
|
87337
|
+
opts;
|
|
87338
|
+
bridge = null;
|
|
87339
|
+
published = false;
|
|
87340
|
+
constructor(opts) {
|
|
87341
|
+
this.opts = opts;
|
|
87342
|
+
}
|
|
87343
|
+
/** The live bridge accessory, or `null` before anything needed one. */
|
|
87344
|
+
get accessory() {
|
|
87345
|
+
return this.bridge;
|
|
87346
|
+
}
|
|
87347
|
+
/** How many accessories are riding it right now. */
|
|
87348
|
+
get size() {
|
|
87349
|
+
return this.bridge?.bridgedAccessories.length ?? 0;
|
|
87350
|
+
}
|
|
87351
|
+
/**
|
|
87352
|
+
* Put an accessory on the bridge, publishing the bridge if this is the
|
|
87353
|
+
* first. Returns `false` — without throwing, and having logged — when the
|
|
87354
|
+
* bridge is full: the caller then falls back to standalone, which is worse
|
|
87355
|
+
* for the operator and still works.
|
|
87356
|
+
*/
|
|
87357
|
+
async add(accessory) {
|
|
87358
|
+
const bridge = this.ensure();
|
|
87359
|
+
if (!bridgeHasRoom(bridge.bridgedAccessories.length)) {
|
|
87360
|
+
this.opts.logger.warn("export-hap: the bridge is FULL — publishing standalone instead", { meta: {
|
|
87361
|
+
uuid: accessory.UUID,
|
|
87362
|
+
bridged: bridge.bridgedAccessories.length,
|
|
87363
|
+
max: 149
|
|
87364
|
+
} });
|
|
87365
|
+
return false;
|
|
87366
|
+
}
|
|
87367
|
+
bridge.addBridgedAccessory(accessory);
|
|
87368
|
+
await this.publishOnce();
|
|
87369
|
+
return true;
|
|
87370
|
+
}
|
|
87371
|
+
/** Take an accessory off the bridge. A bridged accessory is never
|
|
87372
|
+
* `unpublish`ed — it has no server of its own. */
|
|
87373
|
+
remove(accessory) {
|
|
87374
|
+
if (this.bridge === null) return;
|
|
87375
|
+
if (!this.bridge.bridgedAccessories.some((a) => a.UUID === accessory.UUID)) return;
|
|
87376
|
+
this.bridge.removeBridgedAccessory(accessory, false);
|
|
87377
|
+
}
|
|
87378
|
+
/** Whether this accessory is currently on the bridge. */
|
|
87379
|
+
holds(accessory) {
|
|
87380
|
+
return this.bridge?.bridgedAccessories.some((a) => a.UUID === accessory.UUID) ?? false;
|
|
87381
|
+
}
|
|
87382
|
+
/** Tear the bridge down — process shutdown only. */
|
|
87383
|
+
async dispose() {
|
|
87384
|
+
if (this.bridge === null || !this.published) return;
|
|
87385
|
+
await unpublishAccessory(this.bridge, this.opts.logger);
|
|
87386
|
+
this.published = false;
|
|
87387
|
+
}
|
|
87388
|
+
ensure() {
|
|
87389
|
+
if (this.bridge !== null) return this.bridge;
|
|
87390
|
+
const bridge = new import_dist.Accessory(this.opts.displayName, this.opts.uuid);
|
|
87391
|
+
bridge.category = import_dist.Categories.BRIDGE;
|
|
87392
|
+
this.bridge = bridge;
|
|
87393
|
+
return bridge;
|
|
87394
|
+
}
|
|
87395
|
+
async publishOnce() {
|
|
87396
|
+
if (this.published || this.bridge === null) return;
|
|
87397
|
+
if (this.opts.publish !== void 0) await this.opts.publish(this.bridge, this.opts.pincode);
|
|
87398
|
+
else await publishStandalone(this.bridge, {
|
|
87399
|
+
pincode: this.opts.pincode,
|
|
87400
|
+
port: 0,
|
|
87401
|
+
bind: this.opts.bind,
|
|
87402
|
+
logger: this.opts.logger
|
|
87403
|
+
});
|
|
87404
|
+
this.published = true;
|
|
87405
|
+
this.opts.logger.info("export-hap: the bridge is published", { meta: {
|
|
87406
|
+
displayName: this.opts.displayName,
|
|
87407
|
+
uuid: this.opts.uuid
|
|
87408
|
+
} });
|
|
87409
|
+
}
|
|
87410
|
+
};
|
|
87056
87411
|
//#endregion
|
|
87057
87412
|
//#region src/hap-setup-uri.ts
|
|
87058
|
-
function errMsg$
|
|
87413
|
+
function errMsg$15(e) {
|
|
87059
87414
|
return e instanceof Error ? e.message : String(e);
|
|
87060
87415
|
}
|
|
87061
87416
|
/**
|
|
@@ -87082,7 +87437,7 @@ function firstExposedAccessorySetupUri(exposed, logger) {
|
|
|
87082
87437
|
try {
|
|
87083
87438
|
return first.setupURI();
|
|
87084
87439
|
} catch (err) {
|
|
87085
|
-
logger.debug("export-hap: setupURI failed on first exposed accessory", { meta: { error: errMsg$
|
|
87440
|
+
logger.debug("export-hap: setupURI failed on first exposed accessory", { meta: { error: errMsg$15(err) } });
|
|
87086
87441
|
return;
|
|
87087
87442
|
}
|
|
87088
87443
|
}
|
|
@@ -87435,7 +87790,7 @@ async function buildBattery(bctx) {
|
|
|
87435
87790
|
const status = await proxy.battery?.getStatus({});
|
|
87436
87791
|
if (status !== void 0 && status !== null) applyToService(service, status);
|
|
87437
87792
|
} catch (err) {
|
|
87438
|
-
log.debug("export-hap: battery getStatus hydrate failed (non-fatal)", { meta: { error: errMsg$
|
|
87793
|
+
log.debug("export-hap: battery getStatus hydrate failed (non-fatal)", { meta: { error: errMsg$14(err) } });
|
|
87439
87794
|
}
|
|
87440
87795
|
const unsubscribes = [];
|
|
87441
87796
|
if (proxy.state.battery) {
|
|
@@ -87454,7 +87809,7 @@ async function buildBattery(bctx) {
|
|
|
87454
87809
|
function applyToService(service, status) {
|
|
87455
87810
|
applyUpdates(service, batteryCharacteristicUpdates(status));
|
|
87456
87811
|
}
|
|
87457
|
-
function errMsg$
|
|
87812
|
+
function errMsg$14(err) {
|
|
87458
87813
|
return err instanceof Error ? err.message : String(err);
|
|
87459
87814
|
}
|
|
87460
87815
|
//#endregion
|
|
@@ -98206,7 +98561,7 @@ var VIDEO_LOOPBACK_RCVBUF_BYTES = 8 * 1024 * 1024;
|
|
|
98206
98561
|
* not burst size.
|
|
98207
98562
|
*/
|
|
98208
98563
|
var AUDIO_LOOPBACK_RCVBUF_BYTES = 1024 * 1024;
|
|
98209
|
-
function errMsg$
|
|
98564
|
+
function errMsg$13(err) {
|
|
98210
98565
|
return err instanceof Error ? err.message : String(err);
|
|
98211
98566
|
}
|
|
98212
98567
|
/**
|
|
@@ -98221,13 +98576,13 @@ function applyReceiveBuffer(socket, requestedBytes) {
|
|
|
98221
98576
|
try {
|
|
98222
98577
|
socket.setRecvBufferSize(requestedBytes);
|
|
98223
98578
|
} catch (err) {
|
|
98224
|
-
error = errMsg$
|
|
98579
|
+
error = errMsg$13(err);
|
|
98225
98580
|
}
|
|
98226
98581
|
let effectiveBytes = null;
|
|
98227
98582
|
try {
|
|
98228
98583
|
effectiveBytes = socket.getRecvBufferSize();
|
|
98229
98584
|
} catch (err) {
|
|
98230
|
-
if (error === null) error = errMsg$
|
|
98585
|
+
if (error === null) error = errMsg$13(err);
|
|
98231
98586
|
}
|
|
98232
98587
|
return {
|
|
98233
98588
|
requestedBytes,
|
|
@@ -98487,20 +98842,20 @@ function buildCameraStreamingDelegate(bctx, advertised) {
|
|
|
98487
98842
|
delegate: {
|
|
98488
98843
|
handleSnapshotRequest(request, callback) {
|
|
98489
98844
|
handleSnapshot(bctx, request).then((buf) => callback(void 0, buf)).catch((err) => {
|
|
98490
|
-
log.warn("export-hap: snapshot failed", { meta: { error: errMsg$
|
|
98491
|
-
callback(err instanceof Error ? err : new Error(errMsg$
|
|
98845
|
+
log.warn("export-hap: snapshot failed", { meta: { error: errMsg$12(err) } });
|
|
98846
|
+
callback(err instanceof Error ? err : new Error(errMsg$12(err)));
|
|
98492
98847
|
});
|
|
98493
98848
|
},
|
|
98494
98849
|
prepareStream(request, callback) {
|
|
98495
98850
|
prepareStream(request, sessions, bctx).then((resp) => callback(void 0, resp)).catch((err) => {
|
|
98496
|
-
log.warn("export-hap: prepareStream failed", { meta: { error: errMsg$
|
|
98497
|
-
callback(err instanceof Error ? err : new Error(errMsg$
|
|
98851
|
+
log.warn("export-hap: prepareStream failed", { meta: { error: errMsg$12(err) } });
|
|
98852
|
+
callback(err instanceof Error ? err : new Error(errMsg$12(err)));
|
|
98498
98853
|
});
|
|
98499
98854
|
},
|
|
98500
98855
|
handleStreamRequest(request, callback) {
|
|
98501
98856
|
handleStreamRequest(request, sessions, bctx, advertised).then(() => callback()).catch((err) => {
|
|
98502
|
-
log.warn("export-hap: handleStreamRequest failed", { meta: { error: errMsg$
|
|
98503
|
-
callback(err instanceof Error ? err : new Error(errMsg$
|
|
98857
|
+
log.warn("export-hap: handleStreamRequest failed", { meta: { error: errMsg$12(err) } });
|
|
98858
|
+
callback(err instanceof Error ? err : new Error(errMsg$12(err)));
|
|
98504
98859
|
});
|
|
98505
98860
|
}
|
|
98506
98861
|
},
|
|
@@ -98616,7 +98971,7 @@ async function prepareStream(request, sessions, bctx) {
|
|
|
98616
98971
|
closeSocket(audioUdp);
|
|
98617
98972
|
closeSocket(videoLoopUdp);
|
|
98618
98973
|
closeSocket(audioLoopUdp);
|
|
98619
|
-
throw new Error(`export-hap: outbound SrtpSession init failed: ${errMsg$
|
|
98974
|
+
throw new Error(`export-hap: outbound SrtpSession init failed: ${errMsg$12(err)}`, { cause: err });
|
|
98620
98975
|
}
|
|
98621
98976
|
let upstreamAudioSrtp = null;
|
|
98622
98977
|
try {
|
|
@@ -98630,7 +98985,7 @@ async function prepareStream(request, sessions, bctx) {
|
|
|
98630
98985
|
profile: import_src.ProtectionProfileAes128CmHmacSha1_80
|
|
98631
98986
|
});
|
|
98632
98987
|
} catch (err) {
|
|
98633
|
-
bctx.ctx.logger.withTags({ deviceId: bctx.numericDeviceId }).warn("export-hap: SrtpSession init failed (upstream audio decrypt disabled)", { meta: { error: errMsg$
|
|
98988
|
+
bctx.ctx.logger.withTags({ deviceId: bctx.numericDeviceId }).warn("export-hap: SrtpSession init failed (upstream audio decrypt disabled)", { meta: { error: errMsg$12(err) } });
|
|
98634
98989
|
}
|
|
98635
98990
|
const videoSsrc = randomSsrc();
|
|
98636
98991
|
const audioSsrc = randomSsrc();
|
|
@@ -98747,7 +99102,7 @@ async function prepareStream(request, sessions, bctx) {
|
|
|
98747
99102
|
});
|
|
98748
99103
|
audioUdp.on("message", (packet, rinfo) => {
|
|
98749
99104
|
handleIncomingAudioRtp(session, packet, rinfo.address, bctx).catch((err) => {
|
|
98750
|
-
bctx.ctx.logger.withTags({ deviceId: bctx.numericDeviceId }).debug("export-hap: incoming-audio handler error (dropped)", { meta: { error: errMsg$
|
|
99105
|
+
bctx.ctx.logger.withTags({ deviceId: bctx.numericDeviceId }).debug("export-hap: incoming-audio handler error (dropped)", { meta: { error: errMsg$12(err) } });
|
|
98751
99106
|
});
|
|
98752
99107
|
});
|
|
98753
99108
|
logLoopbackBuffer(tagLog, request.sessionID, "video", videoLoop.buffer);
|
|
@@ -98943,7 +99298,7 @@ function readControllerRtcp(session, leg, packet, log) {
|
|
|
98943
99298
|
} catch (err) {
|
|
98944
99299
|
drop(session, "inbound-rtcp-decrypt-failed");
|
|
98945
99300
|
storeReceiverReports(session, leg, recordUnreadableRtcp(tally));
|
|
98946
|
-
logUnreadableRtcp(session, leg, `decrypt: ${errMsg$
|
|
99301
|
+
logUnreadableRtcp(session, leg, `decrypt: ${errMsg$12(err)}`, log);
|
|
98947
99302
|
return;
|
|
98948
99303
|
}
|
|
98949
99304
|
const outcome = ingestDecryptedRtcp(plaintext, tally);
|
|
@@ -99460,6 +99815,19 @@ async function startFfmpegForSession(bctx, session, sessionId, video, advertised
|
|
|
99460
99815
|
} });
|
|
99461
99816
|
throw new Error(`export-hap: no enabled RTSP entries for device ${numericDeviceId}`);
|
|
99462
99817
|
}
|
|
99818
|
+
if (fit.kind === "transcode" && bctx.options.hapDeviceSettings?.allowTranscode === false) {
|
|
99819
|
+
startLog.warn("export-hap: stream start REFUSED — transcoding is switched off", {
|
|
99820
|
+
tags: { deviceId: numericDeviceId },
|
|
99821
|
+
meta: {
|
|
99822
|
+
sessionId,
|
|
99823
|
+
streamPreference: pref,
|
|
99824
|
+
negotiated: `${video.width}x${video.height}`,
|
|
99825
|
+
pickedProfile: fit.profile,
|
|
99826
|
+
pickedCodec: fit.picked.codec ?? "unknown"
|
|
99827
|
+
}
|
|
99828
|
+
});
|
|
99829
|
+
throw new Error(`export-hap: device ${numericDeviceId} needs a transcode and transcoding is switched off`);
|
|
99830
|
+
}
|
|
99463
99831
|
const picked = fit.picked;
|
|
99464
99832
|
const rtspUrl = picked.url;
|
|
99465
99833
|
const slot = brokerStreams.find((s) => s.profile === fit.profile);
|
|
@@ -99709,7 +100077,7 @@ async function handleIncomingAudioRtp(session, packet, sourceAddress, bctx) {
|
|
|
99709
100077
|
session.upstreamRtpDecryptFailures += 1;
|
|
99710
100078
|
if (session.upstreamRtpDecryptFailures % 100 === 1) log.debug("export-hap: SRTP decrypt failed (rate-limited)", { meta: {
|
|
99711
100079
|
failures: session.upstreamRtpDecryptFailures,
|
|
99712
|
-
error: errMsg$
|
|
100080
|
+
error: errMsg$12(err)
|
|
99713
100081
|
} });
|
|
99714
100082
|
return;
|
|
99715
100083
|
}
|
|
@@ -99723,7 +100091,7 @@ async function handleIncomingAudioRtp(session, packet, sourceAddress, bctx) {
|
|
|
99723
100091
|
rtpPayloadType = parsedRtp.header.payloadType;
|
|
99724
100092
|
} catch (err) {
|
|
99725
100093
|
drop(session, "upstream-parse-failed");
|
|
99726
|
-
log.debug("export-hap: RTP parse failed after decrypt", { meta: { error: errMsg$
|
|
100094
|
+
log.debug("export-hap: RTP parse failed after decrypt", { meta: { error: errMsg$12(err) } });
|
|
99727
100095
|
return;
|
|
99728
100096
|
}
|
|
99729
100097
|
const negotiatedAudioPt = session.lastStartParams?.audioPt;
|
|
@@ -99747,7 +100115,7 @@ async function handleIncomingAudioRtp(session, packet, sourceAddress, bctx) {
|
|
|
99747
100115
|
if (session.intercomTalkSessionId === null) {
|
|
99748
100116
|
session.intercomTalkSessionId = "";
|
|
99749
100117
|
const opened = await openIntercomTalkSession(bctx).catch((err) => {
|
|
99750
|
-
log.warn("export-hap: intercom.startTalkSession failed", { meta: { error: errMsg$
|
|
100118
|
+
log.warn("export-hap: intercom.startTalkSession failed", { meta: { error: errMsg$12(err) } });
|
|
99751
100119
|
return null;
|
|
99752
100120
|
});
|
|
99753
100121
|
if (opened) {
|
|
@@ -99774,7 +100142,7 @@ async function handleIncomingAudioRtp(session, packet, sourceAddress, bctx) {
|
|
|
99774
100142
|
drop(session, "upstream-push-failed");
|
|
99775
100143
|
log.debug("export-hap: intercom.pushTalkAudio failed (will re-open on next frame)", { meta: {
|
|
99776
100144
|
sequenceNumber: session.intercomPcmSequence,
|
|
99777
|
-
error: errMsg$
|
|
100145
|
+
error: errMsg$12(err)
|
|
99778
100146
|
} });
|
|
99779
100147
|
session.intercomTalkSessionId = null;
|
|
99780
100148
|
}
|
|
@@ -99806,7 +100174,7 @@ async function closeIntercomTalkSession(session, bctx) {
|
|
|
99806
100174
|
} catch (err) {
|
|
99807
100175
|
log.debug("export-hap: intercom.endTalkSession failed (continuing)", { meta: {
|
|
99808
100176
|
sessionId,
|
|
99809
|
-
error: errMsg$
|
|
100177
|
+
error: errMsg$12(err)
|
|
99810
100178
|
} });
|
|
99811
100179
|
}
|
|
99812
100180
|
}
|
|
@@ -99831,7 +100199,7 @@ function closeSocket(udp) {
|
|
|
99831
100199
|
function randomSsrc() {
|
|
99832
100200
|
return Math.floor(Math.random() * 2147483646) + 1 | 0;
|
|
99833
100201
|
}
|
|
99834
|
-
function errMsg$
|
|
100202
|
+
function errMsg$12(err) {
|
|
99835
100203
|
return err instanceof Error ? err.message : String(err);
|
|
99836
100204
|
}
|
|
99837
100205
|
//#endregion
|
|
@@ -99915,14 +100283,14 @@ async function buildDoorbell(input) {
|
|
|
99915
100283
|
}
|
|
99916
100284
|
log.info("export-hap: doorbell SINGLE_PRESS pushed to HomeKit", { meta: { ...delivery } });
|
|
99917
100285
|
} catch (err) {
|
|
99918
|
-
log.warn("export-hap: ringDoorbell() failed", { meta: { error: errMsg$
|
|
100286
|
+
log.warn("export-hap: ringDoorbell() failed", { meta: { error: errMsg$11(err) } });
|
|
99919
100287
|
}
|
|
99920
100288
|
});
|
|
99921
100289
|
return { async dispose() {
|
|
99922
100290
|
unsubscribe();
|
|
99923
100291
|
} };
|
|
99924
100292
|
}
|
|
99925
|
-
function errMsg$
|
|
100293
|
+
function errMsg$11(err) {
|
|
99926
100294
|
return err instanceof Error ? err.message : String(err);
|
|
99927
100295
|
}
|
|
99928
100296
|
//#endregion
|
|
@@ -99970,7 +100338,7 @@ async function buildMotionSensor(bctx, existing = null) {
|
|
|
99970
100338
|
const detected = await proxy.motion?.isDetected({});
|
|
99971
100339
|
if (typeof detected === "boolean") motionService.updateCharacteristic(import_dist.Characteristic.MotionDetected, detected);
|
|
99972
100340
|
} catch (err) {
|
|
99973
|
-
ctx.logger.withTags({ deviceId: numericDeviceId }).debug("export-hap: initial motion hydrate failed (non-fatal)", { meta: { error: errMsg$
|
|
100341
|
+
ctx.logger.withTags({ deviceId: numericDeviceId }).debug("export-hap: initial motion hydrate failed (non-fatal)", { meta: { error: errMsg$10(err) } });
|
|
99974
100342
|
}
|
|
99975
100343
|
let resetTimer = null;
|
|
99976
100344
|
const armReset = () => {
|
|
@@ -100004,7 +100372,7 @@ async function buildMotionSensor(bctx, existing = null) {
|
|
|
100004
100372
|
}
|
|
100005
100373
|
} };
|
|
100006
100374
|
}
|
|
100007
|
-
function errMsg$
|
|
100375
|
+
function errMsg$10(err) {
|
|
100008
100376
|
return err instanceof Error ? err.message : String(err);
|
|
100009
100377
|
}
|
|
100010
100378
|
//#endregion
|
|
@@ -100035,7 +100403,7 @@ async function buildPrivacySwitch(bctx) {
|
|
|
100035
100403
|
const status = await proxy.privacyMask?.getStatus({});
|
|
100036
100404
|
if (status && typeof status.enabled === "boolean") service.updateCharacteristic(import_dist.Characteristic.On, status.enabled);
|
|
100037
100405
|
} catch (err) {
|
|
100038
|
-
log.debug("export-hap: privacy-mask getStatus hydrate failed (non-fatal)", { meta: { error: errMsg$
|
|
100406
|
+
log.debug("export-hap: privacy-mask getStatus hydrate failed (non-fatal)", { meta: { error: errMsg$9(err) } });
|
|
100039
100407
|
}
|
|
100040
100408
|
service.getCharacteristic(import_dist.Characteristic.On).onSet(async (value) => {
|
|
100041
100409
|
const enabled = value === true;
|
|
@@ -100044,7 +100412,7 @@ async function buildPrivacySwitch(bctx) {
|
|
|
100044
100412
|
} catch (err) {
|
|
100045
100413
|
log.warn("export-hap: privacy-mask setMask failed", { meta: {
|
|
100046
100414
|
enabled,
|
|
100047
|
-
error: errMsg$
|
|
100415
|
+
error: errMsg$9(err)
|
|
100048
100416
|
} });
|
|
100049
100417
|
}
|
|
100050
100418
|
});
|
|
@@ -100062,7 +100430,7 @@ async function buildPrivacySwitch(bctx) {
|
|
|
100062
100430
|
} catch {}
|
|
100063
100431
|
} };
|
|
100064
100432
|
}
|
|
100065
|
-
function errMsg$
|
|
100433
|
+
function errMsg$9(err) {
|
|
100066
100434
|
return err instanceof Error ? err.message : String(err);
|
|
100067
100435
|
}
|
|
100068
100436
|
//#endregion
|
|
@@ -100153,7 +100521,7 @@ async function buildPtz(bctx) {
|
|
|
100153
100521
|
} catch (err) {
|
|
100154
100522
|
log.warn("export-hap: ptz.goToPreset failed", { meta: {
|
|
100155
100523
|
presetId: preset.id,
|
|
100156
|
-
error: errMsg$
|
|
100524
|
+
error: errMsg$8(err)
|
|
100157
100525
|
} });
|
|
100158
100526
|
}
|
|
100159
100527
|
armReset(() => service.updateCharacteristic(import_dist.Characteristic.On, false), MOMENTARY_RESET_MS);
|
|
@@ -100171,14 +100539,14 @@ async function buildPtz(bctx) {
|
|
|
100171
100539
|
try {
|
|
100172
100540
|
await proxy.ptz?.stop({});
|
|
100173
100541
|
} catch (err) {
|
|
100174
|
-
log.debug("export-hap: ptz.stop failed (non-fatal)", { meta: { error: errMsg$
|
|
100542
|
+
log.debug("export-hap: ptz.stop failed (non-fatal)", { meta: { error: errMsg$8(err) } });
|
|
100175
100543
|
}
|
|
100176
100544
|
service.updateCharacteristic(import_dist.Characteristic.On, false);
|
|
100177
100545
|
}, options.ptzPulseMs);
|
|
100178
100546
|
} catch (err) {
|
|
100179
100547
|
log.warn("export-hap: ptz.continuousMove failed", { meta: {
|
|
100180
100548
|
dir: dir.label,
|
|
100181
|
-
error: errMsg$
|
|
100549
|
+
error: errMsg$8(err)
|
|
100182
100550
|
} });
|
|
100183
100551
|
service.updateCharacteristic(import_dist.Characteristic.On, false);
|
|
100184
100552
|
}
|
|
@@ -100201,7 +100569,7 @@ async function readPresets(bctx) {
|
|
|
100201
100569
|
name: p.name
|
|
100202
100570
|
}));
|
|
100203
100571
|
} catch (err) {
|
|
100204
|
-
ctx.logger.withTags({ deviceId: numericDeviceId }).debug("export-hap: ptz.getPresets failed (non-fatal)", { meta: { error: errMsg$
|
|
100572
|
+
ctx.logger.withTags({ deviceId: numericDeviceId }).debug("export-hap: ptz.getPresets failed (non-fatal)", { meta: { error: errMsg$8(err) } });
|
|
100205
100573
|
return [];
|
|
100206
100574
|
}
|
|
100207
100575
|
}
|
|
@@ -100216,7 +100584,7 @@ async function tryBuildAutotrack(bctx) {
|
|
|
100216
100584
|
const status = await proxy.ptzAutotrack.getStatus({});
|
|
100217
100585
|
if (status && typeof status.enabled === "boolean") service.updateCharacteristic(import_dist.Characteristic.On, status.enabled);
|
|
100218
100586
|
} catch (err) {
|
|
100219
|
-
log.debug("export-hap: ptzAutotrack.getStatus failed (non-fatal)", { meta: { error: errMsg$
|
|
100587
|
+
log.debug("export-hap: ptzAutotrack.getStatus failed (non-fatal)", { meta: { error: errMsg$8(err) } });
|
|
100220
100588
|
}
|
|
100221
100589
|
service.getCharacteristic(import_dist.Characteristic.On).onSet(async (value) => {
|
|
100222
100590
|
const enabled = value === true;
|
|
@@ -100225,13 +100593,13 @@ async function tryBuildAutotrack(bctx) {
|
|
|
100225
100593
|
} catch (err) {
|
|
100226
100594
|
log.warn("export-hap: ptzAutotrack.setEnabled failed", { meta: {
|
|
100227
100595
|
enabled,
|
|
100228
|
-
error: errMsg$
|
|
100596
|
+
error: errMsg$8(err)
|
|
100229
100597
|
} });
|
|
100230
100598
|
}
|
|
100231
100599
|
});
|
|
100232
100600
|
return { async dispose() {} };
|
|
100233
100601
|
}
|
|
100234
|
-
function errMsg$
|
|
100602
|
+
function errMsg$8(err) {
|
|
100235
100603
|
return err instanceof Error ? err.message : String(err);
|
|
100236
100604
|
}
|
|
100237
100605
|
//#endregion
|
|
@@ -101262,13 +101630,13 @@ async function buildChildSwitch(bctx, subtype, deviceType) {
|
|
|
101262
101630
|
const switchStatus = await proxy.switch?.getStatus({});
|
|
101263
101631
|
if (switchStatus && typeof switchStatus.on === "boolean") service.updateCharacteristic(import_dist.Characteristic.On, switchStatus.on);
|
|
101264
101632
|
} catch (err) {
|
|
101265
|
-
log.debug("export-hap: child switch.getStatus failed (non-fatal)", { meta: { error: errMsg$
|
|
101633
|
+
log.debug("export-hap: child switch.getStatus failed (non-fatal)", { meta: { error: errMsg$7(err) } });
|
|
101266
101634
|
}
|
|
101267
101635
|
if (useLightbulb) try {
|
|
101268
101636
|
const status = await proxy.brightness?.getStatus({});
|
|
101269
101637
|
if (status && typeof status.percentage === "number") service.updateCharacteristic(import_dist.Characteristic.Brightness, status.percentage);
|
|
101270
101638
|
} catch (err) {
|
|
101271
|
-
log.debug("export-hap: child brightness.getStatus failed (non-fatal)", { meta: { error: errMsg$
|
|
101639
|
+
log.debug("export-hap: child brightness.getStatus failed (non-fatal)", { meta: { error: errMsg$7(err) } });
|
|
101272
101640
|
}
|
|
101273
101641
|
if (hasSwitch) service.getCharacteristic(import_dist.Characteristic.On).onSet(async (value) => {
|
|
101274
101642
|
const on = value === true;
|
|
@@ -101277,7 +101645,7 @@ async function buildChildSwitch(bctx, subtype, deviceType) {
|
|
|
101277
101645
|
} catch (err) {
|
|
101278
101646
|
log.warn("export-hap: child switch.setState failed", { meta: {
|
|
101279
101647
|
on,
|
|
101280
|
-
error: errMsg$
|
|
101648
|
+
error: errMsg$7(err)
|
|
101281
101649
|
} });
|
|
101282
101650
|
}
|
|
101283
101651
|
});
|
|
@@ -101289,7 +101657,7 @@ async function buildChildSwitch(bctx, subtype, deviceType) {
|
|
|
101289
101657
|
} catch (err) {
|
|
101290
101658
|
log.warn("export-hap: child brightness.setBrightness failed", { meta: {
|
|
101291
101659
|
percentage,
|
|
101292
|
-
error: errMsg$
|
|
101660
|
+
error: errMsg$7(err)
|
|
101293
101661
|
} });
|
|
101294
101662
|
}
|
|
101295
101663
|
});
|
|
@@ -101312,7 +101680,7 @@ async function buildChildSwitch(bctx, subtype, deviceType) {
|
|
|
101312
101680
|
} catch {}
|
|
101313
101681
|
} };
|
|
101314
101682
|
}
|
|
101315
|
-
function errMsg$
|
|
101683
|
+
function errMsg$7(err) {
|
|
101316
101684
|
return err instanceof Error ? err.message : String(err);
|
|
101317
101685
|
}
|
|
101318
101686
|
//#endregion
|
|
@@ -101339,7 +101707,7 @@ async function buildChildServicesFor(input) {
|
|
|
101339
101707
|
for (const h of handles) try {
|
|
101340
101708
|
await h.dispose();
|
|
101341
101709
|
} catch (err) {
|
|
101342
|
-
ctx.logger.withTags({ deviceId: parentNumericId }).debug("export-hap: child service dispose failed (continuing)", { meta: { error: errMsg$
|
|
101710
|
+
ctx.logger.withTags({ deviceId: parentNumericId }).debug("export-hap: child service dispose failed (continuing)", { meta: { error: errMsg$6(err) } });
|
|
101343
101711
|
}
|
|
101344
101712
|
} };
|
|
101345
101713
|
}
|
|
@@ -101355,7 +101723,7 @@ async function listChildren(ctx, parentNumericId) {
|
|
|
101355
101723
|
features: Array.isArray(c.features) ? c.features.filter((f) => typeof f === "string") : []
|
|
101356
101724
|
}));
|
|
101357
101725
|
} catch (err) {
|
|
101358
|
-
ctx.logger.withTags({ deviceId: parentNumericId }).debug("export-hap: deviceManager.getChildren failed (non-fatal)", { meta: { error: errMsg$
|
|
101726
|
+
ctx.logger.withTags({ deviceId: parentNumericId }).debug("export-hap: deviceManager.getChildren failed (non-fatal)", { meta: { error: errMsg$6(err) } });
|
|
101359
101727
|
return [];
|
|
101360
101728
|
}
|
|
101361
101729
|
}
|
|
@@ -101371,7 +101739,7 @@ function asDeviceType(raw) {
|
|
|
101371
101739
|
for (const value of Object.values(DeviceType)) if (value === lower) return value;
|
|
101372
101740
|
return DeviceType.Generic;
|
|
101373
101741
|
}
|
|
101374
|
-
function errMsg$
|
|
101742
|
+
function errMsg$6(err) {
|
|
101375
101743
|
return err instanceof Error ? err.message : String(err);
|
|
101376
101744
|
}
|
|
101377
101745
|
//#endregion
|
|
@@ -101393,12 +101761,18 @@ var SUPPORTED_MAPPER_KINDS = ["camera", "generic"];
|
|
|
101393
101761
|
* doctrine the HA exporter writes down, and the thing that confined the
|
|
101394
101762
|
* previous exporter to cameras when it was ignored.
|
|
101395
101763
|
*
|
|
101396
|
-
* Tier A
|
|
101397
|
-
* feature-dependent shape. `cover`, `climate`, `fan`, `valve`,
|
|
101398
|
-
* `
|
|
101764
|
+
* Tier A plus `alarm-panel`: the types whose HomeKit services exist today and
|
|
101765
|
+
* need no feature-dependent shape. `cover`, `climate`, `fan`, `valve`,
|
|
101766
|
+
* `humidifier`, `water-heater`, `button` and `media-player` are deliberately
|
|
101399
101767
|
* absent — each needs a service whose semantics the table cannot yet honour,
|
|
101400
101768
|
* and offering the tab before the mapping exists is how an operator gets an
|
|
101401
101769
|
* accessory that pairs and does nothing.
|
|
101770
|
+
*
|
|
101771
|
+
* `alarm-panel` is no longer one of them. It maps to `Service.SecuritySystem`
|
|
101772
|
+
* (`builders/generic/security-system.ts`), and the two things the table could
|
|
101773
|
+
* not previously honour are now honoured explicitly: HomeKit is only ever
|
|
101774
|
+
* offered the arm modes the panel accepts, and a panel that requires a PIN
|
|
101775
|
+
* refuses the write out loud instead of pretending to arm.
|
|
101402
101776
|
*/
|
|
101403
101777
|
var HAP_EXPORTABLE_DEVICE_TYPES = [
|
|
101404
101778
|
DeviceType.Camera,
|
|
@@ -101408,6 +101782,7 @@ var HAP_EXPORTABLE_DEVICE_TYPES = [
|
|
|
101408
101782
|
DeviceType.Sensor,
|
|
101409
101783
|
DeviceType.Lock,
|
|
101410
101784
|
DeviceType.Presence,
|
|
101785
|
+
DeviceType.AlarmPanel,
|
|
101411
101786
|
DeviceType.Generic
|
|
101412
101787
|
];
|
|
101413
101788
|
/**
|
|
@@ -101533,17 +101908,17 @@ async function buildCameraAccessory(input) {
|
|
|
101533
101908
|
for (const h of handles) try {
|
|
101534
101909
|
await h.dispose();
|
|
101535
101910
|
} catch (err) {
|
|
101536
|
-
log.debug("export-hap: builder dispose failed (continuing)", { meta: { error: errMsg$
|
|
101911
|
+
log.debug("export-hap: builder dispose failed (continuing)", { meta: { error: errMsg$5(err) } });
|
|
101537
101912
|
}
|
|
101538
101913
|
try {
|
|
101539
101914
|
await streams.dispose();
|
|
101540
101915
|
} catch (err) {
|
|
101541
|
-
log.debug("export-hap: streams dispose failed", { meta: { error: errMsg$
|
|
101916
|
+
log.debug("export-hap: streams dispose failed", { meta: { error: errMsg$5(err) } });
|
|
101542
101917
|
}
|
|
101543
101918
|
}
|
|
101544
101919
|
};
|
|
101545
101920
|
}
|
|
101546
|
-
function errMsg$
|
|
101921
|
+
function errMsg$5(err) {
|
|
101547
101922
|
return err instanceof Error ? err.message : String(err);
|
|
101548
101923
|
}
|
|
101549
101924
|
//#endregion
|
|
@@ -101572,7 +101947,7 @@ function errMsg$4(err) {
|
|
|
101572
101947
|
* counterpart on this service and is deliberately not wired — a Switch that
|
|
101573
101948
|
* silently buzzes a door open would be a second knob nobody asked for.
|
|
101574
101949
|
*/
|
|
101575
|
-
var SUBTYPE = "lock-control";
|
|
101950
|
+
var SUBTYPE$1 = "lock-control";
|
|
101576
101951
|
var readLock = reader(LockControlStatusSchema.pick({ state: true }), (status) => {
|
|
101577
101952
|
const current = status.state === "locked" ? import_dist.Characteristic.LockCurrentState.SECURED : status.state === "unlocked" ? import_dist.Characteristic.LockCurrentState.UNSECURED : status.state === "jammed" ? import_dist.Characteristic.LockCurrentState.JAMMED : import_dist.Characteristic.LockCurrentState.UNKNOWN;
|
|
101578
101953
|
const target = status.state === "locked" || status.state === "locking" ? import_dist.Characteristic.LockTargetState.SECURED : status.state === "unlocked" || status.state === "unlocking" ? import_dist.Characteristic.LockTargetState.UNSECURED : null;
|
|
@@ -101588,7 +101963,7 @@ async function buildLockMechanism(bctx) {
|
|
|
101588
101963
|
const { ctx, accessory, proxy, numericDeviceId, displayName } = bctx;
|
|
101589
101964
|
const log = ctx.logger.withTags({ deviceId: numericDeviceId });
|
|
101590
101965
|
const label = hapServiceName([displayName], `Lock ${numericDeviceId}`);
|
|
101591
|
-
const service = accessory.addService(import_dist.Service.LockMechanism, label, SUBTYPE);
|
|
101966
|
+
const service = accessory.addService(import_dist.Service.LockMechanism, label, SUBTYPE$1);
|
|
101592
101967
|
applyServiceLabel(service, label);
|
|
101593
101968
|
const apply = (status, source) => {
|
|
101594
101969
|
const updates = readLock(status);
|
|
@@ -101602,7 +101977,7 @@ async function buildLockMechanism(bctx) {
|
|
|
101602
101977
|
const status = await proxy.lockControl?.getStatus({});
|
|
101603
101978
|
if (status !== void 0 && status !== null) apply(status, "getStatus");
|
|
101604
101979
|
} catch (err) {
|
|
101605
|
-
log.debug("export-hap: lock getStatus hydrate failed (non-fatal)", { meta: { error: errMsg$
|
|
101980
|
+
log.debug("export-hap: lock getStatus hydrate failed (non-fatal)", { meta: { error: errMsg$4(err) } });
|
|
101606
101981
|
}
|
|
101607
101982
|
service.getCharacteristic(import_dist.Characteristic.LockTargetState).onSet(async (value) => {
|
|
101608
101983
|
const secure = value === import_dist.Characteristic.LockTargetState.SECURED;
|
|
@@ -101612,7 +101987,7 @@ async function buildLockMechanism(bctx) {
|
|
|
101612
101987
|
} catch (err) {
|
|
101613
101988
|
log.warn("export-hap: lock command failed", { meta: {
|
|
101614
101989
|
secure,
|
|
101615
|
-
error: errMsg$
|
|
101990
|
+
error: errMsg$4(err)
|
|
101616
101991
|
} });
|
|
101617
101992
|
}
|
|
101618
101993
|
});
|
|
@@ -101626,6 +102001,296 @@ async function buildLockMechanism(bctx) {
|
|
|
101626
102001
|
} catch {}
|
|
101627
102002
|
} };
|
|
101628
102003
|
}
|
|
102004
|
+
function errMsg$4(err) {
|
|
102005
|
+
return err instanceof Error ? err.message : String(err);
|
|
102006
|
+
}
|
|
102007
|
+
//#endregion
|
|
102008
|
+
//#region src/mappers/builders/generic/security-state.ts
|
|
102009
|
+
/** Is this a settled arm state worth remembering? */
|
|
102010
|
+
function armedMemoOf(state) {
|
|
102011
|
+
return state === "armed_home" || state === "armed_away" || state === "armed_night" || state === "armed_vacation" || state === "armed_custom_bypass" ? state : null;
|
|
102012
|
+
}
|
|
102013
|
+
function currentForArmed(state) {
|
|
102014
|
+
switch (state) {
|
|
102015
|
+
case "armed_home":
|
|
102016
|
+
case "armed_custom_bypass": return import_dist.Characteristic.SecuritySystemCurrentState.STAY_ARM;
|
|
102017
|
+
case "armed_night": return import_dist.Characteristic.SecuritySystemCurrentState.NIGHT_ARM;
|
|
102018
|
+
default: return import_dist.Characteristic.SecuritySystemCurrentState.AWAY_ARM;
|
|
102019
|
+
}
|
|
102020
|
+
}
|
|
102021
|
+
function targetForArmed(state) {
|
|
102022
|
+
switch (state) {
|
|
102023
|
+
case "armed_home":
|
|
102024
|
+
case "armed_custom_bypass": return import_dist.Characteristic.SecuritySystemTargetState.STAY_ARM;
|
|
102025
|
+
case "armed_night": return import_dist.Characteristic.SecuritySystemTargetState.NIGHT_ARM;
|
|
102026
|
+
default: return import_dist.Characteristic.SecuritySystemTargetState.AWAY_ARM;
|
|
102027
|
+
}
|
|
102028
|
+
}
|
|
102029
|
+
function securityStateFor(state, memo) {
|
|
102030
|
+
const settled = armedMemoOf(state);
|
|
102031
|
+
if (settled !== null) return {
|
|
102032
|
+
current: currentForArmed(settled),
|
|
102033
|
+
target: targetForArmed(settled)
|
|
102034
|
+
};
|
|
102035
|
+
switch (state) {
|
|
102036
|
+
case "disarmed": return {
|
|
102037
|
+
current: import_dist.Characteristic.SecuritySystemCurrentState.DISARMED,
|
|
102038
|
+
target: import_dist.Characteristic.SecuritySystemTargetState.DISARM
|
|
102039
|
+
};
|
|
102040
|
+
case "arming": return {
|
|
102041
|
+
current: import_dist.Characteristic.SecuritySystemCurrentState.DISARMED,
|
|
102042
|
+
target: memo === null ? null : targetForArmed(memo)
|
|
102043
|
+
};
|
|
102044
|
+
case "disarming": return {
|
|
102045
|
+
current: memo === null ? import_dist.Characteristic.SecuritySystemCurrentState.DISARMED : currentForArmed(memo),
|
|
102046
|
+
target: import_dist.Characteristic.SecuritySystemTargetState.DISARM
|
|
102047
|
+
};
|
|
102048
|
+
case "pending": return {
|
|
102049
|
+
current: memo === null ? import_dist.Characteristic.SecuritySystemCurrentState.DISARMED : currentForArmed(memo),
|
|
102050
|
+
target: memo === null ? null : targetForArmed(memo)
|
|
102051
|
+
};
|
|
102052
|
+
default: return {
|
|
102053
|
+
current: import_dist.Characteristic.SecuritySystemCurrentState.ALARM_TRIGGERED,
|
|
102054
|
+
target: memo === null ? null : targetForArmed(memo)
|
|
102055
|
+
};
|
|
102056
|
+
}
|
|
102057
|
+
}
|
|
102058
|
+
/**
|
|
102059
|
+
* The arm mode behind a HomeKit target, or `null` for DISARM and for anything
|
|
102060
|
+
* outside the four values HomeKit defines.
|
|
102061
|
+
*
|
|
102062
|
+
* `null` is not an error the caller can ignore: DISARM is a different COMMAND,
|
|
102063
|
+
* and a value HomeKit never sends is a write this builder refuses to translate.
|
|
102064
|
+
*/
|
|
102065
|
+
function alarmArmModeFor(target) {
|
|
102066
|
+
switch (target) {
|
|
102067
|
+
case import_dist.Characteristic.SecuritySystemTargetState.STAY_ARM: return "home";
|
|
102068
|
+
case import_dist.Characteristic.SecuritySystemTargetState.AWAY_ARM: return "away";
|
|
102069
|
+
case import_dist.Characteristic.SecuritySystemTargetState.NIGHT_ARM: return "night";
|
|
102070
|
+
default: return null;
|
|
102071
|
+
}
|
|
102072
|
+
}
|
|
102073
|
+
//#endregion
|
|
102074
|
+
//#region src/mappers/builders/generic/security-target.ts
|
|
102075
|
+
/**
|
|
102076
|
+
* The panel modes behind each HomeKit target, PRIMARY first.
|
|
102077
|
+
*
|
|
102078
|
+
* The primary is the mode `alarmArmModeFor` names; the secondary is the other
|
|
102079
|
+
* mode `security-state.ts` reports through the same HomeKit value, so the two
|
|
102080
|
+
* modules agree in both directions by construction.
|
|
102081
|
+
*/
|
|
102082
|
+
var MODES_BY_TARGET = new Map([
|
|
102083
|
+
[import_dist.Characteristic.SecuritySystemTargetState.STAY_ARM, ["home", "custom_bypass"]],
|
|
102084
|
+
[import_dist.Characteristic.SecuritySystemTargetState.AWAY_ARM, ["away", "vacation"]],
|
|
102085
|
+
[import_dist.Characteristic.SecuritySystemTargetState.NIGHT_ARM, ["night"]]
|
|
102086
|
+
]);
|
|
102087
|
+
/** Arm targets in the order HomeKit numbers them; DISARM is appended last. */
|
|
102088
|
+
var ARM_TARGETS = [
|
|
102089
|
+
import_dist.Characteristic.SecuritySystemTargetState.STAY_ARM,
|
|
102090
|
+
import_dist.Characteristic.SecuritySystemTargetState.AWAY_ARM,
|
|
102091
|
+
import_dist.Characteristic.SecuritySystemTargetState.NIGHT_ARM
|
|
102092
|
+
];
|
|
102093
|
+
/**
|
|
102094
|
+
* The `validValues` for `SecuritySystemTargetState`, or `null` to leave
|
|
102095
|
+
* HomeKit's own four values in place.
|
|
102096
|
+
*
|
|
102097
|
+
* DISARM is always present: disarming is not one of the panel's arm modes and
|
|
102098
|
+
* a panel that cannot be disarmed is not a thing this cap can express.
|
|
102099
|
+
*/
|
|
102100
|
+
function targetValidValuesFor(availableModes) {
|
|
102101
|
+
if (availableModes.length === 0) return null;
|
|
102102
|
+
return [...ARM_TARGETS.filter((target) => (MODES_BY_TARGET.get(target) ?? []).some((mode) => availableModes.includes(mode))), import_dist.Characteristic.SecuritySystemTargetState.DISARM];
|
|
102103
|
+
}
|
|
102104
|
+
/**
|
|
102105
|
+
* The arm mode to send for a HomeKit target, or `null` when there is none.
|
|
102106
|
+
*
|
|
102107
|
+
* `null` is not a shrug the caller may swallow: DISARM is a different command,
|
|
102108
|
+
* and an arm target the panel accepts no mode for is a write this module
|
|
102109
|
+
* refuses to translate rather than guess at.
|
|
102110
|
+
*/
|
|
102111
|
+
function armModeForTarget(target, availableModes) {
|
|
102112
|
+
const primary = alarmArmModeFor(target);
|
|
102113
|
+
if (primary === null) return null;
|
|
102114
|
+
if (availableModes.length === 0) return primary;
|
|
102115
|
+
return (MODES_BY_TARGET.get(target) ?? [primary]).find((mode) => availableModes.includes(mode)) ?? null;
|
|
102116
|
+
}
|
|
102117
|
+
//#endregion
|
|
102118
|
+
//#region src/mappers/builders/generic/security-system.ts
|
|
102119
|
+
/**
|
|
102120
|
+
* `alarm-panel` → `Service.SecuritySystem`.
|
|
102121
|
+
*
|
|
102122
|
+
* The lock builder's shape (a current/target pair, a hydrate, an `onSet`, a
|
|
102123
|
+
* slice subscription, a dispose) applied to the one device on the fleet where
|
|
102124
|
+
* reporting a state that is not true has a consequence worse than a stalled
|
|
102125
|
+
* motor. The mapping itself is NOT here: `security-state.ts` owns what the
|
|
102126
|
+
* panel's state looks like to HomeKit and `security-target.ts` owns what
|
|
102127
|
+
* HomeKit may ask for, both pure and both tested on their own. This file is
|
|
102128
|
+
* the service around them.
|
|
102129
|
+
*
|
|
102130
|
+
* ## The memo
|
|
102131
|
+
*
|
|
102132
|
+
* `pending`, `disarming` and `triggered` do not carry the mode the panel was
|
|
102133
|
+
* armed to — only the last settled state knows it. This builder is the caller
|
|
102134
|
+
* `security-state.ts` describes: it remembers the last settled arm and forgets
|
|
102135
|
+
* it on `disarmed`, because a memo that outlives a disarm makes the next
|
|
102136
|
+
* `arming` claim a target nobody asked for.
|
|
102137
|
+
*
|
|
102138
|
+
* The memo is deliberately NOT seeded from the controller's own write. HomeKit
|
|
102139
|
+
* already holds the target the operator just set; not writing it back is
|
|
102140
|
+
* exactly right. The cost is a panel armed from its own keypad during an exit
|
|
102141
|
+
* delay, where the target stays at whatever HomeKit last knew — a stale target
|
|
102142
|
+
* for the length of the delay, against inventing an intent, and the invention
|
|
102143
|
+
* is worse.
|
|
102144
|
+
*
|
|
102145
|
+
* ## `requiresCode`: the arm is REFUSED, not attempted
|
|
102146
|
+
*
|
|
102147
|
+
* HomeKit's SecuritySystem has no PIN prompt — there is no characteristic for
|
|
102148
|
+
* it and no way to ask the operator mid-write. So a panel that requires a code
|
|
102149
|
+
* cannot be armed or disarmed from the Home app, and this builder says so
|
|
102150
|
+
* twice: the write fails with `INSUFFICIENT_AUTHORIZATION` (iOS renders the
|
|
102151
|
+
* tile's failure) and a WARN names the device, the command and the mode.
|
|
102152
|
+
*
|
|
102153
|
+
* Sending the command code-less and letting the panel reject it was the
|
|
102154
|
+
* alternative. It is worse: the refusal costs a round trip, it is
|
|
102155
|
+
* indistinguishable from a broken panel in the log, and repeated code-less
|
|
102156
|
+
* attempts are what locks a real alarm panel out.
|
|
102157
|
+
*/
|
|
102158
|
+
var SUBTYPE = "alarm-panel";
|
|
102159
|
+
/** The subset of the status this builder reads. */
|
|
102160
|
+
var PanelReadSchema = AlarmPanelStatusSchema.pick({
|
|
102161
|
+
state: true,
|
|
102162
|
+
availableModes: true,
|
|
102163
|
+
requiresCode: true
|
|
102164
|
+
});
|
|
102165
|
+
/**
|
|
102166
|
+
* Turn a panel status into characteristic writes, folding the memo.
|
|
102167
|
+
*
|
|
102168
|
+
* A payload that does not match the cap's own schema yields NO updates and
|
|
102169
|
+
* leaves the memo alone — it is a status we could not read, not a panel that
|
|
102170
|
+
* changed. The caller logs the drop; a frozen characteristic is otherwise
|
|
102171
|
+
* indistinguishable from a quiet panel.
|
|
102172
|
+
*/
|
|
102173
|
+
function securityUpdatesFor(status, memo) {
|
|
102174
|
+
const parsed = PanelReadSchema.safeParse(status);
|
|
102175
|
+
if (!parsed.success) return {
|
|
102176
|
+
updates: [],
|
|
102177
|
+
memo,
|
|
102178
|
+
panel: null
|
|
102179
|
+
};
|
|
102180
|
+
const nextMemo = parsed.data.state === "disarmed" ? null : armedMemoOf(parsed.data.state) ?? memo;
|
|
102181
|
+
const { current, target } = securityStateFor(parsed.data.state, nextMemo);
|
|
102182
|
+
return {
|
|
102183
|
+
updates: [{
|
|
102184
|
+
characteristic: import_dist.Characteristic.SecuritySystemCurrentState,
|
|
102185
|
+
value: current
|
|
102186
|
+
}, ...target === null ? [] : [{
|
|
102187
|
+
characteristic: import_dist.Characteristic.SecuritySystemTargetState,
|
|
102188
|
+
value: target
|
|
102189
|
+
}]],
|
|
102190
|
+
memo: nextMemo,
|
|
102191
|
+
panel: {
|
|
102192
|
+
availableModes: parsed.data.availableModes,
|
|
102193
|
+
requiresCode: parsed.data.requiresCode
|
|
102194
|
+
}
|
|
102195
|
+
};
|
|
102196
|
+
}
|
|
102197
|
+
async function buildSecuritySystem(bctx) {
|
|
102198
|
+
const { ctx, accessory, proxy, numericDeviceId, displayName } = bctx;
|
|
102199
|
+
const log = ctx.logger.withTags({ deviceId: numericDeviceId });
|
|
102200
|
+
const label = hapServiceName([displayName], `Alarm ${numericDeviceId}`);
|
|
102201
|
+
const service = accessory.addService(import_dist.Service.SecuritySystem, label, SUBTYPE);
|
|
102202
|
+
applyServiceLabel(service, label);
|
|
102203
|
+
let memo = null;
|
|
102204
|
+
let availableModes = [];
|
|
102205
|
+
let requiresCode = false;
|
|
102206
|
+
/** Only log the `validValues` narrowing when it actually changes. */
|
|
102207
|
+
let lastValidValues = "";
|
|
102208
|
+
const applyValidValues = () => {
|
|
102209
|
+
const validValues = targetValidValuesFor(availableModes);
|
|
102210
|
+
if (validValues === null) {
|
|
102211
|
+
if (lastValidValues !== "unconstrained") {
|
|
102212
|
+
lastValidValues = "unconstrained";
|
|
102213
|
+
log.info("export-hap: alarm panel named no arm modes — leaving HomeKit’s targets unconstrained", { meta: { subtype: SUBTYPE } });
|
|
102214
|
+
}
|
|
102215
|
+
return;
|
|
102216
|
+
}
|
|
102217
|
+
const key = validValues.join(",");
|
|
102218
|
+
if (key === lastValidValues) return;
|
|
102219
|
+
lastValidValues = key;
|
|
102220
|
+
service.getCharacteristic(import_dist.Characteristic.SecuritySystemTargetState).setProps({ validValues: [...validValues] });
|
|
102221
|
+
log.info("export-hap: alarm panel target constrained to the modes it accepts", { meta: {
|
|
102222
|
+
subtype: SUBTYPE,
|
|
102223
|
+
availableModes: [...availableModes],
|
|
102224
|
+
validValues
|
|
102225
|
+
} });
|
|
102226
|
+
};
|
|
102227
|
+
const apply = (status, source) => {
|
|
102228
|
+
const next = securityUpdatesFor(status, memo);
|
|
102229
|
+
if (next.updates.length === 0) {
|
|
102230
|
+
log.debug("export-hap: alarm panel status did not match the cap schema — no update", { meta: {
|
|
102231
|
+
subtype: SUBTYPE,
|
|
102232
|
+
source
|
|
102233
|
+
} });
|
|
102234
|
+
return;
|
|
102235
|
+
}
|
|
102236
|
+
memo = next.memo;
|
|
102237
|
+
if (next.panel !== null) {
|
|
102238
|
+
availableModes = next.panel.availableModes;
|
|
102239
|
+
requiresCode = next.panel.requiresCode;
|
|
102240
|
+
applyValidValues();
|
|
102241
|
+
}
|
|
102242
|
+
applyUpdates(service, next.updates);
|
|
102243
|
+
};
|
|
102244
|
+
try {
|
|
102245
|
+
const status = await proxy.alarmPanel?.getStatus({});
|
|
102246
|
+
if (status !== void 0 && status !== null) apply(status, "getStatus");
|
|
102247
|
+
} catch (err) {
|
|
102248
|
+
log.debug("export-hap: alarm panel getStatus hydrate failed (non-fatal)", { meta: { error: errMsg$3(err) } });
|
|
102249
|
+
}
|
|
102250
|
+
service.getCharacteristic(import_dist.Characteristic.SecuritySystemTargetState).onSet(async (value) => {
|
|
102251
|
+
const target = typeof value === "number" ? value : Number(value);
|
|
102252
|
+
const disarm = target === import_dist.Characteristic.SecuritySystemTargetState.DISARM;
|
|
102253
|
+
const mode = disarm ? null : armModeForTarget(target, availableModes);
|
|
102254
|
+
if (requiresCode) {
|
|
102255
|
+
log.warn("export-hap: alarm panel requires a PIN — HomeKit cannot supply one, command REFUSED", { meta: {
|
|
102256
|
+
subtype: SUBTYPE,
|
|
102257
|
+
command: disarm ? "disarm" : "arm",
|
|
102258
|
+
mode,
|
|
102259
|
+
target
|
|
102260
|
+
} });
|
|
102261
|
+
throw new import_dist.HapStatusError(import_dist.HAPStatus.INSUFFICIENT_AUTHORIZATION);
|
|
102262
|
+
}
|
|
102263
|
+
if (!disarm && mode === null) {
|
|
102264
|
+
log.warn("export-hap: alarm panel cannot honour this HomeKit arm target — REFUSED", { meta: {
|
|
102265
|
+
subtype: SUBTYPE,
|
|
102266
|
+
target,
|
|
102267
|
+
availableModes: [...availableModes]
|
|
102268
|
+
} });
|
|
102269
|
+
throw new import_dist.HapStatusError(import_dist.HAPStatus.INVALID_VALUE_IN_REQUEST);
|
|
102270
|
+
}
|
|
102271
|
+
try {
|
|
102272
|
+
if (mode === null) await proxy.alarmPanel?.disarm({});
|
|
102273
|
+
else await proxy.alarmPanel?.arm({ mode });
|
|
102274
|
+
} catch (err) {
|
|
102275
|
+
log.warn("export-hap: alarm panel command failed", { meta: {
|
|
102276
|
+
subtype: SUBTYPE,
|
|
102277
|
+
command: mode === null ? "disarm" : "arm",
|
|
102278
|
+
mode,
|
|
102279
|
+
error: errMsg$3(err)
|
|
102280
|
+
} });
|
|
102281
|
+
throw new import_dist.HapStatusError(import_dist.HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
102282
|
+
}
|
|
102283
|
+
});
|
|
102284
|
+
const unsubscribe = proxy.state.alarmPanel?.subscribe((value) => {
|
|
102285
|
+
if (value === void 0 || value === null) return;
|
|
102286
|
+
apply(value, "slice");
|
|
102287
|
+
}) ?? null;
|
|
102288
|
+
return { async dispose() {
|
|
102289
|
+
try {
|
|
102290
|
+
unsubscribe?.();
|
|
102291
|
+
} catch {}
|
|
102292
|
+
} };
|
|
102293
|
+
}
|
|
101629
102294
|
function errMsg$3(err) {
|
|
101630
102295
|
return err instanceof Error ? err.message : String(err);
|
|
101631
102296
|
}
|
|
@@ -101700,11 +102365,16 @@ function errMsg$2(err) {
|
|
|
101700
102365
|
*
|
|
101701
102366
|
* ## Tier
|
|
101702
102367
|
*
|
|
101703
|
-
* Tier A
|
|
101704
|
-
* feature-dependent shape
|
|
101705
|
-
*
|
|
101706
|
-
*
|
|
101707
|
-
*
|
|
102368
|
+
* Tier A, plus `alarm-panel`: the caps whose HomeKit service exists today and
|
|
102369
|
+
* needs no feature-dependent shape. `cover` still needs `cover-positionable`
|
|
102370
|
+
* and `climate-control` the dual-setpoint split; those are a separate task,
|
|
102371
|
+
* and adding a row here must never mean adding a service whose semantics this
|
|
102372
|
+
* file cannot fully honour.
|
|
102373
|
+
*
|
|
102374
|
+
* `alarm-panel` earned its row by answering the two questions that kept it
|
|
102375
|
+
* out: a target the panel would refuse is never offered (`availableModes` →
|
|
102376
|
+
* `validValues`, `security-target.ts`) and an arm a PIN-gated panel cannot
|
|
102377
|
+
* accept is refused out loud rather than attempted (`security-system.ts`).
|
|
101708
102378
|
*/
|
|
101709
102379
|
/** HomeKit's floor for `CurrentAmbientLightLevel`; 0 lux is out of range. */
|
|
101710
102380
|
var MIN_LUX = 1e-4;
|
|
@@ -101846,6 +102516,14 @@ var HAP_CAP_SERVICES = [
|
|
|
101846
102516
|
displayName: name
|
|
101847
102517
|
})
|
|
101848
102518
|
},
|
|
102519
|
+
{
|
|
102520
|
+
caps: ["alarm-panel"],
|
|
102521
|
+
label: "Alarm",
|
|
102522
|
+
build: ({ bctx, name }) => buildSecuritySystem({
|
|
102523
|
+
...bctx,
|
|
102524
|
+
displayName: name
|
|
102525
|
+
})
|
|
102526
|
+
},
|
|
101849
102527
|
{
|
|
101850
102528
|
caps: ["battery"],
|
|
101851
102529
|
label: BATTERY_SPEC.label,
|
|
@@ -101883,7 +102561,8 @@ var ACCESSORY_CATEGORY_BY_TYPE = {
|
|
|
101883
102561
|
[DeviceType.Siren]: import_dist.Categories.SWITCH,
|
|
101884
102562
|
[DeviceType.Lock]: import_dist.Categories.DOOR_LOCK,
|
|
101885
102563
|
[DeviceType.Sensor]: import_dist.Categories.SENSOR,
|
|
101886
|
-
[DeviceType.Presence]: import_dist.Categories.SENSOR
|
|
102564
|
+
[DeviceType.Presence]: import_dist.Categories.SENSOR,
|
|
102565
|
+
[DeviceType.AlarmPanel]: import_dist.Categories.SECURITY_SYSTEM
|
|
101887
102566
|
};
|
|
101888
102567
|
function accessoryCategoryFor(deviceType) {
|
|
101889
102568
|
return ACCESSORY_CATEGORY_BY_TYPE[deviceType] ?? import_dist.Categories.OTHER;
|
|
@@ -102268,6 +102947,12 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102268
102947
|
* hardware init.
|
|
102269
102948
|
*/
|
|
102270
102949
|
decodeMemos = createHapDecodeMemos();
|
|
102950
|
+
/**
|
|
102951
|
+
* THE bridge. Lazily created and published the first time a non-camera
|
|
102952
|
+
* accessory needs it; never torn down while the addon runs, because an
|
|
102953
|
+
* unpublish would drop a pairing the operator already entered a code for.
|
|
102954
|
+
*/
|
|
102955
|
+
bridgeHost = null;
|
|
102271
102956
|
constructor() {
|
|
102272
102957
|
super({ ...DEFAULT_CONFIG });
|
|
102273
102958
|
}
|
|
@@ -102275,6 +102960,13 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102275
102960
|
const identity = await this.ensureIdentity();
|
|
102276
102961
|
this.pincode = identity.pincode;
|
|
102277
102962
|
this.bind = this.config.interfaceName || void 0;
|
|
102963
|
+
this.bridgeHost = new BridgeHost({
|
|
102964
|
+
displayName: this.config.bridgeName,
|
|
102965
|
+
uuid: identity.uuid,
|
|
102966
|
+
pincode: identity.pincode,
|
|
102967
|
+
bind: this.bind,
|
|
102968
|
+
logger: this.ctx.logger
|
|
102969
|
+
});
|
|
102278
102970
|
try {
|
|
102279
102971
|
await initHapStorage(node_path.join(this.ctx.dataDir, "hap-store"));
|
|
102280
102972
|
} catch (err) {
|
|
@@ -102303,6 +102995,7 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102303
102995
|
}
|
|
102304
102996
|
this.ctx.addDisposer(async () => {
|
|
102305
102997
|
await this.detachAll();
|
|
102998
|
+
await this.bridgeHost?.dispose();
|
|
102306
102999
|
});
|
|
102307
103000
|
this.subscribeDeviceProvisionedForReconcile();
|
|
102308
103001
|
this.subscribeDeviceReadyForReconcile();
|
|
@@ -102459,16 +103152,24 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102459
103152
|
decodeMemos: this.decodeMemos,
|
|
102460
103153
|
hapDeviceSettings: {
|
|
102461
103154
|
streamPreference: entrySettings.streamPreference ?? "auto",
|
|
102462
|
-
hksvRecording: resolveHksvRecording(entrySettings)
|
|
103155
|
+
hksvRecording: resolveHksvRecording(entrySettings),
|
|
103156
|
+
allowTranscode: entrySettings.allowTranscode !== false
|
|
102463
103157
|
}
|
|
102464
103158
|
}
|
|
102465
103159
|
});
|
|
102466
|
-
|
|
102467
|
-
|
|
102468
|
-
|
|
102469
|
-
bind: this.bind,
|
|
102470
|
-
logger: this.ctx.logger
|
|
103160
|
+
const wantsBridge = shouldBridge({
|
|
103161
|
+
mapperKind: entry.mapperKind,
|
|
103162
|
+
useBridge: entry.settings?.useBridge
|
|
102471
103163
|
});
|
|
103164
|
+
for (const accessory of mapper.accessories) {
|
|
103165
|
+
if (wantsBridge && this.bridgeHost !== null && await this.bridgeHost.add(accessory)) continue;
|
|
103166
|
+
await publishStandalone(accessory, {
|
|
103167
|
+
pincode: this.pincode,
|
|
103168
|
+
port: 0,
|
|
103169
|
+
bind: this.bind,
|
|
103170
|
+
logger: this.ctx.logger
|
|
103171
|
+
});
|
|
103172
|
+
}
|
|
102472
103173
|
this.exposed.set(entry.deviceId, mapper);
|
|
102473
103174
|
return { childAccessoryUuids: [] };
|
|
102474
103175
|
}
|
|
@@ -102481,7 +103182,13 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102481
103182
|
const mapper = this.exposed.get(deviceId);
|
|
102482
103183
|
if (!mapper) return;
|
|
102483
103184
|
this.exposed.delete(deviceId);
|
|
102484
|
-
for (const accessory of mapper.accessories)
|
|
103185
|
+
for (const accessory of mapper.accessories) {
|
|
103186
|
+
if (this.bridgeHost?.holds(accessory) === true) {
|
|
103187
|
+
this.bridgeHost.remove(accessory);
|
|
103188
|
+
continue;
|
|
103189
|
+
}
|
|
103190
|
+
await unpublishAccessory(accessory, this.ctx.logger);
|
|
103191
|
+
}
|
|
102485
103192
|
await mapper.dispose().catch((err) => {
|
|
102486
103193
|
this.ctx.logger.withTags({ deviceId: Number.parseInt(deviceId, 10) }).warn("export-hap: mapper dispose failed", { meta: { error: errMsg(err) } });
|
|
102487
103194
|
});
|
|
@@ -102776,42 +103483,79 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102776
103483
|
const enabledKey = `hap:${deviceId}:enabled`;
|
|
102777
103484
|
const streamPreferenceKey = `hap:${deviceId}:streamPreference`;
|
|
102778
103485
|
const hksvKey = `hap:${deviceId}:hksvRecording`;
|
|
103486
|
+
const useBridgeKey = `hap:${deviceId}:useBridge`;
|
|
103487
|
+
const allowTranscodeKey = `hap:${deviceId}:allowTranscode`;
|
|
102779
103488
|
const mapper = this.exposed.get(String(deviceId)) ?? null;
|
|
102780
103489
|
const paired = mapper ? accessoryPaired(mapper.accessory) : false;
|
|
103490
|
+
const bridged = mapper !== null && this.bridgeHost?.holds(mapper.accessory) === true;
|
|
102781
103491
|
const name = entry?.displayName ?? `Device ${deviceId}`;
|
|
102782
|
-
const
|
|
103492
|
+
const bridgePaired = this.bridgeHost?.accessory !== null && this.bridgeHost?.accessory !== void 0 ? accessoryPaired(this.bridgeHost.accessory) : false;
|
|
103493
|
+
const statusLabel = !enabled ? "Not exposed" : bridged ? bridgePaired ? `On the “${this.config.bridgeName}” bridge, as “${name}”` : `On the “${this.config.bridgeName}” bridge, as “${name}” — the BRIDGE is not paired yet. In iOS Home: + → Add Accessory → “${this.config.bridgeName}”, then enter setup code ${this.config.identity.pincode}. Every bridged device arrives with it.` : paired ? `Paired — exposed as “${name}”` : `Exposed as “${name}” — not paired yet. In iOS Home: + → Add Accessory → “${name}”, then enter setup code ${this.config.identity.pincode}.`;
|
|
103494
|
+
const qrSource = bridged ? this.bridgeHost?.accessory ?? null : mapper?.accessory ?? null;
|
|
102783
103495
|
let qrValue = "";
|
|
102784
|
-
if (
|
|
102785
|
-
qrValue =
|
|
103496
|
+
if (qrSource) try {
|
|
103497
|
+
qrValue = qrSource.setupURI();
|
|
102786
103498
|
} catch (err) {
|
|
102787
103499
|
this.ctx.logger.withTags({ deviceId }).debug("export-hap: setupURI failed for per-device contribution", { meta: { error: errMsg(err) } });
|
|
102788
103500
|
}
|
|
102789
|
-
const
|
|
102790
|
-
type: "select",
|
|
102791
|
-
key: streamPreferenceKey,
|
|
102792
|
-
label: "Source stream (HomeKit)",
|
|
102793
|
-
description: "Which camstack profile slot HomeKit pulls. Auto = the broker picks the slot closest to 1080p at session start.",
|
|
102794
|
-
options: HAP_STREAM_PREFERENCE_OPTIONS,
|
|
102795
|
-
required: true,
|
|
102796
|
-
value: settings.streamPreference,
|
|
102797
|
-
showWhen: {
|
|
102798
|
-
field: enabledKey,
|
|
102799
|
-
equals: true
|
|
102800
|
-
},
|
|
102801
|
-
immediate: true
|
|
102802
|
-
}, {
|
|
103501
|
+
const bridgeFields = kind === "camera" ? [] : [{
|
|
102803
103502
|
type: "boolean",
|
|
102804
|
-
key:
|
|
102805
|
-
label: "
|
|
102806
|
-
description: "
|
|
103503
|
+
key: useBridgeKey,
|
|
103504
|
+
label: "Export through the bridge",
|
|
103505
|
+
description: "Publish this device inside the shared CamStack bridge — one pairing and one entry in Add Accessory for every non-camera device, instead of one each. Turning this off gives it its own advertisement. Either way the switch REBUILDS the accessory and it must be added to the Home app again.",
|
|
102807
103506
|
style: "switch",
|
|
102808
|
-
value:
|
|
103507
|
+
value: shouldBridge({
|
|
103508
|
+
mapperKind: kind,
|
|
103509
|
+
useBridge: settings.useBridge
|
|
103510
|
+
}),
|
|
102809
103511
|
showWhen: {
|
|
102810
103512
|
field: enabledKey,
|
|
102811
103513
|
equals: true
|
|
102812
103514
|
},
|
|
102813
103515
|
immediate: true
|
|
102814
103516
|
}];
|
|
103517
|
+
const cameraFields = kind !== "camera" ? [] : [
|
|
103518
|
+
{
|
|
103519
|
+
type: "select",
|
|
103520
|
+
key: streamPreferenceKey,
|
|
103521
|
+
label: "Source stream (HomeKit)",
|
|
103522
|
+
description: "Which camstack profile slot HomeKit pulls. Auto = the broker picks the slot closest to 1080p at session start.",
|
|
103523
|
+
options: HAP_STREAM_PREFERENCE_OPTIONS,
|
|
103524
|
+
required: true,
|
|
103525
|
+
value: settings.streamPreference,
|
|
103526
|
+
showWhen: {
|
|
103527
|
+
field: enabledKey,
|
|
103528
|
+
equals: true
|
|
103529
|
+
},
|
|
103530
|
+
immediate: true
|
|
103531
|
+
},
|
|
103532
|
+
{
|
|
103533
|
+
type: "boolean",
|
|
103534
|
+
key: hksvKey,
|
|
103535
|
+
label: "HomeKit recording (Secure Video)",
|
|
103536
|
+
description: "Offer “Stream and Allow Recording” in iOS Home. Requires iCloud+ and a home hub. Keeps a continuous 8s prebuffer for this camera (~0.7% of one CPU core, H.264 sources only).",
|
|
103537
|
+
style: "switch",
|
|
103538
|
+
value: resolveHksvRecording(settings),
|
|
103539
|
+
showWhen: {
|
|
103540
|
+
field: enabledKey,
|
|
103541
|
+
equals: true
|
|
103542
|
+
},
|
|
103543
|
+
immediate: true
|
|
103544
|
+
},
|
|
103545
|
+
{
|
|
103546
|
+
type: "boolean",
|
|
103547
|
+
key: allowTranscodeKey,
|
|
103548
|
+
label: "Allow transcoding for HomeKit",
|
|
103549
|
+
description: "Let the hub re-encode this camera when the resolution HomeKit negotiated cannot be served by a direct copy. Off means only a stream that can be forwarded as-is is offered — cheaper, but a session HomeKit negotiates outside what the camera publishes will be refused instead of transcoded.",
|
|
103550
|
+
style: "switch",
|
|
103551
|
+
value: settings.allowTranscode !== false,
|
|
103552
|
+
showWhen: {
|
|
103553
|
+
field: enabledKey,
|
|
103554
|
+
equals: true
|
|
103555
|
+
},
|
|
103556
|
+
immediate: true
|
|
103557
|
+
}
|
|
103558
|
+
];
|
|
102815
103559
|
return {
|
|
102816
103560
|
tabs: [{
|
|
102817
103561
|
id: "export",
|
|
@@ -102856,6 +103600,7 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102856
103600
|
value: enabled,
|
|
102857
103601
|
immediate: true
|
|
102858
103602
|
},
|
|
103603
|
+
...bridgeFields,
|
|
102859
103604
|
...cameraFields
|
|
102860
103605
|
]
|
|
102861
103606
|
}]
|
|
@@ -102881,14 +103626,20 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102881
103626
|
const enabledKey = `hap:${deviceId}:enabled`;
|
|
102882
103627
|
const streamPreferenceKey = `hap:${deviceId}:streamPreference`;
|
|
102883
103628
|
const hksvKey = `hap:${deviceId}:hksvRecording`;
|
|
103629
|
+
const useBridgeKey = `hap:${deviceId}:useBridge`;
|
|
103630
|
+
const allowTranscodeKey = `hap:${deviceId}:allowTranscode`;
|
|
102884
103631
|
const enabledValue = enabledKey in patch ? Boolean(patch[enabledKey]) : wasEnabled;
|
|
102885
103632
|
const streamPreferenceRaw = streamPreferenceKey in patch ? patch[streamPreferenceKey] : current?.settings?.streamPreference;
|
|
102886
103633
|
const streamPreference = typeof streamPreferenceRaw === "string" && streamPreferenceRaw.trim().length > 0 ? streamPreferenceRaw : "auto";
|
|
102887
103634
|
const hksvRecording = hksvKey in patch ? Boolean(patch[hksvKey]) : resolveHksvRecording(current?.settings);
|
|
103635
|
+
const useBridge = useBridgeKey in patch ? Boolean(patch[useBridgeKey]) : current?.settings?.useBridge !== false;
|
|
103636
|
+
const allowTranscode = allowTranscodeKey in patch ? Boolean(patch[allowTranscodeKey]) : current?.settings?.allowTranscode !== false;
|
|
102888
103637
|
const nextSettings = {
|
|
102889
103638
|
...current?.settings ?? DEFAULT_DEVICE_SETTINGS,
|
|
102890
103639
|
streamPreference,
|
|
102891
|
-
hksvRecording
|
|
103640
|
+
hksvRecording,
|
|
103641
|
+
useBridge,
|
|
103642
|
+
allowTranscode
|
|
102892
103643
|
};
|
|
102893
103644
|
if (!enabledValue) {
|
|
102894
103645
|
if (wasEnabled) await this.unexposeDevice(deviceIdStr);
|
|
@@ -102901,8 +103652,17 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102901
103652
|
}
|
|
102902
103653
|
const currentPref = current?.settings?.streamPreference ?? "auto";
|
|
102903
103654
|
const currentHksv = resolveHksvRecording(current?.settings);
|
|
103655
|
+
const mapperKind = current?.mapperKind ?? "generic";
|
|
103656
|
+
const wasBridged = shouldBridge({
|
|
103657
|
+
mapperKind,
|
|
103658
|
+
useBridge: current?.settings?.useBridge
|
|
103659
|
+
});
|
|
103660
|
+
const willBridge = shouldBridge({
|
|
103661
|
+
mapperKind,
|
|
103662
|
+
useBridge
|
|
103663
|
+
});
|
|
102904
103664
|
await this.updateEntrySettings(deviceIdStr, nextSettings);
|
|
102905
|
-
if (currentPref !== streamPreference || currentHksv !== hksvRecording) {
|
|
103665
|
+
if (currentPref !== streamPreference || currentHksv !== hksvRecording || wasBridged !== willBridge) {
|
|
102906
103666
|
log.info("export-hap: per-camera export settings changed — refreshing accessory", { meta: {
|
|
102907
103667
|
streamPreference: {
|
|
102908
103668
|
from: currentPref,
|
|
@@ -102911,10 +103671,14 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102911
103671
|
hksvRecording: {
|
|
102912
103672
|
from: currentHksv,
|
|
102913
103673
|
to: hksvRecording
|
|
103674
|
+
},
|
|
103675
|
+
bridged: {
|
|
103676
|
+
from: wasBridged,
|
|
103677
|
+
to: willBridge
|
|
102914
103678
|
}
|
|
102915
103679
|
} });
|
|
102916
103680
|
try {
|
|
102917
|
-
await this.unexposeDevice(deviceIdStr, { clearPairing:
|
|
103681
|
+
await this.unexposeDevice(deviceIdStr, { clearPairing: wasBridged !== willBridge });
|
|
102918
103682
|
await this.exposeDevice(deviceIdStr);
|
|
102919
103683
|
} catch (err) {
|
|
102920
103684
|
log.warn("export-hap: failed to refresh accessory after a settings change", { meta: { error: errMsg(err) } });
|