@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
|
@@ -72,7 +72,7 @@ function carryForward(base, existing, keys) {
|
|
|
72
72
|
return out;
|
|
73
73
|
}
|
|
74
74
|
//#endregion
|
|
75
|
-
//#region ../types/dist/event-category-
|
|
75
|
+
//#region ../types/dist/event-category-BVDXG4tB.mjs
|
|
76
76
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
77
77
|
EventCategory["SystemBoot"] = "system.boot";
|
|
78
78
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -689,6 +689,20 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
689
689
|
* pull-reconcile from the provider's `getStatus` on reconnect. */
|
|
690
690
|
EventCategory["MeshNetworkChanged"] = "network.mesh.changed";
|
|
691
691
|
EventCategory["BackupCompleted"] = "backup.completed";
|
|
692
|
+
/**
|
|
693
|
+
* A whole backup RUN finished — every destination attempted, win or lose.
|
|
694
|
+
*
|
|
695
|
+
* `backup.completed` fires once per DESTINATION, which is the right grain for
|
|
696
|
+
* a progress UI and the wrong one for a notification: an operator with three
|
|
697
|
+
* destinations would be told three times. And a run where two of three
|
|
698
|
+
* destinations succeeded is not a clean success — a single "backup
|
|
699
|
+
* completed" that hid the failed one would be a lie, so the count of each is
|
|
700
|
+
* carried here and the message says both.
|
|
701
|
+
*
|
|
702
|
+
* Emitted by the backup orchestrator only after the destination loop, so a
|
|
703
|
+
* run that dies during the BUILD phase produces no completion at all.
|
|
704
|
+
*/
|
|
705
|
+
EventCategory["BackupRunCompleted"] = "backup.run-completed";
|
|
692
706
|
EventCategory["BackupRestored"] = "backup.restored";
|
|
693
707
|
EventCategory["NotificationDispatched"] = "notification.dispatched";
|
|
694
708
|
EventCategory["NotificationFailed"] = "notification.failed";
|
|
@@ -5419,7 +5433,7 @@ var ZodIssueCode = {
|
|
|
5419
5433
|
var ZodFirstPartyTypeKind;
|
|
5420
5434
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5421
5435
|
//#endregion
|
|
5422
|
-
//#region ../types/dist/sleep-
|
|
5436
|
+
//#region ../types/dist/sleep-DEuj7E3j.mjs
|
|
5423
5437
|
/**
|
|
5424
5438
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5425
5439
|
* window to float samples (D455).
|
|
@@ -7420,7 +7434,7 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
7420
7434
|
input: unknown()
|
|
7421
7435
|
}), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
7422
7436
|
//#endregion
|
|
7423
|
-
//#region ../types/dist/canonical-hash-
|
|
7437
|
+
//#region ../types/dist/canonical-hash-Ch5bSjFG.mjs
|
|
7424
7438
|
var AUDIO_ENCODER_BY_CODEC = {
|
|
7425
7439
|
opus: "libopus",
|
|
7426
7440
|
aac: "aac",
|
|
@@ -7523,6 +7537,7 @@ function buildVideoArgs(video, outputArgs) {
|
|
|
7523
7537
|
];
|
|
7524
7538
|
if (video.preset !== void 0) args.push("-preset", video.preset);
|
|
7525
7539
|
if (video.tune !== void 0) args.push("-tune", video.tune);
|
|
7540
|
+
if (video.singleSlicePerFrame === true && video.encoder === "libx264") args.push("-x264-params", "sliced-threads=0");
|
|
7526
7541
|
if (video.profile !== void 0) args.push("-profile:v", video.profile);
|
|
7527
7542
|
if (video.level !== void 0) args.push("-level", video.level);
|
|
7528
7543
|
if (video.pixelFormat !== void 0) args.push("-pix_fmt", video.pixelFormat);
|
|
@@ -7924,7 +7939,7 @@ import { errMsg } from '@camstack/types'
|
|
|
7924
7939
|
* Extract a human-readable message from an unknown error value.
|
|
7925
7940
|
* Replaces the ubiquitous `errMsg(err)` pattern.
|
|
7926
7941
|
*/
|
|
7927
|
-
function errMsg$
|
|
7942
|
+
function errMsg$16(err) {
|
|
7928
7943
|
if (err instanceof Error) return err.message;
|
|
7929
7944
|
if (typeof err === "string") return err;
|
|
7930
7945
|
return String(err);
|
|
@@ -8001,7 +8016,23 @@ var EncodeProfileSchema = object({
|
|
|
8001
8016
|
"zerolatency",
|
|
8002
8017
|
"film",
|
|
8003
8018
|
"animation"
|
|
8004
|
-
]).optional()
|
|
8019
|
+
]).optional(),
|
|
8020
|
+
/**
|
|
8021
|
+
* ONE slice per access unit.
|
|
8022
|
+
*
|
|
8023
|
+
* `-tune zerolatency` turns on x264's sliced threads, and a frame then leaves
|
|
8024
|
+
* the encoder as five NAL slices that share one RTP timestamp and carry one
|
|
8025
|
+
* marker bit. A libwebrtc depacketiser sees five frame-starts and one
|
|
8026
|
+
* frame-end per frame: the first pictures render and the video then freezes
|
|
8027
|
+
* for good while the audio, on its own plane, plays on. Measured on this hub
|
|
8028
|
+
* 2026-09-13 against the Echo, and reduced to one slice by this flag alone.
|
|
8029
|
+
*
|
|
8030
|
+
* A NAMED field and not a raw flag, because {@link EgressEncodeSchema} omits
|
|
8031
|
+
* `outputArgs` on purpose: an opaque array is part of the sharing key, so two
|
|
8032
|
+
* consumers meaning the same thing spelled differently would stop sharing one
|
|
8033
|
+
* child. Absent means "whatever the encoder does" — today's behaviour.
|
|
8034
|
+
*/
|
|
8035
|
+
singleSlicePerFrame: boolean().optional()
|
|
8005
8036
|
}),
|
|
8006
8037
|
audio: union([literal("passthrough"), object({
|
|
8007
8038
|
codec: _enum([
|
|
@@ -8030,6 +8061,28 @@ var EncodeProfileSchema = object({
|
|
|
8030
8061
|
outputArgs: array(string()).optional()
|
|
8031
8062
|
});
|
|
8032
8063
|
/**
|
|
8064
|
+
* THE target rule: which of two sizes serves a consumer better.
|
|
8065
|
+
*
|
|
8066
|
+
* "Prefer at or above the target so the consumer downscales instead of
|
|
8067
|
+
* upscaling; among those the SMALLEST, because the extra pixels are thrown
|
|
8068
|
+
* away and the decode is not; among the rest the LARGEST, because it is the
|
|
8069
|
+
* closest we can get." One sentence, and until now it was written twice — once
|
|
8070
|
+
* here in lines, once in `stream-selection.ts` in pixels, for the same two
|
|
8071
|
+
* exporters. The two agreed, which is luck, not a property.
|
|
8072
|
+
*
|
|
8073
|
+
* The `size` is whatever measure the caller ranks by: the cap ranks by LINES
|
|
8074
|
+
* (a consumer's requirement is stated in p), the RTSP picker by PIXELS (it
|
|
8075
|
+
* compares entries of possibly different aspect). The rule is the same either
|
|
8076
|
+
* way and the measure is the caller's business.
|
|
8077
|
+
*
|
|
8078
|
+
* Returns a sort delta: negative when `a` should come first.
|
|
8079
|
+
*/
|
|
8080
|
+
function compareToTarget(a, b, target) {
|
|
8081
|
+
const aReaches = a >= target;
|
|
8082
|
+
if (aReaches !== b >= target) return aReaches ? -1 : 1;
|
|
8083
|
+
return aReaches ? a - b : b - a;
|
|
8084
|
+
}
|
|
8085
|
+
/**
|
|
8033
8086
|
* The shape every live egress starts from: H.264 Baseline 3.1 at 720p25.
|
|
8034
8087
|
* Baseline because it is the one profile every consumer in this repo decodes
|
|
8035
8088
|
* (Echo, iOS, an old browser); 3.1 because that is what the SDPs advertise.
|
|
@@ -8051,7 +8104,7 @@ var BASE_LIVE_EGRESS_PROFILE = {
|
|
|
8051
8104
|
audio: "passthrough"
|
|
8052
8105
|
};
|
|
8053
8106
|
({ ...BASE_LIVE_EGRESS_PROFILE }), { ...BASE_LIVE_EGRESS_PROFILE.video };
|
|
8054
|
-
({ ...BASE_LIVE_EGRESS_PROFILE });
|
|
8107
|
+
({ ...BASE_LIVE_EGRESS_PROFILE }), { ...BASE_LIVE_EGRESS_PROFILE.video };
|
|
8055
8108
|
/** VBV window for a consumer whose budget is enforced per second (HomeKit). */
|
|
8056
8109
|
var RATE_CONTROL_TIGHT = {
|
|
8057
8110
|
kind: "cbr",
|
|
@@ -9942,6 +9995,47 @@ var LogChannelWindowSchema = object({
|
|
|
9942
9995
|
/** `null` = every camera. A non-empty list narrows to those numeric ids. */
|
|
9943
9996
|
deviceIds: array(number().int()).readonly().nullable()
|
|
9944
9997
|
});
|
|
9998
|
+
/**
|
|
9999
|
+
* Shared stream-selection picker for export addons.
|
|
10000
|
+
*
|
|
10001
|
+
* Both `addon-export-alexa` and `addon-export-hap` resolve the
|
|
10002
|
+
* operator's `streamPreference` setting against the broker's RTSP
|
|
10003
|
+
* entries before dialling a camera. Each addon used to roll its own:
|
|
10004
|
+
* Alexa had `pickPreferredRtspEntry` under `handlers/`, HAP had an
|
|
10005
|
+
* inline `"prefer /mid, then /high, then first"` chain inside its
|
|
10006
|
+
* camera-streams mapper. The chains drifted (Alexa honoured
|
|
10007
|
+
* `streamPreference`, HAP didn't; only Alexa got the smart
|
|
10008
|
+
* resolution-targeted auto-pick) and the cross-addon import rule
|
|
10009
|
+
* blocks deduping in either direction.
|
|
10010
|
+
*
|
|
10011
|
+
* Lifting the picker into `@camstack/types` lets every exporter call
|
|
10012
|
+
* the same code path with the consumer's target resolution baked into
|
|
10013
|
+
* the call site — Alexa passes 1280×720, HomeKit passes 1920×1080,
|
|
10014
|
+
* the picker handles the rest.
|
|
10015
|
+
*
|
|
10016
|
+
* Selection algorithm:
|
|
10017
|
+
* - pref === '<profile>' → profile-keyed entries (from
|
|
10018
|
+
* `getProfileRtspEntries`) match on `e.profile`;
|
|
10019
|
+
* legacy raw entries match on the brokerId
|
|
10020
|
+
* suffix (`brokerId` ENDS WITH `/${pref}`, shape
|
|
10021
|
+
* `${deviceId}/${camStreamId}`). Addons store the
|
|
10022
|
+
* bare profile/camStream id in their
|
|
10023
|
+
* `ExportDeviceSettings.streamPreference`. Falls
|
|
10024
|
+
* back to 'auto' when no enabled entry matches
|
|
10025
|
+
* either way.
|
|
10026
|
+
* - pref === 'auto' → when `targetResolution` is given, pick the
|
|
10027
|
+
* entry whose source resolution is closest to
|
|
10028
|
+
* it (prefer ≥ target so the consumer
|
|
10029
|
+
* downscales instead of upscaling). Without a
|
|
10030
|
+
* target, fall back to first-enabled. If no
|
|
10031
|
+
* entry advertises a resolution at all
|
|
10032
|
+
* (broker hasn't probed yet), also fall back
|
|
10033
|
+
* to first-enabled so cold start still serves.
|
|
10034
|
+
*
|
|
10035
|
+
* Returns `null` when nothing is publishable — callers fold that into
|
|
10036
|
+
* the consumer's "no stream" error (Alexa: STREAM_TYPE_UNSUPPORTED;
|
|
10037
|
+
* HAP: a thrown error inside `startFfmpegForSession`).
|
|
10038
|
+
*/
|
|
9945
10039
|
function pickPreferredRtspEntry(entries, pref, deviceId, options = {}) {
|
|
9946
10040
|
if (entries.length === 0) return null;
|
|
9947
10041
|
const prefix = `${deviceId}/`;
|
|
@@ -9971,30 +10065,23 @@ function pickPreferredRtspEntry(entries, pref, deviceId, options = {}) {
|
|
|
9971
10065
|
return toPicked(eligible[0]);
|
|
9972
10066
|
}
|
|
9973
10067
|
/**
|
|
9974
|
-
* Pick the entry whose `resolution` is closest to `target
|
|
9975
|
-
*
|
|
9976
|
-
*
|
|
9977
|
-
*
|
|
9978
|
-
*
|
|
10068
|
+
* Pick the entry whose `resolution` is closest to `target`, by the ONE target
|
|
10069
|
+
* rule ({@link compareToTarget}): prefer at or above the target so the consumer
|
|
10070
|
+
* downscales instead of upscaling; among those the smallest; among the rest the
|
|
10071
|
+
* largest.
|
|
10072
|
+
*
|
|
10073
|
+
* This function used to implement that rule itself, in pixels, while
|
|
10074
|
+
* `rankStreams` implemented it again in lines — the same sentence written twice
|
|
10075
|
+
* for the same two exporters, agreeing by luck rather than by construction.
|
|
10076
|
+
* Only the MEASURE is this picker's own: it compares whole pixel counts because
|
|
10077
|
+
* its entries can differ in aspect, where the cap's requirement is stated in p.
|
|
9979
10078
|
*/
|
|
9980
10079
|
function pickClosestResolution(entries, target) {
|
|
9981
10080
|
const targetPixels = target.width * target.height;
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
const pixels = e.resolution.width * e.resolution.height;
|
|
9987
|
-
if (pixels >= targetPixels) {
|
|
9988
|
-
if (!bestAbove || pixels < bestAbove.pixels) bestAbove = {
|
|
9989
|
-
entry: e,
|
|
9990
|
-
pixels
|
|
9991
|
-
};
|
|
9992
|
-
} else if (!bestBelow || pixels > bestBelow.pixels) bestBelow = {
|
|
9993
|
-
entry: e,
|
|
9994
|
-
pixels
|
|
9995
|
-
};
|
|
9996
|
-
}
|
|
9997
|
-
return bestAbove?.entry ?? bestBelow?.entry;
|
|
10081
|
+
return [...entries.flatMap((entry) => entry.resolution === void 0 ? [] : [{
|
|
10082
|
+
entry,
|
|
10083
|
+
pixels: entry.resolution.width * entry.resolution.height
|
|
10084
|
+
}])].sort((a, b) => compareToTarget(a.pixels, b.pixels, targetPixels))[0]?.entry;
|
|
9998
10085
|
}
|
|
9999
10086
|
var MODEL_FORMATS = [
|
|
10000
10087
|
"onnx",
|
|
@@ -12182,6 +12269,58 @@ method(ListInputSchema, array(BrokerInfoSchema$1)), method(GetInputSchema, Broke
|
|
|
12182
12269
|
auth: "admin"
|
|
12183
12270
|
}), method(GetStateInputSchema, unknown().nullable()), method(_void(), RegistryStatusSchema);
|
|
12184
12271
|
DeviceType.Camera;
|
|
12272
|
+
/**
|
|
12273
|
+
* The signals a device can emit to WAKE its own stream.
|
|
12274
|
+
*
|
|
12275
|
+
* A camera whose stream is built on demand sleeps until something asks for it,
|
|
12276
|
+
* and "something" cannot be a consumer that is merely attached — a Frigate-style
|
|
12277
|
+
* puller holds a session open for ever, and treating that as demand would keep
|
|
12278
|
+
* a battery camera awake for ever, which is the whole thing the battery is for
|
|
12279
|
+
* (D173). So the wake has to come from the CAMERA: an event it noticed by
|
|
12280
|
+
* itself, with no stream running.
|
|
12281
|
+
*
|
|
12282
|
+
* ## The vocabulary is the PROVIDER'S, not ours
|
|
12283
|
+
*
|
|
12284
|
+
* Like `consumables`, this cap declares no vocabulary of its own. A provider
|
|
12285
|
+
* names each signal with a `code` it chooses and a `label` an operator reads.
|
|
12286
|
+
* Reolink offers motion and camera-native detection; another provider may offer
|
|
12287
|
+
* a tamper, a doorbell press, a PIR, or something no camera in this fleet has
|
|
12288
|
+
* yet. A fixed enum here would mean every new signal is a framework release.
|
|
12289
|
+
*
|
|
12290
|
+
* It is deliberately NOT derived from the caps a device already binds. Whether
|
|
12291
|
+
* a camera CAN push firmware motion is expressed by `motionSources` containing
|
|
12292
|
+
* `'onboard'`, and whether it does AI on-camera by the `native-object-detection`
|
|
12293
|
+
* binding — but both answer "what drives the detection pipeline", which is a
|
|
12294
|
+
* different question from "what may wake a sleeping stream". A camera can do
|
|
12295
|
+
* the first and not be trusted with the second, and the operator picks per
|
|
12296
|
+
* camera. Two questions, two authorities.
|
|
12297
|
+
*
|
|
12298
|
+
* ## Availability is not permission
|
|
12299
|
+
*
|
|
12300
|
+
* `listSignals` says what the device CAN emit. Whether a given signal actually
|
|
12301
|
+
* wakes the stream is the operator's per-camera choice, held by the broker
|
|
12302
|
+
* alongside the cooldown — see the stream-broker cap's wake settings. A
|
|
12303
|
+
* provider declaring a signal is not a provider enabling it.
|
|
12304
|
+
*/
|
|
12305
|
+
/** One signal a device can emit. */
|
|
12306
|
+
var StreamSignalSchema = object({
|
|
12307
|
+
/** Stable id chosen by the provider, e.g. `'motion'`, `'person'`, `'tamper'`. */
|
|
12308
|
+
code: string().min(1),
|
|
12309
|
+
/** What an operator reads in the picker. The provider's own wording. */
|
|
12310
|
+
label: string().min(1),
|
|
12311
|
+
/**
|
|
12312
|
+
* Whether the provider recommends this signal ON when a camera is first set
|
|
12313
|
+
* up. A provider knows which of its signals are cheap and reliable; an
|
|
12314
|
+
* operator should not have to discover that by trial. Reolink recommends
|
|
12315
|
+
* both of its own.
|
|
12316
|
+
*/
|
|
12317
|
+
recommended: boolean()
|
|
12318
|
+
});
|
|
12319
|
+
object({
|
|
12320
|
+
signals: array(StreamSignalSchema),
|
|
12321
|
+
lastFetchedAt: number()
|
|
12322
|
+
});
|
|
12323
|
+
Object.values(DeviceType), method(_void(), array(StreamSignalSchema).readonly());
|
|
12185
12324
|
/** Stream delivery format. (Relocated from the retired `streaming-engine` cap.) */
|
|
12186
12325
|
var StreamFormatSchema = _enum([
|
|
12187
12326
|
"webrtc",
|
|
@@ -12578,6 +12717,22 @@ var EgressTranscodeSchema = object({
|
|
|
12578
12717
|
camStreamId: string().nullable()
|
|
12579
12718
|
});
|
|
12580
12719
|
method(object({
|
|
12720
|
+
deviceId: number().int().nonnegative(),
|
|
12721
|
+
/** The provider's signal code. */
|
|
12722
|
+
code: string().min(1),
|
|
12723
|
+
/** Ms epoch. Absent ⇒ now. */
|
|
12724
|
+
at: number().optional()
|
|
12725
|
+
}), object({
|
|
12726
|
+
/** Whether the broker acted on it, and if not, why. */
|
|
12727
|
+
accepted: boolean(),
|
|
12728
|
+
reason: _enum([
|
|
12729
|
+
"woke",
|
|
12730
|
+
"hold-extended",
|
|
12731
|
+
"not-enabled",
|
|
12732
|
+
"no-consumer",
|
|
12733
|
+
"unknown-code"
|
|
12734
|
+
])
|
|
12735
|
+
}), { kind: "mutation" }), method(object({
|
|
12581
12736
|
deviceId: number().int().nonnegative(),
|
|
12582
12737
|
camStreamId: string().min(1),
|
|
12583
12738
|
kind: CamStreamKindSchema,
|
|
@@ -12832,6 +12987,16 @@ var PickStreamRequirementsSchema = object({
|
|
|
12832
12987
|
acceptCodecs: array(StreamCodecSchema).readonly().optional(),
|
|
12833
12988
|
/** Minimum vertical resolution. Streams shorter than this are dropped. */
|
|
12834
12989
|
minHeight: number().int().positive().optional(),
|
|
12990
|
+
/**
|
|
12991
|
+
* Maximum vertical resolution. Streams TALLER than this are dropped.
|
|
12992
|
+
*
|
|
12993
|
+
* A consumer can have a ceiling as real as its floor: Alexa documents
|
|
12994
|
+
* 480p to 1080p, and a 4K stream is as unusable to an Echo as a 360p one.
|
|
12995
|
+
* Without this the ceiling had to be re-implemented by every caller — and
|
|
12996
|
+
* one caller implementing it privately is how a second scoring authority
|
|
12997
|
+
* gets born.
|
|
12998
|
+
*/
|
|
12999
|
+
maxHeight: number().int().positive().optional(),
|
|
12835
13000
|
/** Minimum horizontal resolution. */
|
|
12836
13001
|
minWidth: number().int().positive().optional(),
|
|
12837
13002
|
/**
|
|
@@ -12848,7 +13013,22 @@ var PickStreamRequirementsSchema = object({
|
|
|
12848
13013
|
* transcoded" guard: if the device is already serving the consumer's
|
|
12849
13014
|
* codec end-to-end, there's nothing to optimise.
|
|
12850
13015
|
*/
|
|
12851
|
-
requireSiblingCodec: array(StreamCodecSchema).readonly().optional()
|
|
13016
|
+
requireSiblingCodec: array(StreamCodecSchema).readonly().optional(),
|
|
13017
|
+
/**
|
|
13018
|
+
* Whether a stream the consumer CANNOT decode may still be picked, on the
|
|
13019
|
+
* understanding that it will be transcoded.
|
|
13020
|
+
*
|
|
13021
|
+
* Default `false` — today's behaviour, and the right one for a bypass
|
|
13022
|
+
* question ("is there a stream I can forward untouched?"). Set `true` to
|
|
13023
|
+
* ask the larger question: "what is the best stream for me, transcoding if
|
|
13024
|
+
* I must?" A stream that satisfies `acceptCodecs` always outranks one that
|
|
13025
|
+
* does not, so a passthrough is never lost to a transcode; the answer says
|
|
13026
|
+
* which it is in {@link PickedCamStreamSchema.transcodes}.
|
|
13027
|
+
*
|
|
13028
|
+
* This is what lets one picker serve both the bypass and the full source
|
|
13029
|
+
* choice, instead of a consumer scoring privately when the bypass misses.
|
|
13030
|
+
*/
|
|
13031
|
+
allowTranscode: boolean().optional()
|
|
12852
13032
|
}).readonly();
|
|
12853
13033
|
var PickStreamPreferencesSchema = object({
|
|
12854
13034
|
/**
|
|
@@ -12862,12 +13042,32 @@ var PickStreamPreferencesSchema = object({
|
|
|
12862
13042
|
* picks the tallest stream; `'lowest'` picks the shortest (used by
|
|
12863
13043
|
* memory-constrained consumers / Apple Home guest sessions).
|
|
12864
13044
|
*/
|
|
12865
|
-
resolutionPreference: _enum(["highest", "lowest"]).optional()
|
|
13045
|
+
resolutionPreference: _enum(["highest", "lowest"]).optional(),
|
|
13046
|
+
/**
|
|
13047
|
+
* The height the consumer actually wants to DELIVER.
|
|
13048
|
+
*
|
|
13049
|
+
* Not a constraint — an ordering. With it set, the SMALLEST stream at or
|
|
13050
|
+
* above the target wins, and only if nothing reaches it does the tallest
|
|
13051
|
+
* take over. Pulling 1296 lines to draw 720 on a 1280x800 Echo panel costs
|
|
13052
|
+
* a decode and buys nothing, and `resolutionPreference: 'highest'` cannot
|
|
13053
|
+
* express that: it says "as big as possible", which is a different wish.
|
|
13054
|
+
*
|
|
13055
|
+
* Ignored when absent, so every existing caller keeps its ordering.
|
|
13056
|
+
*/
|
|
13057
|
+
targetHeight: number().int().positive().optional()
|
|
12866
13058
|
}).readonly();
|
|
12867
13059
|
var PickedCamStreamSchema = object({
|
|
12868
13060
|
camStreamId: string(),
|
|
12869
13061
|
codec: string().optional(),
|
|
12870
13062
|
resolution: CamStreamResolutionSchema.optional(),
|
|
13063
|
+
/**
|
|
13064
|
+
* Whether serving this stream requires a decode + re-encode.
|
|
13065
|
+
*
|
|
13066
|
+
* `false` is a stream the consumer can take as it stands. Only ever `true`
|
|
13067
|
+
* when the caller asked for it with `allowTranscode`, so a caller that did
|
|
13068
|
+
* not ask cannot be handed a cost it never agreed to pay.
|
|
13069
|
+
*/
|
|
13070
|
+
transcodes: boolean(),
|
|
12871
13071
|
/** One-line explanation of why this stream won — for logs / debug UI. */
|
|
12872
13072
|
reason: string()
|
|
12873
13073
|
});
|
|
@@ -16974,7 +17174,7 @@ var AlarmArmModeSchema = _enum([
|
|
|
16974
17174
|
"vacation",
|
|
16975
17175
|
"custom_bypass"
|
|
16976
17176
|
]);
|
|
16977
|
-
object({
|
|
17177
|
+
var AlarmPanelStatusSchema = object({
|
|
16978
17178
|
/** Current lifecycle state. */
|
|
16979
17179
|
state: AlarmStateSchema,
|
|
16980
17180
|
/** Subset of arm modes the panel accepts. UI renders one button per
|
|
@@ -17137,6 +17337,8 @@ var NcSystemEventKindSchema = _enum([
|
|
|
17137
17337
|
"device-enabled",
|
|
17138
17338
|
"device-battery-low",
|
|
17139
17339
|
"device-battery-normal",
|
|
17340
|
+
"device-consumable-low",
|
|
17341
|
+
"device-consumable-normal",
|
|
17140
17342
|
"stream-online",
|
|
17141
17343
|
"stream-offline",
|
|
17142
17344
|
"node-online",
|
|
@@ -17155,6 +17357,7 @@ var NcSystemEventKindSchema = _enum([
|
|
|
17155
17357
|
"addon-updated",
|
|
17156
17358
|
"server-updated",
|
|
17157
17359
|
"export-completed",
|
|
17360
|
+
"backup-completed",
|
|
17158
17361
|
"camera-online",
|
|
17159
17362
|
"camera-offline",
|
|
17160
17363
|
"camera-disabled",
|
|
@@ -24396,10 +24599,28 @@ DeviceType.Camera, method(object({ deviceId: number().int().nonnegative() }), ar
|
|
|
24396
24599
|
}), boolean()), method(object({
|
|
24397
24600
|
deviceId: number().int().nonnegative(),
|
|
24398
24601
|
sessionId: string()
|
|
24399
|
-
}), object({
|
|
24400
|
-
|
|
24401
|
-
|
|
24402
|
-
|
|
24602
|
+
}), object({
|
|
24603
|
+
pendingRenegotiation: object({
|
|
24604
|
+
target: WebrtcStreamTargetSchema,
|
|
24605
|
+
epoch: number()
|
|
24606
|
+
}).nullable(),
|
|
24607
|
+
/**
|
|
24608
|
+
* Whether the session still EXISTS.
|
|
24609
|
+
*
|
|
24610
|
+
* A consumer that holds a resource for the life of a session needs to
|
|
24611
|
+
* be able to ask, because a session does not always end the way it
|
|
24612
|
+
* began. Measured on this hub 2026-09-13: an Echo that got stuck never
|
|
24613
|
+
* sent `SessionDisconnected`, so the Alexa exporter's
|
|
24614
|
+
* `releaseEgressTranscode` never ran, and a 2304x1296 HEVC to 720p
|
|
24615
|
+
* H.264 transcode kept running for NOBODY for more than twenty
|
|
24616
|
+
* minutes. The WebRTC session had logged `WebRTC session closed`
|
|
24617
|
+
* minutes earlier — the broker knew; the holder had no way to ask.
|
|
24618
|
+
*
|
|
24619
|
+
* `false` for a session id the provider has never heard of, which is
|
|
24620
|
+
* the same answer as "it ended": either way nothing is holding it up.
|
|
24621
|
+
*/
|
|
24622
|
+
alive: boolean()
|
|
24623
|
+
}));
|
|
24403
24624
|
object({
|
|
24404
24625
|
/** All accessory children of the parent. */
|
|
24405
24626
|
childDeviceIds: array(number()).readonly(),
|
|
@@ -36964,6 +37185,12 @@ Object.freeze({
|
|
|
36964
37185
|
addonId: null,
|
|
36965
37186
|
access: "create"
|
|
36966
37187
|
},
|
|
37188
|
+
"streamBroker.reportStreamSignal": {
|
|
37189
|
+
capName: "stream-broker",
|
|
37190
|
+
capScope: "system",
|
|
37191
|
+
addonId: null,
|
|
37192
|
+
access: "create"
|
|
37193
|
+
},
|
|
36967
37194
|
"streamBroker.restartProfile": {
|
|
36968
37195
|
capName: "stream-broker",
|
|
36969
37196
|
capScope: "system",
|
|
@@ -37048,6 +37275,12 @@ Object.freeze({
|
|
|
37048
37275
|
addonId: null,
|
|
37049
37276
|
access: "create"
|
|
37050
37277
|
},
|
|
37278
|
+
"streamSignals.listSignals": {
|
|
37279
|
+
capName: "stream-signals",
|
|
37280
|
+
capScope: "device",
|
|
37281
|
+
addonId: null,
|
|
37282
|
+
access: "view"
|
|
37283
|
+
},
|
|
37051
37284
|
"switch.setState": {
|
|
37052
37285
|
capName: "switch",
|
|
37053
37286
|
capScope: "device",
|
|
@@ -39420,6 +39653,11 @@ Object.freeze({
|
|
|
39420
39653
|
form: "single",
|
|
39421
39654
|
optional: false
|
|
39422
39655
|
}],
|
|
39656
|
+
"streamBroker.reportStreamSignal": [{
|
|
39657
|
+
name: "deviceId",
|
|
39658
|
+
form: "single",
|
|
39659
|
+
optional: false
|
|
39660
|
+
}],
|
|
39423
39661
|
"streamBroker.restartProfile": [{
|
|
39424
39662
|
name: "deviceId",
|
|
39425
39663
|
form: "single",
|
|
@@ -40208,7 +40446,7 @@ var Fmp4FragmentChild = class {
|
|
|
40208
40446
|
meta: {
|
|
40209
40447
|
sourceId: this.args.sourceId,
|
|
40210
40448
|
decodeHwAccel: requested,
|
|
40211
|
-
error: errMsg$
|
|
40449
|
+
error: errMsg$16(err)
|
|
40212
40450
|
}
|
|
40213
40451
|
});
|
|
40214
40452
|
this.killChild();
|
|
@@ -40387,7 +40625,7 @@ var Fmp4FragmentChild = class {
|
|
|
40387
40625
|
tags: { deviceId: this.args.deviceId },
|
|
40388
40626
|
meta: {
|
|
40389
40627
|
sourceId: this.args.sourceId,
|
|
40390
|
-
error: errMsg$
|
|
40628
|
+
error: errMsg$16(err)
|
|
40391
40629
|
}
|
|
40392
40630
|
});
|
|
40393
40631
|
}
|
|
@@ -87041,9 +87279,126 @@ function clearPairingFiles(accessoryUuid, logger) {
|
|
|
87041
87279
|
} });
|
|
87042
87280
|
}
|
|
87043
87281
|
}
|
|
87282
|
+
/**
|
|
87283
|
+
* Whether this device's accessory belongs on the bridge.
|
|
87284
|
+
*
|
|
87285
|
+
* A camera is `false` whatever the operator picked — the answer is HomeKit's,
|
|
87286
|
+
* not ours, and an operator who switched it on before the field was gated must
|
|
87287
|
+
* not end up with a camera nobody can pair.
|
|
87288
|
+
*
|
|
87289
|
+
* Absent means ON for everything else: the field did not exist for entries
|
|
87290
|
+
* persisted before it, and the default the operator asked for is the bridge.
|
|
87291
|
+
*/
|
|
87292
|
+
function shouldBridge(input) {
|
|
87293
|
+
if (input.mapperKind === "camera") return false;
|
|
87294
|
+
return input.useBridge !== false;
|
|
87295
|
+
}
|
|
87296
|
+
/** Whether the bridge has room for one more. */
|
|
87297
|
+
function bridgeHasRoom(current) {
|
|
87298
|
+
return current < 149;
|
|
87299
|
+
}
|
|
87300
|
+
//#endregion
|
|
87301
|
+
//#region src/bridge-host.ts
|
|
87302
|
+
/**
|
|
87303
|
+
* THE bridge accessory — one per node, created on demand, holding every
|
|
87304
|
+
* non-camera accessory the operator routed onto it.
|
|
87305
|
+
*
|
|
87306
|
+
* One mDNS advertisement, one HAP connection, one pairing, N accessories
|
|
87307
|
+
* inside. The alternative — what this addon did until now — gives every
|
|
87308
|
+
* switch, sensor and alarm panel its own port, its own advertisement and its
|
|
87309
|
+
* own "Add Accessory" in the Home app. Cameras stay standalone, because
|
|
87310
|
+
* HomeKit forbids bridging them (`bridge-policy.ts`).
|
|
87311
|
+
*
|
|
87312
|
+
* ONE bridge, deliberately. The ceiling is 149 accessories
|
|
87313
|
+
* ({@link MAX_BRIDGED_ACCESSORIES}) and this hub exposes 46 devices in total,
|
|
87314
|
+
* cameras included; a second bridge is a thing to build when the count
|
|
87315
|
+
* approaches the ceiling, not before, and the refusal at the ceiling is
|
|
87316
|
+
* explicit rather than a library throw.
|
|
87317
|
+
*
|
|
87318
|
+
* The bridge is LAZY: it is published the first time an accessory needs it,
|
|
87319
|
+
* so a fleet of nothing but cameras advertises no empty bridge. It is not
|
|
87320
|
+
* unpublished when the last accessory leaves — an unpublish would drop the
|
|
87321
|
+
* pairing record the operator already entered a code for, and an empty bridge
|
|
87322
|
+
* in the Home app is a far smaller cost than a re-pair.
|
|
87323
|
+
*/
|
|
87324
|
+
var BridgeHost = class {
|
|
87325
|
+
opts;
|
|
87326
|
+
bridge = null;
|
|
87327
|
+
published = false;
|
|
87328
|
+
constructor(opts) {
|
|
87329
|
+
this.opts = opts;
|
|
87330
|
+
}
|
|
87331
|
+
/** The live bridge accessory, or `null` before anything needed one. */
|
|
87332
|
+
get accessory() {
|
|
87333
|
+
return this.bridge;
|
|
87334
|
+
}
|
|
87335
|
+
/** How many accessories are riding it right now. */
|
|
87336
|
+
get size() {
|
|
87337
|
+
return this.bridge?.bridgedAccessories.length ?? 0;
|
|
87338
|
+
}
|
|
87339
|
+
/**
|
|
87340
|
+
* Put an accessory on the bridge, publishing the bridge if this is the
|
|
87341
|
+
* first. Returns `false` — without throwing, and having logged — when the
|
|
87342
|
+
* bridge is full: the caller then falls back to standalone, which is worse
|
|
87343
|
+
* for the operator and still works.
|
|
87344
|
+
*/
|
|
87345
|
+
async add(accessory) {
|
|
87346
|
+
const bridge = this.ensure();
|
|
87347
|
+
if (!bridgeHasRoom(bridge.bridgedAccessories.length)) {
|
|
87348
|
+
this.opts.logger.warn("export-hap: the bridge is FULL — publishing standalone instead", { meta: {
|
|
87349
|
+
uuid: accessory.UUID,
|
|
87350
|
+
bridged: bridge.bridgedAccessories.length,
|
|
87351
|
+
max: 149
|
|
87352
|
+
} });
|
|
87353
|
+
return false;
|
|
87354
|
+
}
|
|
87355
|
+
bridge.addBridgedAccessory(accessory);
|
|
87356
|
+
await this.publishOnce();
|
|
87357
|
+
return true;
|
|
87358
|
+
}
|
|
87359
|
+
/** Take an accessory off the bridge. A bridged accessory is never
|
|
87360
|
+
* `unpublish`ed — it has no server of its own. */
|
|
87361
|
+
remove(accessory) {
|
|
87362
|
+
if (this.bridge === null) return;
|
|
87363
|
+
if (!this.bridge.bridgedAccessories.some((a) => a.UUID === accessory.UUID)) return;
|
|
87364
|
+
this.bridge.removeBridgedAccessory(accessory, false);
|
|
87365
|
+
}
|
|
87366
|
+
/** Whether this accessory is currently on the bridge. */
|
|
87367
|
+
holds(accessory) {
|
|
87368
|
+
return this.bridge?.bridgedAccessories.some((a) => a.UUID === accessory.UUID) ?? false;
|
|
87369
|
+
}
|
|
87370
|
+
/** Tear the bridge down — process shutdown only. */
|
|
87371
|
+
async dispose() {
|
|
87372
|
+
if (this.bridge === null || !this.published) return;
|
|
87373
|
+
await unpublishAccessory(this.bridge, this.opts.logger);
|
|
87374
|
+
this.published = false;
|
|
87375
|
+
}
|
|
87376
|
+
ensure() {
|
|
87377
|
+
if (this.bridge !== null) return this.bridge;
|
|
87378
|
+
const bridge = new import_dist.Accessory(this.opts.displayName, this.opts.uuid);
|
|
87379
|
+
bridge.category = import_dist.Categories.BRIDGE;
|
|
87380
|
+
this.bridge = bridge;
|
|
87381
|
+
return bridge;
|
|
87382
|
+
}
|
|
87383
|
+
async publishOnce() {
|
|
87384
|
+
if (this.published || this.bridge === null) return;
|
|
87385
|
+
if (this.opts.publish !== void 0) await this.opts.publish(this.bridge, this.opts.pincode);
|
|
87386
|
+
else await publishStandalone(this.bridge, {
|
|
87387
|
+
pincode: this.opts.pincode,
|
|
87388
|
+
port: 0,
|
|
87389
|
+
bind: this.opts.bind,
|
|
87390
|
+
logger: this.opts.logger
|
|
87391
|
+
});
|
|
87392
|
+
this.published = true;
|
|
87393
|
+
this.opts.logger.info("export-hap: the bridge is published", { meta: {
|
|
87394
|
+
displayName: this.opts.displayName,
|
|
87395
|
+
uuid: this.opts.uuid
|
|
87396
|
+
} });
|
|
87397
|
+
}
|
|
87398
|
+
};
|
|
87044
87399
|
//#endregion
|
|
87045
87400
|
//#region src/hap-setup-uri.ts
|
|
87046
|
-
function errMsg$
|
|
87401
|
+
function errMsg$15(e) {
|
|
87047
87402
|
return e instanceof Error ? e.message : String(e);
|
|
87048
87403
|
}
|
|
87049
87404
|
/**
|
|
@@ -87070,7 +87425,7 @@ function firstExposedAccessorySetupUri(exposed, logger) {
|
|
|
87070
87425
|
try {
|
|
87071
87426
|
return first.setupURI();
|
|
87072
87427
|
} catch (err) {
|
|
87073
|
-
logger.debug("export-hap: setupURI failed on first exposed accessory", { meta: { error: errMsg$
|
|
87428
|
+
logger.debug("export-hap: setupURI failed on first exposed accessory", { meta: { error: errMsg$15(err) } });
|
|
87074
87429
|
return;
|
|
87075
87430
|
}
|
|
87076
87431
|
}
|
|
@@ -87423,7 +87778,7 @@ async function buildBattery(bctx) {
|
|
|
87423
87778
|
const status = await proxy.battery?.getStatus({});
|
|
87424
87779
|
if (status !== void 0 && status !== null) applyToService(service, status);
|
|
87425
87780
|
} catch (err) {
|
|
87426
|
-
log.debug("export-hap: battery getStatus hydrate failed (non-fatal)", { meta: { error: errMsg$
|
|
87781
|
+
log.debug("export-hap: battery getStatus hydrate failed (non-fatal)", { meta: { error: errMsg$14(err) } });
|
|
87427
87782
|
}
|
|
87428
87783
|
const unsubscribes = [];
|
|
87429
87784
|
if (proxy.state.battery) {
|
|
@@ -87442,7 +87797,7 @@ async function buildBattery(bctx) {
|
|
|
87442
87797
|
function applyToService(service, status) {
|
|
87443
87798
|
applyUpdates(service, batteryCharacteristicUpdates(status));
|
|
87444
87799
|
}
|
|
87445
|
-
function errMsg$
|
|
87800
|
+
function errMsg$14(err) {
|
|
87446
87801
|
return err instanceof Error ? err.message : String(err);
|
|
87447
87802
|
}
|
|
87448
87803
|
//#endregion
|
|
@@ -98194,7 +98549,7 @@ var VIDEO_LOOPBACK_RCVBUF_BYTES = 8 * 1024 * 1024;
|
|
|
98194
98549
|
* not burst size.
|
|
98195
98550
|
*/
|
|
98196
98551
|
var AUDIO_LOOPBACK_RCVBUF_BYTES = 1024 * 1024;
|
|
98197
|
-
function errMsg$
|
|
98552
|
+
function errMsg$13(err) {
|
|
98198
98553
|
return err instanceof Error ? err.message : String(err);
|
|
98199
98554
|
}
|
|
98200
98555
|
/**
|
|
@@ -98209,13 +98564,13 @@ function applyReceiveBuffer(socket, requestedBytes) {
|
|
|
98209
98564
|
try {
|
|
98210
98565
|
socket.setRecvBufferSize(requestedBytes);
|
|
98211
98566
|
} catch (err) {
|
|
98212
|
-
error = errMsg$
|
|
98567
|
+
error = errMsg$13(err);
|
|
98213
98568
|
}
|
|
98214
98569
|
let effectiveBytes = null;
|
|
98215
98570
|
try {
|
|
98216
98571
|
effectiveBytes = socket.getRecvBufferSize();
|
|
98217
98572
|
} catch (err) {
|
|
98218
|
-
if (error === null) error = errMsg$
|
|
98573
|
+
if (error === null) error = errMsg$13(err);
|
|
98219
98574
|
}
|
|
98220
98575
|
return {
|
|
98221
98576
|
requestedBytes,
|
|
@@ -98475,20 +98830,20 @@ function buildCameraStreamingDelegate(bctx, advertised) {
|
|
|
98475
98830
|
delegate: {
|
|
98476
98831
|
handleSnapshotRequest(request, callback) {
|
|
98477
98832
|
handleSnapshot(bctx, request).then((buf) => callback(void 0, buf)).catch((err) => {
|
|
98478
|
-
log.warn("export-hap: snapshot failed", { meta: { error: errMsg$
|
|
98479
|
-
callback(err instanceof Error ? err : new Error(errMsg$
|
|
98833
|
+
log.warn("export-hap: snapshot failed", { meta: { error: errMsg$12(err) } });
|
|
98834
|
+
callback(err instanceof Error ? err : new Error(errMsg$12(err)));
|
|
98480
98835
|
});
|
|
98481
98836
|
},
|
|
98482
98837
|
prepareStream(request, callback) {
|
|
98483
98838
|
prepareStream(request, sessions, bctx).then((resp) => callback(void 0, resp)).catch((err) => {
|
|
98484
|
-
log.warn("export-hap: prepareStream failed", { meta: { error: errMsg$
|
|
98485
|
-
callback(err instanceof Error ? err : new Error(errMsg$
|
|
98839
|
+
log.warn("export-hap: prepareStream failed", { meta: { error: errMsg$12(err) } });
|
|
98840
|
+
callback(err instanceof Error ? err : new Error(errMsg$12(err)));
|
|
98486
98841
|
});
|
|
98487
98842
|
},
|
|
98488
98843
|
handleStreamRequest(request, callback) {
|
|
98489
98844
|
handleStreamRequest(request, sessions, bctx, advertised).then(() => callback()).catch((err) => {
|
|
98490
|
-
log.warn("export-hap: handleStreamRequest failed", { meta: { error: errMsg$
|
|
98491
|
-
callback(err instanceof Error ? err : new Error(errMsg$
|
|
98845
|
+
log.warn("export-hap: handleStreamRequest failed", { meta: { error: errMsg$12(err) } });
|
|
98846
|
+
callback(err instanceof Error ? err : new Error(errMsg$12(err)));
|
|
98492
98847
|
});
|
|
98493
98848
|
}
|
|
98494
98849
|
},
|
|
@@ -98604,7 +98959,7 @@ async function prepareStream(request, sessions, bctx) {
|
|
|
98604
98959
|
closeSocket(audioUdp);
|
|
98605
98960
|
closeSocket(videoLoopUdp);
|
|
98606
98961
|
closeSocket(audioLoopUdp);
|
|
98607
|
-
throw new Error(`export-hap: outbound SrtpSession init failed: ${errMsg$
|
|
98962
|
+
throw new Error(`export-hap: outbound SrtpSession init failed: ${errMsg$12(err)}`, { cause: err });
|
|
98608
98963
|
}
|
|
98609
98964
|
let upstreamAudioSrtp = null;
|
|
98610
98965
|
try {
|
|
@@ -98618,7 +98973,7 @@ async function prepareStream(request, sessions, bctx) {
|
|
|
98618
98973
|
profile: import_src.ProtectionProfileAes128CmHmacSha1_80
|
|
98619
98974
|
});
|
|
98620
98975
|
} catch (err) {
|
|
98621
|
-
bctx.ctx.logger.withTags({ deviceId: bctx.numericDeviceId }).warn("export-hap: SrtpSession init failed (upstream audio decrypt disabled)", { meta: { error: errMsg$
|
|
98976
|
+
bctx.ctx.logger.withTags({ deviceId: bctx.numericDeviceId }).warn("export-hap: SrtpSession init failed (upstream audio decrypt disabled)", { meta: { error: errMsg$12(err) } });
|
|
98622
98977
|
}
|
|
98623
98978
|
const videoSsrc = randomSsrc();
|
|
98624
98979
|
const audioSsrc = randomSsrc();
|
|
@@ -98735,7 +99090,7 @@ async function prepareStream(request, sessions, bctx) {
|
|
|
98735
99090
|
});
|
|
98736
99091
|
audioUdp.on("message", (packet, rinfo) => {
|
|
98737
99092
|
handleIncomingAudioRtp(session, packet, rinfo.address, bctx).catch((err) => {
|
|
98738
|
-
bctx.ctx.logger.withTags({ deviceId: bctx.numericDeviceId }).debug("export-hap: incoming-audio handler error (dropped)", { meta: { error: errMsg$
|
|
99093
|
+
bctx.ctx.logger.withTags({ deviceId: bctx.numericDeviceId }).debug("export-hap: incoming-audio handler error (dropped)", { meta: { error: errMsg$12(err) } });
|
|
98739
99094
|
});
|
|
98740
99095
|
});
|
|
98741
99096
|
logLoopbackBuffer(tagLog, request.sessionID, "video", videoLoop.buffer);
|
|
@@ -98931,7 +99286,7 @@ function readControllerRtcp(session, leg, packet, log) {
|
|
|
98931
99286
|
} catch (err) {
|
|
98932
99287
|
drop(session, "inbound-rtcp-decrypt-failed");
|
|
98933
99288
|
storeReceiverReports(session, leg, recordUnreadableRtcp(tally));
|
|
98934
|
-
logUnreadableRtcp(session, leg, `decrypt: ${errMsg$
|
|
99289
|
+
logUnreadableRtcp(session, leg, `decrypt: ${errMsg$12(err)}`, log);
|
|
98935
99290
|
return;
|
|
98936
99291
|
}
|
|
98937
99292
|
const outcome = ingestDecryptedRtcp(plaintext, tally);
|
|
@@ -99448,6 +99803,19 @@ async function startFfmpegForSession(bctx, session, sessionId, video, advertised
|
|
|
99448
99803
|
} });
|
|
99449
99804
|
throw new Error(`export-hap: no enabled RTSP entries for device ${numericDeviceId}`);
|
|
99450
99805
|
}
|
|
99806
|
+
if (fit.kind === "transcode" && bctx.options.hapDeviceSettings?.allowTranscode === false) {
|
|
99807
|
+
startLog.warn("export-hap: stream start REFUSED — transcoding is switched off", {
|
|
99808
|
+
tags: { deviceId: numericDeviceId },
|
|
99809
|
+
meta: {
|
|
99810
|
+
sessionId,
|
|
99811
|
+
streamPreference: pref,
|
|
99812
|
+
negotiated: `${video.width}x${video.height}`,
|
|
99813
|
+
pickedProfile: fit.profile,
|
|
99814
|
+
pickedCodec: fit.picked.codec ?? "unknown"
|
|
99815
|
+
}
|
|
99816
|
+
});
|
|
99817
|
+
throw new Error(`export-hap: device ${numericDeviceId} needs a transcode and transcoding is switched off`);
|
|
99818
|
+
}
|
|
99451
99819
|
const picked = fit.picked;
|
|
99452
99820
|
const rtspUrl = picked.url;
|
|
99453
99821
|
const slot = brokerStreams.find((s) => s.profile === fit.profile);
|
|
@@ -99697,7 +100065,7 @@ async function handleIncomingAudioRtp(session, packet, sourceAddress, bctx) {
|
|
|
99697
100065
|
session.upstreamRtpDecryptFailures += 1;
|
|
99698
100066
|
if (session.upstreamRtpDecryptFailures % 100 === 1) log.debug("export-hap: SRTP decrypt failed (rate-limited)", { meta: {
|
|
99699
100067
|
failures: session.upstreamRtpDecryptFailures,
|
|
99700
|
-
error: errMsg$
|
|
100068
|
+
error: errMsg$12(err)
|
|
99701
100069
|
} });
|
|
99702
100070
|
return;
|
|
99703
100071
|
}
|
|
@@ -99711,7 +100079,7 @@ async function handleIncomingAudioRtp(session, packet, sourceAddress, bctx) {
|
|
|
99711
100079
|
rtpPayloadType = parsedRtp.header.payloadType;
|
|
99712
100080
|
} catch (err) {
|
|
99713
100081
|
drop(session, "upstream-parse-failed");
|
|
99714
|
-
log.debug("export-hap: RTP parse failed after decrypt", { meta: { error: errMsg$
|
|
100082
|
+
log.debug("export-hap: RTP parse failed after decrypt", { meta: { error: errMsg$12(err) } });
|
|
99715
100083
|
return;
|
|
99716
100084
|
}
|
|
99717
100085
|
const negotiatedAudioPt = session.lastStartParams?.audioPt;
|
|
@@ -99735,7 +100103,7 @@ async function handleIncomingAudioRtp(session, packet, sourceAddress, bctx) {
|
|
|
99735
100103
|
if (session.intercomTalkSessionId === null) {
|
|
99736
100104
|
session.intercomTalkSessionId = "";
|
|
99737
100105
|
const opened = await openIntercomTalkSession(bctx).catch((err) => {
|
|
99738
|
-
log.warn("export-hap: intercom.startTalkSession failed", { meta: { error: errMsg$
|
|
100106
|
+
log.warn("export-hap: intercom.startTalkSession failed", { meta: { error: errMsg$12(err) } });
|
|
99739
100107
|
return null;
|
|
99740
100108
|
});
|
|
99741
100109
|
if (opened) {
|
|
@@ -99762,7 +100130,7 @@ async function handleIncomingAudioRtp(session, packet, sourceAddress, bctx) {
|
|
|
99762
100130
|
drop(session, "upstream-push-failed");
|
|
99763
100131
|
log.debug("export-hap: intercom.pushTalkAudio failed (will re-open on next frame)", { meta: {
|
|
99764
100132
|
sequenceNumber: session.intercomPcmSequence,
|
|
99765
|
-
error: errMsg$
|
|
100133
|
+
error: errMsg$12(err)
|
|
99766
100134
|
} });
|
|
99767
100135
|
session.intercomTalkSessionId = null;
|
|
99768
100136
|
}
|
|
@@ -99794,7 +100162,7 @@ async function closeIntercomTalkSession(session, bctx) {
|
|
|
99794
100162
|
} catch (err) {
|
|
99795
100163
|
log.debug("export-hap: intercom.endTalkSession failed (continuing)", { meta: {
|
|
99796
100164
|
sessionId,
|
|
99797
|
-
error: errMsg$
|
|
100165
|
+
error: errMsg$12(err)
|
|
99798
100166
|
} });
|
|
99799
100167
|
}
|
|
99800
100168
|
}
|
|
@@ -99819,7 +100187,7 @@ function closeSocket(udp) {
|
|
|
99819
100187
|
function randomSsrc() {
|
|
99820
100188
|
return Math.floor(Math.random() * 2147483646) + 1 | 0;
|
|
99821
100189
|
}
|
|
99822
|
-
function errMsg$
|
|
100190
|
+
function errMsg$12(err) {
|
|
99823
100191
|
return err instanceof Error ? err.message : String(err);
|
|
99824
100192
|
}
|
|
99825
100193
|
//#endregion
|
|
@@ -99903,14 +100271,14 @@ async function buildDoorbell(input) {
|
|
|
99903
100271
|
}
|
|
99904
100272
|
log.info("export-hap: doorbell SINGLE_PRESS pushed to HomeKit", { meta: { ...delivery } });
|
|
99905
100273
|
} catch (err) {
|
|
99906
|
-
log.warn("export-hap: ringDoorbell() failed", { meta: { error: errMsg$
|
|
100274
|
+
log.warn("export-hap: ringDoorbell() failed", { meta: { error: errMsg$11(err) } });
|
|
99907
100275
|
}
|
|
99908
100276
|
});
|
|
99909
100277
|
return { async dispose() {
|
|
99910
100278
|
unsubscribe();
|
|
99911
100279
|
} };
|
|
99912
100280
|
}
|
|
99913
|
-
function errMsg$
|
|
100281
|
+
function errMsg$11(err) {
|
|
99914
100282
|
return err instanceof Error ? err.message : String(err);
|
|
99915
100283
|
}
|
|
99916
100284
|
//#endregion
|
|
@@ -99958,7 +100326,7 @@ async function buildMotionSensor(bctx, existing = null) {
|
|
|
99958
100326
|
const detected = await proxy.motion?.isDetected({});
|
|
99959
100327
|
if (typeof detected === "boolean") motionService.updateCharacteristic(import_dist.Characteristic.MotionDetected, detected);
|
|
99960
100328
|
} catch (err) {
|
|
99961
|
-
ctx.logger.withTags({ deviceId: numericDeviceId }).debug("export-hap: initial motion hydrate failed (non-fatal)", { meta: { error: errMsg$
|
|
100329
|
+
ctx.logger.withTags({ deviceId: numericDeviceId }).debug("export-hap: initial motion hydrate failed (non-fatal)", { meta: { error: errMsg$10(err) } });
|
|
99962
100330
|
}
|
|
99963
100331
|
let resetTimer = null;
|
|
99964
100332
|
const armReset = () => {
|
|
@@ -99992,7 +100360,7 @@ async function buildMotionSensor(bctx, existing = null) {
|
|
|
99992
100360
|
}
|
|
99993
100361
|
} };
|
|
99994
100362
|
}
|
|
99995
|
-
function errMsg$
|
|
100363
|
+
function errMsg$10(err) {
|
|
99996
100364
|
return err instanceof Error ? err.message : String(err);
|
|
99997
100365
|
}
|
|
99998
100366
|
//#endregion
|
|
@@ -100023,7 +100391,7 @@ async function buildPrivacySwitch(bctx) {
|
|
|
100023
100391
|
const status = await proxy.privacyMask?.getStatus({});
|
|
100024
100392
|
if (status && typeof status.enabled === "boolean") service.updateCharacteristic(import_dist.Characteristic.On, status.enabled);
|
|
100025
100393
|
} catch (err) {
|
|
100026
|
-
log.debug("export-hap: privacy-mask getStatus hydrate failed (non-fatal)", { meta: { error: errMsg$
|
|
100394
|
+
log.debug("export-hap: privacy-mask getStatus hydrate failed (non-fatal)", { meta: { error: errMsg$9(err) } });
|
|
100027
100395
|
}
|
|
100028
100396
|
service.getCharacteristic(import_dist.Characteristic.On).onSet(async (value) => {
|
|
100029
100397
|
const enabled = value === true;
|
|
@@ -100032,7 +100400,7 @@ async function buildPrivacySwitch(bctx) {
|
|
|
100032
100400
|
} catch (err) {
|
|
100033
100401
|
log.warn("export-hap: privacy-mask setMask failed", { meta: {
|
|
100034
100402
|
enabled,
|
|
100035
|
-
error: errMsg$
|
|
100403
|
+
error: errMsg$9(err)
|
|
100036
100404
|
} });
|
|
100037
100405
|
}
|
|
100038
100406
|
});
|
|
@@ -100050,7 +100418,7 @@ async function buildPrivacySwitch(bctx) {
|
|
|
100050
100418
|
} catch {}
|
|
100051
100419
|
} };
|
|
100052
100420
|
}
|
|
100053
|
-
function errMsg$
|
|
100421
|
+
function errMsg$9(err) {
|
|
100054
100422
|
return err instanceof Error ? err.message : String(err);
|
|
100055
100423
|
}
|
|
100056
100424
|
//#endregion
|
|
@@ -100141,7 +100509,7 @@ async function buildPtz(bctx) {
|
|
|
100141
100509
|
} catch (err) {
|
|
100142
100510
|
log.warn("export-hap: ptz.goToPreset failed", { meta: {
|
|
100143
100511
|
presetId: preset.id,
|
|
100144
|
-
error: errMsg$
|
|
100512
|
+
error: errMsg$8(err)
|
|
100145
100513
|
} });
|
|
100146
100514
|
}
|
|
100147
100515
|
armReset(() => service.updateCharacteristic(import_dist.Characteristic.On, false), MOMENTARY_RESET_MS);
|
|
@@ -100159,14 +100527,14 @@ async function buildPtz(bctx) {
|
|
|
100159
100527
|
try {
|
|
100160
100528
|
await proxy.ptz?.stop({});
|
|
100161
100529
|
} catch (err) {
|
|
100162
|
-
log.debug("export-hap: ptz.stop failed (non-fatal)", { meta: { error: errMsg$
|
|
100530
|
+
log.debug("export-hap: ptz.stop failed (non-fatal)", { meta: { error: errMsg$8(err) } });
|
|
100163
100531
|
}
|
|
100164
100532
|
service.updateCharacteristic(import_dist.Characteristic.On, false);
|
|
100165
100533
|
}, options.ptzPulseMs);
|
|
100166
100534
|
} catch (err) {
|
|
100167
100535
|
log.warn("export-hap: ptz.continuousMove failed", { meta: {
|
|
100168
100536
|
dir: dir.label,
|
|
100169
|
-
error: errMsg$
|
|
100537
|
+
error: errMsg$8(err)
|
|
100170
100538
|
} });
|
|
100171
100539
|
service.updateCharacteristic(import_dist.Characteristic.On, false);
|
|
100172
100540
|
}
|
|
@@ -100189,7 +100557,7 @@ async function readPresets(bctx) {
|
|
|
100189
100557
|
name: p.name
|
|
100190
100558
|
}));
|
|
100191
100559
|
} catch (err) {
|
|
100192
|
-
ctx.logger.withTags({ deviceId: numericDeviceId }).debug("export-hap: ptz.getPresets failed (non-fatal)", { meta: { error: errMsg$
|
|
100560
|
+
ctx.logger.withTags({ deviceId: numericDeviceId }).debug("export-hap: ptz.getPresets failed (non-fatal)", { meta: { error: errMsg$8(err) } });
|
|
100193
100561
|
return [];
|
|
100194
100562
|
}
|
|
100195
100563
|
}
|
|
@@ -100204,7 +100572,7 @@ async function tryBuildAutotrack(bctx) {
|
|
|
100204
100572
|
const status = await proxy.ptzAutotrack.getStatus({});
|
|
100205
100573
|
if (status && typeof status.enabled === "boolean") service.updateCharacteristic(import_dist.Characteristic.On, status.enabled);
|
|
100206
100574
|
} catch (err) {
|
|
100207
|
-
log.debug("export-hap: ptzAutotrack.getStatus failed (non-fatal)", { meta: { error: errMsg$
|
|
100575
|
+
log.debug("export-hap: ptzAutotrack.getStatus failed (non-fatal)", { meta: { error: errMsg$8(err) } });
|
|
100208
100576
|
}
|
|
100209
100577
|
service.getCharacteristic(import_dist.Characteristic.On).onSet(async (value) => {
|
|
100210
100578
|
const enabled = value === true;
|
|
@@ -100213,13 +100581,13 @@ async function tryBuildAutotrack(bctx) {
|
|
|
100213
100581
|
} catch (err) {
|
|
100214
100582
|
log.warn("export-hap: ptzAutotrack.setEnabled failed", { meta: {
|
|
100215
100583
|
enabled,
|
|
100216
|
-
error: errMsg$
|
|
100584
|
+
error: errMsg$8(err)
|
|
100217
100585
|
} });
|
|
100218
100586
|
}
|
|
100219
100587
|
});
|
|
100220
100588
|
return { async dispose() {} };
|
|
100221
100589
|
}
|
|
100222
|
-
function errMsg$
|
|
100590
|
+
function errMsg$8(err) {
|
|
100223
100591
|
return err instanceof Error ? err.message : String(err);
|
|
100224
100592
|
}
|
|
100225
100593
|
//#endregion
|
|
@@ -101250,13 +101618,13 @@ async function buildChildSwitch(bctx, subtype, deviceType) {
|
|
|
101250
101618
|
const switchStatus = await proxy.switch?.getStatus({});
|
|
101251
101619
|
if (switchStatus && typeof switchStatus.on === "boolean") service.updateCharacteristic(import_dist.Characteristic.On, switchStatus.on);
|
|
101252
101620
|
} catch (err) {
|
|
101253
|
-
log.debug("export-hap: child switch.getStatus failed (non-fatal)", { meta: { error: errMsg$
|
|
101621
|
+
log.debug("export-hap: child switch.getStatus failed (non-fatal)", { meta: { error: errMsg$7(err) } });
|
|
101254
101622
|
}
|
|
101255
101623
|
if (useLightbulb) try {
|
|
101256
101624
|
const status = await proxy.brightness?.getStatus({});
|
|
101257
101625
|
if (status && typeof status.percentage === "number") service.updateCharacteristic(import_dist.Characteristic.Brightness, status.percentage);
|
|
101258
101626
|
} catch (err) {
|
|
101259
|
-
log.debug("export-hap: child brightness.getStatus failed (non-fatal)", { meta: { error: errMsg$
|
|
101627
|
+
log.debug("export-hap: child brightness.getStatus failed (non-fatal)", { meta: { error: errMsg$7(err) } });
|
|
101260
101628
|
}
|
|
101261
101629
|
if (hasSwitch) service.getCharacteristic(import_dist.Characteristic.On).onSet(async (value) => {
|
|
101262
101630
|
const on = value === true;
|
|
@@ -101265,7 +101633,7 @@ async function buildChildSwitch(bctx, subtype, deviceType) {
|
|
|
101265
101633
|
} catch (err) {
|
|
101266
101634
|
log.warn("export-hap: child switch.setState failed", { meta: {
|
|
101267
101635
|
on,
|
|
101268
|
-
error: errMsg$
|
|
101636
|
+
error: errMsg$7(err)
|
|
101269
101637
|
} });
|
|
101270
101638
|
}
|
|
101271
101639
|
});
|
|
@@ -101277,7 +101645,7 @@ async function buildChildSwitch(bctx, subtype, deviceType) {
|
|
|
101277
101645
|
} catch (err) {
|
|
101278
101646
|
log.warn("export-hap: child brightness.setBrightness failed", { meta: {
|
|
101279
101647
|
percentage,
|
|
101280
|
-
error: errMsg$
|
|
101648
|
+
error: errMsg$7(err)
|
|
101281
101649
|
} });
|
|
101282
101650
|
}
|
|
101283
101651
|
});
|
|
@@ -101300,7 +101668,7 @@ async function buildChildSwitch(bctx, subtype, deviceType) {
|
|
|
101300
101668
|
} catch {}
|
|
101301
101669
|
} };
|
|
101302
101670
|
}
|
|
101303
|
-
function errMsg$
|
|
101671
|
+
function errMsg$7(err) {
|
|
101304
101672
|
return err instanceof Error ? err.message : String(err);
|
|
101305
101673
|
}
|
|
101306
101674
|
//#endregion
|
|
@@ -101327,7 +101695,7 @@ async function buildChildServicesFor(input) {
|
|
|
101327
101695
|
for (const h of handles) try {
|
|
101328
101696
|
await h.dispose();
|
|
101329
101697
|
} catch (err) {
|
|
101330
|
-
ctx.logger.withTags({ deviceId: parentNumericId }).debug("export-hap: child service dispose failed (continuing)", { meta: { error: errMsg$
|
|
101698
|
+
ctx.logger.withTags({ deviceId: parentNumericId }).debug("export-hap: child service dispose failed (continuing)", { meta: { error: errMsg$6(err) } });
|
|
101331
101699
|
}
|
|
101332
101700
|
} };
|
|
101333
101701
|
}
|
|
@@ -101343,7 +101711,7 @@ async function listChildren(ctx, parentNumericId) {
|
|
|
101343
101711
|
features: Array.isArray(c.features) ? c.features.filter((f) => typeof f === "string") : []
|
|
101344
101712
|
}));
|
|
101345
101713
|
} catch (err) {
|
|
101346
|
-
ctx.logger.withTags({ deviceId: parentNumericId }).debug("export-hap: deviceManager.getChildren failed (non-fatal)", { meta: { error: errMsg$
|
|
101714
|
+
ctx.logger.withTags({ deviceId: parentNumericId }).debug("export-hap: deviceManager.getChildren failed (non-fatal)", { meta: { error: errMsg$6(err) } });
|
|
101347
101715
|
return [];
|
|
101348
101716
|
}
|
|
101349
101717
|
}
|
|
@@ -101359,7 +101727,7 @@ function asDeviceType(raw) {
|
|
|
101359
101727
|
for (const value of Object.values(DeviceType)) if (value === lower) return value;
|
|
101360
101728
|
return DeviceType.Generic;
|
|
101361
101729
|
}
|
|
101362
|
-
function errMsg$
|
|
101730
|
+
function errMsg$6(err) {
|
|
101363
101731
|
return err instanceof Error ? err.message : String(err);
|
|
101364
101732
|
}
|
|
101365
101733
|
//#endregion
|
|
@@ -101381,12 +101749,18 @@ var SUPPORTED_MAPPER_KINDS = ["camera", "generic"];
|
|
|
101381
101749
|
* doctrine the HA exporter writes down, and the thing that confined the
|
|
101382
101750
|
* previous exporter to cameras when it was ignored.
|
|
101383
101751
|
*
|
|
101384
|
-
* Tier A
|
|
101385
|
-
* feature-dependent shape. `cover`, `climate`, `fan`, `valve`,
|
|
101386
|
-
* `
|
|
101752
|
+
* Tier A plus `alarm-panel`: the types whose HomeKit services exist today and
|
|
101753
|
+
* need no feature-dependent shape. `cover`, `climate`, `fan`, `valve`,
|
|
101754
|
+
* `humidifier`, `water-heater`, `button` and `media-player` are deliberately
|
|
101387
101755
|
* absent — each needs a service whose semantics the table cannot yet honour,
|
|
101388
101756
|
* and offering the tab before the mapping exists is how an operator gets an
|
|
101389
101757
|
* accessory that pairs and does nothing.
|
|
101758
|
+
*
|
|
101759
|
+
* `alarm-panel` is no longer one of them. It maps to `Service.SecuritySystem`
|
|
101760
|
+
* (`builders/generic/security-system.ts`), and the two things the table could
|
|
101761
|
+
* not previously honour are now honoured explicitly: HomeKit is only ever
|
|
101762
|
+
* offered the arm modes the panel accepts, and a panel that requires a PIN
|
|
101763
|
+
* refuses the write out loud instead of pretending to arm.
|
|
101390
101764
|
*/
|
|
101391
101765
|
var HAP_EXPORTABLE_DEVICE_TYPES = [
|
|
101392
101766
|
DeviceType.Camera,
|
|
@@ -101396,6 +101770,7 @@ var HAP_EXPORTABLE_DEVICE_TYPES = [
|
|
|
101396
101770
|
DeviceType.Sensor,
|
|
101397
101771
|
DeviceType.Lock,
|
|
101398
101772
|
DeviceType.Presence,
|
|
101773
|
+
DeviceType.AlarmPanel,
|
|
101399
101774
|
DeviceType.Generic
|
|
101400
101775
|
];
|
|
101401
101776
|
/**
|
|
@@ -101521,17 +101896,17 @@ async function buildCameraAccessory(input) {
|
|
|
101521
101896
|
for (const h of handles) try {
|
|
101522
101897
|
await h.dispose();
|
|
101523
101898
|
} catch (err) {
|
|
101524
|
-
log.debug("export-hap: builder dispose failed (continuing)", { meta: { error: errMsg$
|
|
101899
|
+
log.debug("export-hap: builder dispose failed (continuing)", { meta: { error: errMsg$5(err) } });
|
|
101525
101900
|
}
|
|
101526
101901
|
try {
|
|
101527
101902
|
await streams.dispose();
|
|
101528
101903
|
} catch (err) {
|
|
101529
|
-
log.debug("export-hap: streams dispose failed", { meta: { error: errMsg$
|
|
101904
|
+
log.debug("export-hap: streams dispose failed", { meta: { error: errMsg$5(err) } });
|
|
101530
101905
|
}
|
|
101531
101906
|
}
|
|
101532
101907
|
};
|
|
101533
101908
|
}
|
|
101534
|
-
function errMsg$
|
|
101909
|
+
function errMsg$5(err) {
|
|
101535
101910
|
return err instanceof Error ? err.message : String(err);
|
|
101536
101911
|
}
|
|
101537
101912
|
//#endregion
|
|
@@ -101560,7 +101935,7 @@ function errMsg$4(err) {
|
|
|
101560
101935
|
* counterpart on this service and is deliberately not wired — a Switch that
|
|
101561
101936
|
* silently buzzes a door open would be a second knob nobody asked for.
|
|
101562
101937
|
*/
|
|
101563
|
-
var SUBTYPE = "lock-control";
|
|
101938
|
+
var SUBTYPE$1 = "lock-control";
|
|
101564
101939
|
var readLock = reader(LockControlStatusSchema.pick({ state: true }), (status) => {
|
|
101565
101940
|
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;
|
|
101566
101941
|
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;
|
|
@@ -101576,7 +101951,7 @@ async function buildLockMechanism(bctx) {
|
|
|
101576
101951
|
const { ctx, accessory, proxy, numericDeviceId, displayName } = bctx;
|
|
101577
101952
|
const log = ctx.logger.withTags({ deviceId: numericDeviceId });
|
|
101578
101953
|
const label = hapServiceName([displayName], `Lock ${numericDeviceId}`);
|
|
101579
|
-
const service = accessory.addService(import_dist.Service.LockMechanism, label, SUBTYPE);
|
|
101954
|
+
const service = accessory.addService(import_dist.Service.LockMechanism, label, SUBTYPE$1);
|
|
101580
101955
|
applyServiceLabel(service, label);
|
|
101581
101956
|
const apply = (status, source) => {
|
|
101582
101957
|
const updates = readLock(status);
|
|
@@ -101590,7 +101965,7 @@ async function buildLockMechanism(bctx) {
|
|
|
101590
101965
|
const status = await proxy.lockControl?.getStatus({});
|
|
101591
101966
|
if (status !== void 0 && status !== null) apply(status, "getStatus");
|
|
101592
101967
|
} catch (err) {
|
|
101593
|
-
log.debug("export-hap: lock getStatus hydrate failed (non-fatal)", { meta: { error: errMsg$
|
|
101968
|
+
log.debug("export-hap: lock getStatus hydrate failed (non-fatal)", { meta: { error: errMsg$4(err) } });
|
|
101594
101969
|
}
|
|
101595
101970
|
service.getCharacteristic(import_dist.Characteristic.LockTargetState).onSet(async (value) => {
|
|
101596
101971
|
const secure = value === import_dist.Characteristic.LockTargetState.SECURED;
|
|
@@ -101600,7 +101975,7 @@ async function buildLockMechanism(bctx) {
|
|
|
101600
101975
|
} catch (err) {
|
|
101601
101976
|
log.warn("export-hap: lock command failed", { meta: {
|
|
101602
101977
|
secure,
|
|
101603
|
-
error: errMsg$
|
|
101978
|
+
error: errMsg$4(err)
|
|
101604
101979
|
} });
|
|
101605
101980
|
}
|
|
101606
101981
|
});
|
|
@@ -101614,6 +101989,296 @@ async function buildLockMechanism(bctx) {
|
|
|
101614
101989
|
} catch {}
|
|
101615
101990
|
} };
|
|
101616
101991
|
}
|
|
101992
|
+
function errMsg$4(err) {
|
|
101993
|
+
return err instanceof Error ? err.message : String(err);
|
|
101994
|
+
}
|
|
101995
|
+
//#endregion
|
|
101996
|
+
//#region src/mappers/builders/generic/security-state.ts
|
|
101997
|
+
/** Is this a settled arm state worth remembering? */
|
|
101998
|
+
function armedMemoOf(state) {
|
|
101999
|
+
return state === "armed_home" || state === "armed_away" || state === "armed_night" || state === "armed_vacation" || state === "armed_custom_bypass" ? state : null;
|
|
102000
|
+
}
|
|
102001
|
+
function currentForArmed(state) {
|
|
102002
|
+
switch (state) {
|
|
102003
|
+
case "armed_home":
|
|
102004
|
+
case "armed_custom_bypass": return import_dist.Characteristic.SecuritySystemCurrentState.STAY_ARM;
|
|
102005
|
+
case "armed_night": return import_dist.Characteristic.SecuritySystemCurrentState.NIGHT_ARM;
|
|
102006
|
+
default: return import_dist.Characteristic.SecuritySystemCurrentState.AWAY_ARM;
|
|
102007
|
+
}
|
|
102008
|
+
}
|
|
102009
|
+
function targetForArmed(state) {
|
|
102010
|
+
switch (state) {
|
|
102011
|
+
case "armed_home":
|
|
102012
|
+
case "armed_custom_bypass": return import_dist.Characteristic.SecuritySystemTargetState.STAY_ARM;
|
|
102013
|
+
case "armed_night": return import_dist.Characteristic.SecuritySystemTargetState.NIGHT_ARM;
|
|
102014
|
+
default: return import_dist.Characteristic.SecuritySystemTargetState.AWAY_ARM;
|
|
102015
|
+
}
|
|
102016
|
+
}
|
|
102017
|
+
function securityStateFor(state, memo) {
|
|
102018
|
+
const settled = armedMemoOf(state);
|
|
102019
|
+
if (settled !== null) return {
|
|
102020
|
+
current: currentForArmed(settled),
|
|
102021
|
+
target: targetForArmed(settled)
|
|
102022
|
+
};
|
|
102023
|
+
switch (state) {
|
|
102024
|
+
case "disarmed": return {
|
|
102025
|
+
current: import_dist.Characteristic.SecuritySystemCurrentState.DISARMED,
|
|
102026
|
+
target: import_dist.Characteristic.SecuritySystemTargetState.DISARM
|
|
102027
|
+
};
|
|
102028
|
+
case "arming": return {
|
|
102029
|
+
current: import_dist.Characteristic.SecuritySystemCurrentState.DISARMED,
|
|
102030
|
+
target: memo === null ? null : targetForArmed(memo)
|
|
102031
|
+
};
|
|
102032
|
+
case "disarming": return {
|
|
102033
|
+
current: memo === null ? import_dist.Characteristic.SecuritySystemCurrentState.DISARMED : currentForArmed(memo),
|
|
102034
|
+
target: import_dist.Characteristic.SecuritySystemTargetState.DISARM
|
|
102035
|
+
};
|
|
102036
|
+
case "pending": return {
|
|
102037
|
+
current: memo === null ? import_dist.Characteristic.SecuritySystemCurrentState.DISARMED : currentForArmed(memo),
|
|
102038
|
+
target: memo === null ? null : targetForArmed(memo)
|
|
102039
|
+
};
|
|
102040
|
+
default: return {
|
|
102041
|
+
current: import_dist.Characteristic.SecuritySystemCurrentState.ALARM_TRIGGERED,
|
|
102042
|
+
target: memo === null ? null : targetForArmed(memo)
|
|
102043
|
+
};
|
|
102044
|
+
}
|
|
102045
|
+
}
|
|
102046
|
+
/**
|
|
102047
|
+
* The arm mode behind a HomeKit target, or `null` for DISARM and for anything
|
|
102048
|
+
* outside the four values HomeKit defines.
|
|
102049
|
+
*
|
|
102050
|
+
* `null` is not an error the caller can ignore: DISARM is a different COMMAND,
|
|
102051
|
+
* and a value HomeKit never sends is a write this builder refuses to translate.
|
|
102052
|
+
*/
|
|
102053
|
+
function alarmArmModeFor(target) {
|
|
102054
|
+
switch (target) {
|
|
102055
|
+
case import_dist.Characteristic.SecuritySystemTargetState.STAY_ARM: return "home";
|
|
102056
|
+
case import_dist.Characteristic.SecuritySystemTargetState.AWAY_ARM: return "away";
|
|
102057
|
+
case import_dist.Characteristic.SecuritySystemTargetState.NIGHT_ARM: return "night";
|
|
102058
|
+
default: return null;
|
|
102059
|
+
}
|
|
102060
|
+
}
|
|
102061
|
+
//#endregion
|
|
102062
|
+
//#region src/mappers/builders/generic/security-target.ts
|
|
102063
|
+
/**
|
|
102064
|
+
* The panel modes behind each HomeKit target, PRIMARY first.
|
|
102065
|
+
*
|
|
102066
|
+
* The primary is the mode `alarmArmModeFor` names; the secondary is the other
|
|
102067
|
+
* mode `security-state.ts` reports through the same HomeKit value, so the two
|
|
102068
|
+
* modules agree in both directions by construction.
|
|
102069
|
+
*/
|
|
102070
|
+
var MODES_BY_TARGET = new Map([
|
|
102071
|
+
[import_dist.Characteristic.SecuritySystemTargetState.STAY_ARM, ["home", "custom_bypass"]],
|
|
102072
|
+
[import_dist.Characteristic.SecuritySystemTargetState.AWAY_ARM, ["away", "vacation"]],
|
|
102073
|
+
[import_dist.Characteristic.SecuritySystemTargetState.NIGHT_ARM, ["night"]]
|
|
102074
|
+
]);
|
|
102075
|
+
/** Arm targets in the order HomeKit numbers them; DISARM is appended last. */
|
|
102076
|
+
var ARM_TARGETS = [
|
|
102077
|
+
import_dist.Characteristic.SecuritySystemTargetState.STAY_ARM,
|
|
102078
|
+
import_dist.Characteristic.SecuritySystemTargetState.AWAY_ARM,
|
|
102079
|
+
import_dist.Characteristic.SecuritySystemTargetState.NIGHT_ARM
|
|
102080
|
+
];
|
|
102081
|
+
/**
|
|
102082
|
+
* The `validValues` for `SecuritySystemTargetState`, or `null` to leave
|
|
102083
|
+
* HomeKit's own four values in place.
|
|
102084
|
+
*
|
|
102085
|
+
* DISARM is always present: disarming is not one of the panel's arm modes and
|
|
102086
|
+
* a panel that cannot be disarmed is not a thing this cap can express.
|
|
102087
|
+
*/
|
|
102088
|
+
function targetValidValuesFor(availableModes) {
|
|
102089
|
+
if (availableModes.length === 0) return null;
|
|
102090
|
+
return [...ARM_TARGETS.filter((target) => (MODES_BY_TARGET.get(target) ?? []).some((mode) => availableModes.includes(mode))), import_dist.Characteristic.SecuritySystemTargetState.DISARM];
|
|
102091
|
+
}
|
|
102092
|
+
/**
|
|
102093
|
+
* The arm mode to send for a HomeKit target, or `null` when there is none.
|
|
102094
|
+
*
|
|
102095
|
+
* `null` is not a shrug the caller may swallow: DISARM is a different command,
|
|
102096
|
+
* and an arm target the panel accepts no mode for is a write this module
|
|
102097
|
+
* refuses to translate rather than guess at.
|
|
102098
|
+
*/
|
|
102099
|
+
function armModeForTarget(target, availableModes) {
|
|
102100
|
+
const primary = alarmArmModeFor(target);
|
|
102101
|
+
if (primary === null) return null;
|
|
102102
|
+
if (availableModes.length === 0) return primary;
|
|
102103
|
+
return (MODES_BY_TARGET.get(target) ?? [primary]).find((mode) => availableModes.includes(mode)) ?? null;
|
|
102104
|
+
}
|
|
102105
|
+
//#endregion
|
|
102106
|
+
//#region src/mappers/builders/generic/security-system.ts
|
|
102107
|
+
/**
|
|
102108
|
+
* `alarm-panel` → `Service.SecuritySystem`.
|
|
102109
|
+
*
|
|
102110
|
+
* The lock builder's shape (a current/target pair, a hydrate, an `onSet`, a
|
|
102111
|
+
* slice subscription, a dispose) applied to the one device on the fleet where
|
|
102112
|
+
* reporting a state that is not true has a consequence worse than a stalled
|
|
102113
|
+
* motor. The mapping itself is NOT here: `security-state.ts` owns what the
|
|
102114
|
+
* panel's state looks like to HomeKit and `security-target.ts` owns what
|
|
102115
|
+
* HomeKit may ask for, both pure and both tested on their own. This file is
|
|
102116
|
+
* the service around them.
|
|
102117
|
+
*
|
|
102118
|
+
* ## The memo
|
|
102119
|
+
*
|
|
102120
|
+
* `pending`, `disarming` and `triggered` do not carry the mode the panel was
|
|
102121
|
+
* armed to — only the last settled state knows it. This builder is the caller
|
|
102122
|
+
* `security-state.ts` describes: it remembers the last settled arm and forgets
|
|
102123
|
+
* it on `disarmed`, because a memo that outlives a disarm makes the next
|
|
102124
|
+
* `arming` claim a target nobody asked for.
|
|
102125
|
+
*
|
|
102126
|
+
* The memo is deliberately NOT seeded from the controller's own write. HomeKit
|
|
102127
|
+
* already holds the target the operator just set; not writing it back is
|
|
102128
|
+
* exactly right. The cost is a panel armed from its own keypad during an exit
|
|
102129
|
+
* delay, where the target stays at whatever HomeKit last knew — a stale target
|
|
102130
|
+
* for the length of the delay, against inventing an intent, and the invention
|
|
102131
|
+
* is worse.
|
|
102132
|
+
*
|
|
102133
|
+
* ## `requiresCode`: the arm is REFUSED, not attempted
|
|
102134
|
+
*
|
|
102135
|
+
* HomeKit's SecuritySystem has no PIN prompt — there is no characteristic for
|
|
102136
|
+
* it and no way to ask the operator mid-write. So a panel that requires a code
|
|
102137
|
+
* cannot be armed or disarmed from the Home app, and this builder says so
|
|
102138
|
+
* twice: the write fails with `INSUFFICIENT_AUTHORIZATION` (iOS renders the
|
|
102139
|
+
* tile's failure) and a WARN names the device, the command and the mode.
|
|
102140
|
+
*
|
|
102141
|
+
* Sending the command code-less and letting the panel reject it was the
|
|
102142
|
+
* alternative. It is worse: the refusal costs a round trip, it is
|
|
102143
|
+
* indistinguishable from a broken panel in the log, and repeated code-less
|
|
102144
|
+
* attempts are what locks a real alarm panel out.
|
|
102145
|
+
*/
|
|
102146
|
+
var SUBTYPE = "alarm-panel";
|
|
102147
|
+
/** The subset of the status this builder reads. */
|
|
102148
|
+
var PanelReadSchema = AlarmPanelStatusSchema.pick({
|
|
102149
|
+
state: true,
|
|
102150
|
+
availableModes: true,
|
|
102151
|
+
requiresCode: true
|
|
102152
|
+
});
|
|
102153
|
+
/**
|
|
102154
|
+
* Turn a panel status into characteristic writes, folding the memo.
|
|
102155
|
+
*
|
|
102156
|
+
* A payload that does not match the cap's own schema yields NO updates and
|
|
102157
|
+
* leaves the memo alone — it is a status we could not read, not a panel that
|
|
102158
|
+
* changed. The caller logs the drop; a frozen characteristic is otherwise
|
|
102159
|
+
* indistinguishable from a quiet panel.
|
|
102160
|
+
*/
|
|
102161
|
+
function securityUpdatesFor(status, memo) {
|
|
102162
|
+
const parsed = PanelReadSchema.safeParse(status);
|
|
102163
|
+
if (!parsed.success) return {
|
|
102164
|
+
updates: [],
|
|
102165
|
+
memo,
|
|
102166
|
+
panel: null
|
|
102167
|
+
};
|
|
102168
|
+
const nextMemo = parsed.data.state === "disarmed" ? null : armedMemoOf(parsed.data.state) ?? memo;
|
|
102169
|
+
const { current, target } = securityStateFor(parsed.data.state, nextMemo);
|
|
102170
|
+
return {
|
|
102171
|
+
updates: [{
|
|
102172
|
+
characteristic: import_dist.Characteristic.SecuritySystemCurrentState,
|
|
102173
|
+
value: current
|
|
102174
|
+
}, ...target === null ? [] : [{
|
|
102175
|
+
characteristic: import_dist.Characteristic.SecuritySystemTargetState,
|
|
102176
|
+
value: target
|
|
102177
|
+
}]],
|
|
102178
|
+
memo: nextMemo,
|
|
102179
|
+
panel: {
|
|
102180
|
+
availableModes: parsed.data.availableModes,
|
|
102181
|
+
requiresCode: parsed.data.requiresCode
|
|
102182
|
+
}
|
|
102183
|
+
};
|
|
102184
|
+
}
|
|
102185
|
+
async function buildSecuritySystem(bctx) {
|
|
102186
|
+
const { ctx, accessory, proxy, numericDeviceId, displayName } = bctx;
|
|
102187
|
+
const log = ctx.logger.withTags({ deviceId: numericDeviceId });
|
|
102188
|
+
const label = hapServiceName([displayName], `Alarm ${numericDeviceId}`);
|
|
102189
|
+
const service = accessory.addService(import_dist.Service.SecuritySystem, label, SUBTYPE);
|
|
102190
|
+
applyServiceLabel(service, label);
|
|
102191
|
+
let memo = null;
|
|
102192
|
+
let availableModes = [];
|
|
102193
|
+
let requiresCode = false;
|
|
102194
|
+
/** Only log the `validValues` narrowing when it actually changes. */
|
|
102195
|
+
let lastValidValues = "";
|
|
102196
|
+
const applyValidValues = () => {
|
|
102197
|
+
const validValues = targetValidValuesFor(availableModes);
|
|
102198
|
+
if (validValues === null) {
|
|
102199
|
+
if (lastValidValues !== "unconstrained") {
|
|
102200
|
+
lastValidValues = "unconstrained";
|
|
102201
|
+
log.info("export-hap: alarm panel named no arm modes — leaving HomeKit’s targets unconstrained", { meta: { subtype: SUBTYPE } });
|
|
102202
|
+
}
|
|
102203
|
+
return;
|
|
102204
|
+
}
|
|
102205
|
+
const key = validValues.join(",");
|
|
102206
|
+
if (key === lastValidValues) return;
|
|
102207
|
+
lastValidValues = key;
|
|
102208
|
+
service.getCharacteristic(import_dist.Characteristic.SecuritySystemTargetState).setProps({ validValues: [...validValues] });
|
|
102209
|
+
log.info("export-hap: alarm panel target constrained to the modes it accepts", { meta: {
|
|
102210
|
+
subtype: SUBTYPE,
|
|
102211
|
+
availableModes: [...availableModes],
|
|
102212
|
+
validValues
|
|
102213
|
+
} });
|
|
102214
|
+
};
|
|
102215
|
+
const apply = (status, source) => {
|
|
102216
|
+
const next = securityUpdatesFor(status, memo);
|
|
102217
|
+
if (next.updates.length === 0) {
|
|
102218
|
+
log.debug("export-hap: alarm panel status did not match the cap schema — no update", { meta: {
|
|
102219
|
+
subtype: SUBTYPE,
|
|
102220
|
+
source
|
|
102221
|
+
} });
|
|
102222
|
+
return;
|
|
102223
|
+
}
|
|
102224
|
+
memo = next.memo;
|
|
102225
|
+
if (next.panel !== null) {
|
|
102226
|
+
availableModes = next.panel.availableModes;
|
|
102227
|
+
requiresCode = next.panel.requiresCode;
|
|
102228
|
+
applyValidValues();
|
|
102229
|
+
}
|
|
102230
|
+
applyUpdates(service, next.updates);
|
|
102231
|
+
};
|
|
102232
|
+
try {
|
|
102233
|
+
const status = await proxy.alarmPanel?.getStatus({});
|
|
102234
|
+
if (status !== void 0 && status !== null) apply(status, "getStatus");
|
|
102235
|
+
} catch (err) {
|
|
102236
|
+
log.debug("export-hap: alarm panel getStatus hydrate failed (non-fatal)", { meta: { error: errMsg$3(err) } });
|
|
102237
|
+
}
|
|
102238
|
+
service.getCharacteristic(import_dist.Characteristic.SecuritySystemTargetState).onSet(async (value) => {
|
|
102239
|
+
const target = typeof value === "number" ? value : Number(value);
|
|
102240
|
+
const disarm = target === import_dist.Characteristic.SecuritySystemTargetState.DISARM;
|
|
102241
|
+
const mode = disarm ? null : armModeForTarget(target, availableModes);
|
|
102242
|
+
if (requiresCode) {
|
|
102243
|
+
log.warn("export-hap: alarm panel requires a PIN — HomeKit cannot supply one, command REFUSED", { meta: {
|
|
102244
|
+
subtype: SUBTYPE,
|
|
102245
|
+
command: disarm ? "disarm" : "arm",
|
|
102246
|
+
mode,
|
|
102247
|
+
target
|
|
102248
|
+
} });
|
|
102249
|
+
throw new import_dist.HapStatusError(import_dist.HAPStatus.INSUFFICIENT_AUTHORIZATION);
|
|
102250
|
+
}
|
|
102251
|
+
if (!disarm && mode === null) {
|
|
102252
|
+
log.warn("export-hap: alarm panel cannot honour this HomeKit arm target — REFUSED", { meta: {
|
|
102253
|
+
subtype: SUBTYPE,
|
|
102254
|
+
target,
|
|
102255
|
+
availableModes: [...availableModes]
|
|
102256
|
+
} });
|
|
102257
|
+
throw new import_dist.HapStatusError(import_dist.HAPStatus.INVALID_VALUE_IN_REQUEST);
|
|
102258
|
+
}
|
|
102259
|
+
try {
|
|
102260
|
+
if (mode === null) await proxy.alarmPanel?.disarm({});
|
|
102261
|
+
else await proxy.alarmPanel?.arm({ mode });
|
|
102262
|
+
} catch (err) {
|
|
102263
|
+
log.warn("export-hap: alarm panel command failed", { meta: {
|
|
102264
|
+
subtype: SUBTYPE,
|
|
102265
|
+
command: mode === null ? "disarm" : "arm",
|
|
102266
|
+
mode,
|
|
102267
|
+
error: errMsg$3(err)
|
|
102268
|
+
} });
|
|
102269
|
+
throw new import_dist.HapStatusError(import_dist.HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
102270
|
+
}
|
|
102271
|
+
});
|
|
102272
|
+
const unsubscribe = proxy.state.alarmPanel?.subscribe((value) => {
|
|
102273
|
+
if (value === void 0 || value === null) return;
|
|
102274
|
+
apply(value, "slice");
|
|
102275
|
+
}) ?? null;
|
|
102276
|
+
return { async dispose() {
|
|
102277
|
+
try {
|
|
102278
|
+
unsubscribe?.();
|
|
102279
|
+
} catch {}
|
|
102280
|
+
} };
|
|
102281
|
+
}
|
|
101617
102282
|
function errMsg$3(err) {
|
|
101618
102283
|
return err instanceof Error ? err.message : String(err);
|
|
101619
102284
|
}
|
|
@@ -101688,11 +102353,16 @@ function errMsg$2(err) {
|
|
|
101688
102353
|
*
|
|
101689
102354
|
* ## Tier
|
|
101690
102355
|
*
|
|
101691
|
-
* Tier A
|
|
101692
|
-
* feature-dependent shape
|
|
101693
|
-
*
|
|
101694
|
-
*
|
|
101695
|
-
*
|
|
102356
|
+
* Tier A, plus `alarm-panel`: the caps whose HomeKit service exists today and
|
|
102357
|
+
* needs no feature-dependent shape. `cover` still needs `cover-positionable`
|
|
102358
|
+
* and `climate-control` the dual-setpoint split; those are a separate task,
|
|
102359
|
+
* and adding a row here must never mean adding a service whose semantics this
|
|
102360
|
+
* file cannot fully honour.
|
|
102361
|
+
*
|
|
102362
|
+
* `alarm-panel` earned its row by answering the two questions that kept it
|
|
102363
|
+
* out: a target the panel would refuse is never offered (`availableModes` →
|
|
102364
|
+
* `validValues`, `security-target.ts`) and an arm a PIN-gated panel cannot
|
|
102365
|
+
* accept is refused out loud rather than attempted (`security-system.ts`).
|
|
101696
102366
|
*/
|
|
101697
102367
|
/** HomeKit's floor for `CurrentAmbientLightLevel`; 0 lux is out of range. */
|
|
101698
102368
|
var MIN_LUX = 1e-4;
|
|
@@ -101834,6 +102504,14 @@ var HAP_CAP_SERVICES = [
|
|
|
101834
102504
|
displayName: name
|
|
101835
102505
|
})
|
|
101836
102506
|
},
|
|
102507
|
+
{
|
|
102508
|
+
caps: ["alarm-panel"],
|
|
102509
|
+
label: "Alarm",
|
|
102510
|
+
build: ({ bctx, name }) => buildSecuritySystem({
|
|
102511
|
+
...bctx,
|
|
102512
|
+
displayName: name
|
|
102513
|
+
})
|
|
102514
|
+
},
|
|
101837
102515
|
{
|
|
101838
102516
|
caps: ["battery"],
|
|
101839
102517
|
label: BATTERY_SPEC.label,
|
|
@@ -101871,7 +102549,8 @@ var ACCESSORY_CATEGORY_BY_TYPE = {
|
|
|
101871
102549
|
[DeviceType.Siren]: import_dist.Categories.SWITCH,
|
|
101872
102550
|
[DeviceType.Lock]: import_dist.Categories.DOOR_LOCK,
|
|
101873
102551
|
[DeviceType.Sensor]: import_dist.Categories.SENSOR,
|
|
101874
|
-
[DeviceType.Presence]: import_dist.Categories.SENSOR
|
|
102552
|
+
[DeviceType.Presence]: import_dist.Categories.SENSOR,
|
|
102553
|
+
[DeviceType.AlarmPanel]: import_dist.Categories.SECURITY_SYSTEM
|
|
101875
102554
|
};
|
|
101876
102555
|
function accessoryCategoryFor(deviceType) {
|
|
101877
102556
|
return ACCESSORY_CATEGORY_BY_TYPE[deviceType] ?? import_dist.Categories.OTHER;
|
|
@@ -102256,6 +102935,12 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102256
102935
|
* hardware init.
|
|
102257
102936
|
*/
|
|
102258
102937
|
decodeMemos = createHapDecodeMemos();
|
|
102938
|
+
/**
|
|
102939
|
+
* THE bridge. Lazily created and published the first time a non-camera
|
|
102940
|
+
* accessory needs it; never torn down while the addon runs, because an
|
|
102941
|
+
* unpublish would drop a pairing the operator already entered a code for.
|
|
102942
|
+
*/
|
|
102943
|
+
bridgeHost = null;
|
|
102259
102944
|
constructor() {
|
|
102260
102945
|
super({ ...DEFAULT_CONFIG });
|
|
102261
102946
|
}
|
|
@@ -102263,6 +102948,13 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102263
102948
|
const identity = await this.ensureIdentity();
|
|
102264
102949
|
this.pincode = identity.pincode;
|
|
102265
102950
|
this.bind = this.config.interfaceName || void 0;
|
|
102951
|
+
this.bridgeHost = new BridgeHost({
|
|
102952
|
+
displayName: this.config.bridgeName,
|
|
102953
|
+
uuid: identity.uuid,
|
|
102954
|
+
pincode: identity.pincode,
|
|
102955
|
+
bind: this.bind,
|
|
102956
|
+
logger: this.ctx.logger
|
|
102957
|
+
});
|
|
102266
102958
|
try {
|
|
102267
102959
|
await initHapStorage(path.join(this.ctx.dataDir, "hap-store"));
|
|
102268
102960
|
} catch (err) {
|
|
@@ -102291,6 +102983,7 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102291
102983
|
}
|
|
102292
102984
|
this.ctx.addDisposer(async () => {
|
|
102293
102985
|
await this.detachAll();
|
|
102986
|
+
await this.bridgeHost?.dispose();
|
|
102294
102987
|
});
|
|
102295
102988
|
this.subscribeDeviceProvisionedForReconcile();
|
|
102296
102989
|
this.subscribeDeviceReadyForReconcile();
|
|
@@ -102447,16 +103140,24 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102447
103140
|
decodeMemos: this.decodeMemos,
|
|
102448
103141
|
hapDeviceSettings: {
|
|
102449
103142
|
streamPreference: entrySettings.streamPreference ?? "auto",
|
|
102450
|
-
hksvRecording: resolveHksvRecording(entrySettings)
|
|
103143
|
+
hksvRecording: resolveHksvRecording(entrySettings),
|
|
103144
|
+
allowTranscode: entrySettings.allowTranscode !== false
|
|
102451
103145
|
}
|
|
102452
103146
|
}
|
|
102453
103147
|
});
|
|
102454
|
-
|
|
102455
|
-
|
|
102456
|
-
|
|
102457
|
-
bind: this.bind,
|
|
102458
|
-
logger: this.ctx.logger
|
|
103148
|
+
const wantsBridge = shouldBridge({
|
|
103149
|
+
mapperKind: entry.mapperKind,
|
|
103150
|
+
useBridge: entry.settings?.useBridge
|
|
102459
103151
|
});
|
|
103152
|
+
for (const accessory of mapper.accessories) {
|
|
103153
|
+
if (wantsBridge && this.bridgeHost !== null && await this.bridgeHost.add(accessory)) continue;
|
|
103154
|
+
await publishStandalone(accessory, {
|
|
103155
|
+
pincode: this.pincode,
|
|
103156
|
+
port: 0,
|
|
103157
|
+
bind: this.bind,
|
|
103158
|
+
logger: this.ctx.logger
|
|
103159
|
+
});
|
|
103160
|
+
}
|
|
102460
103161
|
this.exposed.set(entry.deviceId, mapper);
|
|
102461
103162
|
return { childAccessoryUuids: [] };
|
|
102462
103163
|
}
|
|
@@ -102469,7 +103170,13 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102469
103170
|
const mapper = this.exposed.get(deviceId);
|
|
102470
103171
|
if (!mapper) return;
|
|
102471
103172
|
this.exposed.delete(deviceId);
|
|
102472
|
-
for (const accessory of mapper.accessories)
|
|
103173
|
+
for (const accessory of mapper.accessories) {
|
|
103174
|
+
if (this.bridgeHost?.holds(accessory) === true) {
|
|
103175
|
+
this.bridgeHost.remove(accessory);
|
|
103176
|
+
continue;
|
|
103177
|
+
}
|
|
103178
|
+
await unpublishAccessory(accessory, this.ctx.logger);
|
|
103179
|
+
}
|
|
102473
103180
|
await mapper.dispose().catch((err) => {
|
|
102474
103181
|
this.ctx.logger.withTags({ deviceId: Number.parseInt(deviceId, 10) }).warn("export-hap: mapper dispose failed", { meta: { error: errMsg(err) } });
|
|
102475
103182
|
});
|
|
@@ -102764,42 +103471,79 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102764
103471
|
const enabledKey = `hap:${deviceId}:enabled`;
|
|
102765
103472
|
const streamPreferenceKey = `hap:${deviceId}:streamPreference`;
|
|
102766
103473
|
const hksvKey = `hap:${deviceId}:hksvRecording`;
|
|
103474
|
+
const useBridgeKey = `hap:${deviceId}:useBridge`;
|
|
103475
|
+
const allowTranscodeKey = `hap:${deviceId}:allowTranscode`;
|
|
102767
103476
|
const mapper = this.exposed.get(String(deviceId)) ?? null;
|
|
102768
103477
|
const paired = mapper ? accessoryPaired(mapper.accessory) : false;
|
|
103478
|
+
const bridged = mapper !== null && this.bridgeHost?.holds(mapper.accessory) === true;
|
|
102769
103479
|
const name = entry?.displayName ?? `Device ${deviceId}`;
|
|
102770
|
-
const
|
|
103480
|
+
const bridgePaired = this.bridgeHost?.accessory !== null && this.bridgeHost?.accessory !== void 0 ? accessoryPaired(this.bridgeHost.accessory) : false;
|
|
103481
|
+
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}.`;
|
|
103482
|
+
const qrSource = bridged ? this.bridgeHost?.accessory ?? null : mapper?.accessory ?? null;
|
|
102771
103483
|
let qrValue = "";
|
|
102772
|
-
if (
|
|
102773
|
-
qrValue =
|
|
103484
|
+
if (qrSource) try {
|
|
103485
|
+
qrValue = qrSource.setupURI();
|
|
102774
103486
|
} catch (err) {
|
|
102775
103487
|
this.ctx.logger.withTags({ deviceId }).debug("export-hap: setupURI failed for per-device contribution", { meta: { error: errMsg(err) } });
|
|
102776
103488
|
}
|
|
102777
|
-
const
|
|
102778
|
-
type: "select",
|
|
102779
|
-
key: streamPreferenceKey,
|
|
102780
|
-
label: "Source stream (HomeKit)",
|
|
102781
|
-
description: "Which camstack profile slot HomeKit pulls. Auto = the broker picks the slot closest to 1080p at session start.",
|
|
102782
|
-
options: HAP_STREAM_PREFERENCE_OPTIONS,
|
|
102783
|
-
required: true,
|
|
102784
|
-
value: settings.streamPreference,
|
|
102785
|
-
showWhen: {
|
|
102786
|
-
field: enabledKey,
|
|
102787
|
-
equals: true
|
|
102788
|
-
},
|
|
102789
|
-
immediate: true
|
|
102790
|
-
}, {
|
|
103489
|
+
const bridgeFields = kind === "camera" ? [] : [{
|
|
102791
103490
|
type: "boolean",
|
|
102792
|
-
key:
|
|
102793
|
-
label: "
|
|
102794
|
-
description: "
|
|
103491
|
+
key: useBridgeKey,
|
|
103492
|
+
label: "Export through the bridge",
|
|
103493
|
+
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.",
|
|
102795
103494
|
style: "switch",
|
|
102796
|
-
value:
|
|
103495
|
+
value: shouldBridge({
|
|
103496
|
+
mapperKind: kind,
|
|
103497
|
+
useBridge: settings.useBridge
|
|
103498
|
+
}),
|
|
102797
103499
|
showWhen: {
|
|
102798
103500
|
field: enabledKey,
|
|
102799
103501
|
equals: true
|
|
102800
103502
|
},
|
|
102801
103503
|
immediate: true
|
|
102802
103504
|
}];
|
|
103505
|
+
const cameraFields = kind !== "camera" ? [] : [
|
|
103506
|
+
{
|
|
103507
|
+
type: "select",
|
|
103508
|
+
key: streamPreferenceKey,
|
|
103509
|
+
label: "Source stream (HomeKit)",
|
|
103510
|
+
description: "Which camstack profile slot HomeKit pulls. Auto = the broker picks the slot closest to 1080p at session start.",
|
|
103511
|
+
options: HAP_STREAM_PREFERENCE_OPTIONS,
|
|
103512
|
+
required: true,
|
|
103513
|
+
value: settings.streamPreference,
|
|
103514
|
+
showWhen: {
|
|
103515
|
+
field: enabledKey,
|
|
103516
|
+
equals: true
|
|
103517
|
+
},
|
|
103518
|
+
immediate: true
|
|
103519
|
+
},
|
|
103520
|
+
{
|
|
103521
|
+
type: "boolean",
|
|
103522
|
+
key: hksvKey,
|
|
103523
|
+
label: "HomeKit recording (Secure Video)",
|
|
103524
|
+
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).",
|
|
103525
|
+
style: "switch",
|
|
103526
|
+
value: resolveHksvRecording(settings),
|
|
103527
|
+
showWhen: {
|
|
103528
|
+
field: enabledKey,
|
|
103529
|
+
equals: true
|
|
103530
|
+
},
|
|
103531
|
+
immediate: true
|
|
103532
|
+
},
|
|
103533
|
+
{
|
|
103534
|
+
type: "boolean",
|
|
103535
|
+
key: allowTranscodeKey,
|
|
103536
|
+
label: "Allow transcoding for HomeKit",
|
|
103537
|
+
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.",
|
|
103538
|
+
style: "switch",
|
|
103539
|
+
value: settings.allowTranscode !== false,
|
|
103540
|
+
showWhen: {
|
|
103541
|
+
field: enabledKey,
|
|
103542
|
+
equals: true
|
|
103543
|
+
},
|
|
103544
|
+
immediate: true
|
|
103545
|
+
}
|
|
103546
|
+
];
|
|
102803
103547
|
return {
|
|
102804
103548
|
tabs: [{
|
|
102805
103549
|
id: "export",
|
|
@@ -102844,6 +103588,7 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102844
103588
|
value: enabled,
|
|
102845
103589
|
immediate: true
|
|
102846
103590
|
},
|
|
103591
|
+
...bridgeFields,
|
|
102847
103592
|
...cameraFields
|
|
102848
103593
|
]
|
|
102849
103594
|
}]
|
|
@@ -102869,14 +103614,20 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102869
103614
|
const enabledKey = `hap:${deviceId}:enabled`;
|
|
102870
103615
|
const streamPreferenceKey = `hap:${deviceId}:streamPreference`;
|
|
102871
103616
|
const hksvKey = `hap:${deviceId}:hksvRecording`;
|
|
103617
|
+
const useBridgeKey = `hap:${deviceId}:useBridge`;
|
|
103618
|
+
const allowTranscodeKey = `hap:${deviceId}:allowTranscode`;
|
|
102872
103619
|
const enabledValue = enabledKey in patch ? Boolean(patch[enabledKey]) : wasEnabled;
|
|
102873
103620
|
const streamPreferenceRaw = streamPreferenceKey in patch ? patch[streamPreferenceKey] : current?.settings?.streamPreference;
|
|
102874
103621
|
const streamPreference = typeof streamPreferenceRaw === "string" && streamPreferenceRaw.trim().length > 0 ? streamPreferenceRaw : "auto";
|
|
102875
103622
|
const hksvRecording = hksvKey in patch ? Boolean(patch[hksvKey]) : resolveHksvRecording(current?.settings);
|
|
103623
|
+
const useBridge = useBridgeKey in patch ? Boolean(patch[useBridgeKey]) : current?.settings?.useBridge !== false;
|
|
103624
|
+
const allowTranscode = allowTranscodeKey in patch ? Boolean(patch[allowTranscodeKey]) : current?.settings?.allowTranscode !== false;
|
|
102876
103625
|
const nextSettings = {
|
|
102877
103626
|
...current?.settings ?? DEFAULT_DEVICE_SETTINGS,
|
|
102878
103627
|
streamPreference,
|
|
102879
|
-
hksvRecording
|
|
103628
|
+
hksvRecording,
|
|
103629
|
+
useBridge,
|
|
103630
|
+
allowTranscode
|
|
102880
103631
|
};
|
|
102881
103632
|
if (!enabledValue) {
|
|
102882
103633
|
if (wasEnabled) await this.unexposeDevice(deviceIdStr);
|
|
@@ -102889,8 +103640,17 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102889
103640
|
}
|
|
102890
103641
|
const currentPref = current?.settings?.streamPreference ?? "auto";
|
|
102891
103642
|
const currentHksv = resolveHksvRecording(current?.settings);
|
|
103643
|
+
const mapperKind = current?.mapperKind ?? "generic";
|
|
103644
|
+
const wasBridged = shouldBridge({
|
|
103645
|
+
mapperKind,
|
|
103646
|
+
useBridge: current?.settings?.useBridge
|
|
103647
|
+
});
|
|
103648
|
+
const willBridge = shouldBridge({
|
|
103649
|
+
mapperKind,
|
|
103650
|
+
useBridge
|
|
103651
|
+
});
|
|
102892
103652
|
await this.updateEntrySettings(deviceIdStr, nextSettings);
|
|
102893
|
-
if (currentPref !== streamPreference || currentHksv !== hksvRecording) {
|
|
103653
|
+
if (currentPref !== streamPreference || currentHksv !== hksvRecording || wasBridged !== willBridge) {
|
|
102894
103654
|
log.info("export-hap: per-camera export settings changed — refreshing accessory", { meta: {
|
|
102895
103655
|
streamPreference: {
|
|
102896
103656
|
from: currentPref,
|
|
@@ -102899,10 +103659,14 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
102899
103659
|
hksvRecording: {
|
|
102900
103660
|
from: currentHksv,
|
|
102901
103661
|
to: hksvRecording
|
|
103662
|
+
},
|
|
103663
|
+
bridged: {
|
|
103664
|
+
from: wasBridged,
|
|
103665
|
+
to: willBridge
|
|
102902
103666
|
}
|
|
102903
103667
|
} });
|
|
102904
103668
|
try {
|
|
102905
|
-
await this.unexposeDevice(deviceIdStr, { clearPairing:
|
|
103669
|
+
await this.unexposeDevice(deviceIdStr, { clearPairing: wasBridged !== willBridge });
|
|
102906
103670
|
await this.exposeDevice(deviceIdStr);
|
|
102907
103671
|
} catch (err) {
|
|
102908
103672
|
log.warn("export-hap: failed to refresh accessory after a settings change", { meta: { error: errMsg(err) } });
|