@camstack/server 1.2.751 → 1.2.753
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/CHANGELOG.md +16 -0
- package/dist/api/trpc/generated-cap-routers.js +10 -0
- package/dist/core/moleculer/moleculer.service.js +13 -1
- package/package.json +11 -8
- package/system/dist/{agent-https-Oc0Go3Gs.js → agent-https-B0bjQVfy.js} +1 -1
- package/system/dist/{agent-https-DoGV9jKg.mjs → agent-https-cxghRfum.mjs} +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composer.addon.js +18 -22
- package/system/dist/builtins/composer/composer.addon.mjs +17 -21
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/composition-api.d.ts +4 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +232 -15
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +232 -15
- package/system/dist/builtins/core-blocks/running-proposal.d.ts +32 -0
- package/system/dist/builtins/device-history/device-history.addon.js +24 -23
- package/system/dist/builtins/device-history/device-history.addon.mjs +3 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +3 -3
- package/system/dist/builtins/keychain/index.mjs +3 -3
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/local-network.addon.js +2 -2
- package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +5 -1
- package/system/dist/builtins/snapshot/index.mjs +5 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +2 -2
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2 -2
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +284 -284
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{retention-C-lijsmN.mjs → capture-engine-CfJdhMTH.mjs} +2 -246
- package/system/dist/{retention-WjI-Op7G.js → capture-engine-eRAebXP1.js} +1 -305
- package/system/dist/{composition-sources-Bxahhz4f.js → composition-sources-BvDYLpw_.js} +1 -1
- package/system/dist/{composition-sources-CzRiSzCV.mjs → composition-sources-ChtkMq1Q.mjs} +1 -1
- package/system/dist/{constants-uI6uXyjP.mjs → constants-CYNsr0lM.mjs} +1 -1
- package/system/dist/{constants-0rC5QY6i.js → constants-DkC9-VOa.js} +1 -1
- package/system/dist/{device-ca-CL_Arugd.js → device-ca-BxInMpK2.js} +1 -1
- package/system/dist/{device-ca-D7TyMlsS.mjs → device-ca-CQg3PTnE.mjs} +1 -1
- package/system/dist/{dist-Iq3vrBOE.mjs → dist-C5eIFTMo.mjs} +752 -554
- package/system/dist/{dist-CYnRCUzN.js → dist-DFWnAzAY.js} +775 -553
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-CNLYSVyJ.js → hub-mdns-ciao-BQDdPkPO.js} +2 -2
- package/system/dist/{hub-mdns-ciao-CvMKderb.mjs → hub-mdns-ciao-DW_g42El.mjs} +2 -2
- package/system/dist/index.js +9 -8
- package/system/dist/index.mjs +9 -8
- package/system/dist/kernel/transport/parent-unowned-call.d.ts +10 -0
- package/system/dist/{restore-archive-vzWYLf6p.mjs → restore-archive-CFGGJCfV.mjs} +82 -82
- package/system/dist/{restore-archive-Dw04PiG5.js → restore-archive-DRjYgh6D.js} +1 -1
- package/system/dist/retention-B9l9TnGE.mjs +245 -0
- package/system/dist/retention-BNONb5X_.js +304 -0
- package/system/dist/{wal-maintenance-DQXiTaph.js → wal-maintenance-D0zSmIwJ.js} +0 -0
- package/system/dist/{wal-maintenance-BzTHorT2.mjs → wal-maintenance-xYk-FpJW.mjs} +0 -0
- package/system/package.json +1 -1
|
@@ -1171,7 +1171,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
1171
1171
|
return DeviceRole;
|
|
1172
1172
|
}({});
|
|
1173
1173
|
//#endregion
|
|
1174
|
-
//#region ../types/dist/sleep-
|
|
1174
|
+
//#region ../types/dist/sleep-hK-Dss3z.mjs
|
|
1175
1175
|
/**
|
|
1176
1176
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
1177
1177
|
* window to float samples (D455).
|
|
@@ -8205,7 +8205,7 @@ function sleep(ms) {
|
|
|
8205
8205
|
return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
|
|
8206
8206
|
}
|
|
8207
8207
|
//#endregion
|
|
8208
|
-
//#region ../types/dist/composition-
|
|
8208
|
+
//#region ../types/dist/composition-BSGHhcr8.mjs
|
|
8209
8209
|
var AUDIO_ENCODER_BY_CODEC = {
|
|
8210
8210
|
opus: "libopus",
|
|
8211
8211
|
aac: "aac",
|
|
@@ -9777,45 +9777,6 @@ function evaluateExpressionSource(expr, bindingValues, now, opts) {
|
|
|
9777
9777
|
}
|
|
9778
9778
|
}
|
|
9779
9779
|
/**
|
|
9780
|
-
* One power reading becomes a washer, dryer or dishwasher (D944 helper).
|
|
9781
|
-
*
|
|
9782
|
-
* Standby of the control board is under 5 W; a motor or a heater is far
|
|
9783
|
-
* above that, so 5 W is the line. A door lock or a short pump spike is not
|
|
9784
|
-
* a cycle, so running starts only after 30 s above the line.
|
|
9785
|
-
*
|
|
9786
|
-
* A wash, dry or dishwasher pause (soak, heat-wait, heater off between
|
|
9787
|
-
* bursts) lasts several minutes. Ending the cycle on the first dip would
|
|
9788
|
-
* report "finished" in the middle of the program, so the stop dwell is
|
|
9789
|
-
* 10 minutes on every type. The number is stored per type so one machine
|
|
9790
|
-
* can move later without moving the others.
|
|
9791
|
-
*/
|
|
9792
|
-
var APPLIANCE_TEMPLATE_ID = "appliance";
|
|
9793
|
-
var APPLIANCE_KINDS = [
|
|
9794
|
-
"washer",
|
|
9795
|
-
"dryer",
|
|
9796
|
-
"dishwasher"
|
|
9797
|
-
];
|
|
9798
|
-
var DEVICE_TYPE = {
|
|
9799
|
-
washer: DeviceType.Washer,
|
|
9800
|
-
dryer: DeviceType.Dryer,
|
|
9801
|
-
dishwasher: DeviceType.Dishwasher
|
|
9802
|
-
};
|
|
9803
|
-
function applianceDeviceType(kind) {
|
|
9804
|
-
return DEVICE_TYPE[kind];
|
|
9805
|
-
}
|
|
9806
|
-
/**
|
|
9807
|
-
* A dumb plug-in stove or heater, built from a smart plug (a `Heater`).
|
|
9808
|
-
*
|
|
9809
|
-
* The plug is the actuator: `switch.setState` is a FORWARD to the plug's own
|
|
9810
|
-
* (D967), so the heater switches exactly as the plug does. Running is the
|
|
9811
|
-
* plug being on; when a power reading is also named, running is the draw
|
|
9812
|
-
* staying above the line instead (a plug left on with the stove's own
|
|
9813
|
-
* thermostat open is not heating). 50 W is far above any standby and below
|
|
9814
|
-
* the smallest radiator.
|
|
9815
|
-
*/
|
|
9816
|
-
var HEATER_TEMPLATE_ID = "heater";
|
|
9817
|
-
var HEATER_DEVICE_TYPE = DeviceType.Heater;
|
|
9818
|
-
/**
|
|
9819
9780
|
* Watts integrated over time, in kWh (D944).
|
|
9820
9781
|
*
|
|
9821
9782
|
* 1 kWh = 1 000 W × 3 600 000 ms. The history energy series uses the same
|
|
@@ -10117,6 +10078,26 @@ var DEFAULT_HISTORY_RETENTION = {
|
|
|
10117
10078
|
hourMs: 365 * DAY_MS,
|
|
10118
10079
|
dayMs: null
|
|
10119
10080
|
};
|
|
10081
|
+
/**
|
|
10082
|
+
* The retention a device-history settings document states. A missing or
|
|
10083
|
+
* invalid number is the default; a `dayDays` of 0 (or none) keeps the daily
|
|
10084
|
+
* tier forever.
|
|
10085
|
+
*/
|
|
10086
|
+
function historyRetentionFromSettings(raw) {
|
|
10087
|
+
return {
|
|
10088
|
+
rawMs: positiveDays(raw["rawDays"], DEFAULT_HISTORY_RETENTION.rawMs),
|
|
10089
|
+
fiveMinuteMs: positiveDays(raw["fiveMinuteDays"], DEFAULT_HISTORY_RETENTION.fiveMinuteMs),
|
|
10090
|
+
hourMs: positiveDays(raw["hourDays"], DEFAULT_HISTORY_RETENTION.hourMs),
|
|
10091
|
+
dayMs: positiveDaysOrForever(raw["dayDays"])
|
|
10092
|
+
};
|
|
10093
|
+
}
|
|
10094
|
+
function positiveDays(value, fallbackMs) {
|
|
10095
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value * DAY_MS : fallbackMs;
|
|
10096
|
+
}
|
|
10097
|
+
function positiveDaysOrForever(value) {
|
|
10098
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return null;
|
|
10099
|
+
return value * DAY_MS;
|
|
10100
|
+
}
|
|
10120
10101
|
var rollingWindowObject = zod.z.object({
|
|
10121
10102
|
kind: zod.z.literal("rolling"),
|
|
10122
10103
|
span: zod.z.enum(ROLLING_SPANS),
|
|
@@ -10454,35 +10435,6 @@ var GroupHelperSpecSchema = zod.z.object({
|
|
|
10454
10435
|
/** Actuator groups only. Readings leave this unset. */
|
|
10455
10436
|
active: ActiveCriterionSchema.optional()
|
|
10456
10437
|
});
|
|
10457
|
-
var ApplianceHelperSpecSchema = zod.z.object({
|
|
10458
|
-
kind: zod.z.literal("appliance"),
|
|
10459
|
-
templateId: zod.z.literal(APPLIANCE_TEMPLATE_ID),
|
|
10460
|
-
appliance: zod.z.enum(APPLIANCE_KINDS),
|
|
10461
|
-
thresholdWatts: zod.z.number().positive(),
|
|
10462
|
-
startDwellMs: zod.z.number().int().nonnegative(),
|
|
10463
|
-
stopDwellMs: zod.z.number().int().nonnegative(),
|
|
10464
|
-
member: HelperMemberSchema,
|
|
10465
|
-
/**
|
|
10466
|
-
* The plug that powers the appliance (`switch.on`). Optional: when set, the
|
|
10467
|
-
* composition carries a `power-source` feature, so the hub can cut and restore
|
|
10468
|
-
* that plug (power-source link of a NEW-target composition).
|
|
10469
|
-
*/
|
|
10470
|
-
powerSwitch: HelperMemberSchema.optional(),
|
|
10471
|
-
/** How long a forced restart keeps the plug off; the cap's default when unset. */
|
|
10472
|
-
offSeconds: zod.z.number().optional()
|
|
10473
|
-
});
|
|
10474
|
-
/** A dumb heater built from a plug: the plug is the actuator, a meter is optional. */
|
|
10475
|
-
var HeaterHelperSpecSchema = zod.z.object({
|
|
10476
|
-
kind: zod.z.literal("heater"),
|
|
10477
|
-
templateId: zod.z.literal(HEATER_TEMPLATE_ID),
|
|
10478
|
-
/** The plug, read and commanded at `switch.on`. */
|
|
10479
|
-
plug: HelperMemberSchema,
|
|
10480
|
-
/** The plug's power reading, when it has one: running is then the draw, not the switch. */
|
|
10481
|
-
meter: HelperMemberSchema.optional(),
|
|
10482
|
-
thresholdWatts: zod.z.number().positive(),
|
|
10483
|
-
startDwellMs: zod.z.number().int().nonnegative(),
|
|
10484
|
-
stopDwellMs: zod.z.number().int().nonnegative()
|
|
10485
|
-
});
|
|
10486
10438
|
var statisticHelperObject = zod.z.object({
|
|
10487
10439
|
kind: zod.z.literal("statistic"),
|
|
10488
10440
|
stat: zod.z.enum(STATISTIC_STATS),
|
|
@@ -10533,8 +10485,6 @@ var derivativeHelperObject = zod.z.object({
|
|
|
10533
10485
|
});
|
|
10534
10486
|
var HelperSpecSchema = zod.z.discriminatedUnion("kind", [
|
|
10535
10487
|
GroupHelperSpecSchema,
|
|
10536
|
-
ApplianceHelperSpecSchema,
|
|
10537
|
-
HeaterHelperSpecSchema,
|
|
10538
10488
|
statisticHelperObject,
|
|
10539
10489
|
integralHelperObject,
|
|
10540
10490
|
thresholdHelperObject,
|
|
@@ -10549,8 +10499,6 @@ function isHistoryHelper(spec) {
|
|
|
10549
10499
|
function helperMembers(spec) {
|
|
10550
10500
|
switch (spec.kind) {
|
|
10551
10501
|
case "group": return spec.members;
|
|
10552
|
-
case "appliance": return [spec.member];
|
|
10553
|
-
case "heater": return spec.meter === void 0 ? [spec.plug] : [spec.plug, spec.meter];
|
|
10554
10502
|
case "statistic":
|
|
10555
10503
|
case "integral":
|
|
10556
10504
|
case "threshold":
|
|
@@ -41555,7 +41503,7 @@ var WEEKDAY_BY_INDEX = [
|
|
|
41555
41503
|
"fri",
|
|
41556
41504
|
"sat"
|
|
41557
41505
|
];
|
|
41558
|
-
var MINUTE_MS$
|
|
41506
|
+
var MINUTE_MS$3 = 6e4;
|
|
41559
41507
|
var DAY_MS$1 = 864e5;
|
|
41560
41508
|
var formatters = /* @__PURE__ */ new Map();
|
|
41561
41509
|
function formatterFor$1(timeZone) {
|
|
@@ -41637,8 +41585,8 @@ function wallToEpoch(localDate, hh, mm, timeZone) {
|
|
|
41637
41585
|
if (valid.length > 0) return Math.min(...valid);
|
|
41638
41586
|
let lo = wall - DAY_MS$1;
|
|
41639
41587
|
let hi = wall + DAY_MS$1;
|
|
41640
|
-
while (hi - lo > MINUTE_MS$
|
|
41641
|
-
const mid = Math.floor((lo + hi) / 2 / MINUTE_MS$
|
|
41588
|
+
while (hi - lo > MINUTE_MS$3) {
|
|
41589
|
+
const mid = Math.floor((lo + hi) / 2 / MINUTE_MS$3) * MINUTE_MS$3;
|
|
41642
41590
|
if (offsetMs(mid, timeZone) === before) lo = mid;
|
|
41643
41591
|
else hi = mid;
|
|
41644
41592
|
}
|
|
@@ -41663,7 +41611,7 @@ function occurrenceOn(spec, localDate, site) {
|
|
|
41663
41611
|
const midday = new Date(wallToEpoch(localDate, 12, 0, site.timeZone));
|
|
41664
41612
|
const crossings = sunCrossings(site.lat, site.lon, midday, sunEventAltitude(spec.event));
|
|
41665
41613
|
if (crossings === null) return null;
|
|
41666
|
-
return (spec.event === "sunrise" || spec.event === "dawn" ? crossings.rise : crossings.set) + spec.offsetMin * MINUTE_MS$
|
|
41614
|
+
return (spec.event === "sunrise" || spec.event === "dawn" ? crossings.rise : crossings.set) + spec.offsetMin * MINUTE_MS$3;
|
|
41667
41615
|
}
|
|
41668
41616
|
}
|
|
41669
41617
|
}
|
|
@@ -52825,207 +52773,6 @@ var BY_ID = new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
|
|
|
52825
52773
|
function groupTemplate(id) {
|
|
52826
52774
|
return BY_ID.get(id) ?? null;
|
|
52827
52775
|
}
|
|
52828
|
-
var PowerSourceRefusalReasonSchema = zod.z.enum([
|
|
52829
|
-
"no-power-source",
|
|
52830
|
-
"switch-missing",
|
|
52831
|
-
"switch-offline",
|
|
52832
|
-
"switch-unknown",
|
|
52833
|
-
"restart-in-progress",
|
|
52834
|
-
"switch-call-failed"
|
|
52835
|
-
]);
|
|
52836
|
-
var PowerSourceActionResultSchema = zod.z.discriminatedUnion("accepted", [zod.z.object({ accepted: zod.z.literal(true) }), zod.z.object({
|
|
52837
|
-
accepted: zod.z.literal(false),
|
|
52838
|
-
reason: PowerSourceRefusalReasonSchema,
|
|
52839
|
-
/** One line for the operator, naming the switch. */
|
|
52840
|
-
message: zod.z.string()
|
|
52841
|
-
})]);
|
|
52842
|
-
var PowerSourceInfoSchema = zod.z.object({
|
|
52843
|
-
/** False when the device has no power source linked; the rest is then empty. */
|
|
52844
|
-
linked: zod.z.boolean(),
|
|
52845
|
-
switchDeviceId: zod.z.number().nullable(),
|
|
52846
|
-
switchName: zod.z.string().nullable(),
|
|
52847
|
-
/** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
|
|
52848
|
-
switchOn: zod.z.boolean().nullable(),
|
|
52849
|
-
switchOnline: zod.z.boolean().nullable(),
|
|
52850
|
-
restartInProgress: zod.z.boolean(),
|
|
52851
|
-
offSeconds: zod.z.number().int()
|
|
52852
|
-
});
|
|
52853
|
-
/** The composed slice: the switch state the link mirrors, plus the stored off time. */
|
|
52854
|
-
var PowerSourceStateSchema = zod.z.object({
|
|
52855
|
-
/** Null while the switch has not reported: unknown is never `false` (D393). */
|
|
52856
|
-
switchOn: zod.z.boolean().nullable(),
|
|
52857
|
-
offSeconds: zod.z.number().int(),
|
|
52858
|
-
lastFetchedAt: zod.z.number()
|
|
52859
|
-
});
|
|
52860
|
-
var POWER_SOURCE_DEVICE_TYPES = [
|
|
52861
|
-
DeviceType.Gateway,
|
|
52862
|
-
DeviceType.Hub,
|
|
52863
|
-
DeviceType.Camera,
|
|
52864
|
-
DeviceType.Sensor,
|
|
52865
|
-
DeviceType.MediaPlayer,
|
|
52866
|
-
DeviceType.Vacuum,
|
|
52867
|
-
DeviceType.Generic,
|
|
52868
|
-
DeviceType.Washer,
|
|
52869
|
-
DeviceType.Dryer,
|
|
52870
|
-
DeviceType.Dishwasher,
|
|
52871
|
-
DeviceType.PetFountain,
|
|
52872
|
-
DeviceType.Fan,
|
|
52873
|
-
DeviceType.Humidifier,
|
|
52874
|
-
DeviceType.Climate,
|
|
52875
|
-
DeviceType.WaterHeater
|
|
52876
|
-
];
|
|
52877
|
-
var powerSourceCustomize = {
|
|
52878
|
-
version: 1,
|
|
52879
|
-
targets: [{
|
|
52880
|
-
id: "switch",
|
|
52881
|
-
cardinality: "scalar",
|
|
52882
|
-
vocabulary: {
|
|
52883
|
-
cap: "power-source",
|
|
52884
|
-
stateField: "switchOn"
|
|
52885
|
-
},
|
|
52886
|
-
deviceTypes: POWER_SOURCE_DEVICE_TYPES,
|
|
52887
|
-
apply: "add",
|
|
52888
|
-
path: "switchOn",
|
|
52889
|
-
sources: [{
|
|
52890
|
-
kind: "switch",
|
|
52891
|
-
transforms: [{ kind: "identity" }]
|
|
52892
|
-
}],
|
|
52893
|
-
companions: [{
|
|
52894
|
-
kind: "constant",
|
|
52895
|
-
path: "offSeconds",
|
|
52896
|
-
value: 10,
|
|
52897
|
-
when: "add"
|
|
52898
|
-
}, {
|
|
52899
|
-
kind: "clock",
|
|
52900
|
-
path: "lastFetchedAt",
|
|
52901
|
-
when: "always"
|
|
52902
|
-
}],
|
|
52903
|
-
sourceReport: { status: "assignment-status" }
|
|
52904
|
-
}]
|
|
52905
|
-
};
|
|
52906
|
-
var deviceInput$2 = zod.z.object({ deviceId: zod.z.number().int().nonnegative() });
|
|
52907
|
-
var powerSourceCapability = {
|
|
52908
|
-
name: "power-source",
|
|
52909
|
-
scope: "device",
|
|
52910
|
-
mode: "singleton",
|
|
52911
|
-
deviceTypes: POWER_SOURCE_DEVICE_TYPES,
|
|
52912
|
-
methods: {
|
|
52913
|
-
getStatus: systemMethod(deviceInput$2, PowerSourceInfoSchema, { auth: "admin" }),
|
|
52914
|
-
powerOn: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
|
|
52915
|
-
kind: "mutation",
|
|
52916
|
-
auth: "admin"
|
|
52917
|
-
}),
|
|
52918
|
-
powerOff: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
|
|
52919
|
-
kind: "mutation",
|
|
52920
|
-
auth: "admin"
|
|
52921
|
-
}),
|
|
52922
|
-
forceRestart: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
|
|
52923
|
-
kind: "mutation",
|
|
52924
|
-
auth: "admin"
|
|
52925
|
-
})
|
|
52926
|
-
},
|
|
52927
|
-
runtimeState: PowerSourceStateSchema,
|
|
52928
|
-
customize: powerSourceCustomize,
|
|
52929
|
-
/**
|
|
52930
|
-
* Runtime-state durability: **session** — mirrored from the linked switch on
|
|
52931
|
-
* its next report; a restored value would outlive the reading it names.
|
|
52932
|
-
*
|
|
52933
|
-
* See `RuntimeStateDurability`. Enforced by
|
|
52934
|
-
* `scripts/check-runtime-state-durability.ts`.
|
|
52935
|
-
*/
|
|
52936
|
-
durability: "session",
|
|
52937
|
-
history: "none"
|
|
52938
|
-
};
|
|
52939
|
-
/**
|
|
52940
|
-
* Which smart switch powers a device (the `power-source` Customize extension):
|
|
52941
|
-
* the source its stored `power-source.switchOn` field reads, and the off time of
|
|
52942
|
-
* a forced restart stored beside it. Read from the STORED composition, never kept
|
|
52943
|
-
* as a second copy (D676). Shared by the hub (which acts on the switch) and the
|
|
52944
|
-
* admin UI (which shows it).
|
|
52945
|
-
*/
|
|
52946
|
-
/**
|
|
52947
|
-
* The stored off time, or the default when none is stored. A stored number out
|
|
52948
|
-
* of range is CLAMPED to the bounds (a hand-written value never refuses the
|
|
52949
|
-
* link, it just cannot cut power for an absurd time); a non-integer is rounded.
|
|
52950
|
-
*/
|
|
52951
|
-
function normalizeOffSeconds(value) {
|
|
52952
|
-
if (typeof value !== "number" || !Number.isFinite(value)) return 10;
|
|
52953
|
-
return Math.min(120, Math.max(3, Math.round(value)));
|
|
52954
|
-
}
|
|
52955
|
-
/** The constant a stored `offSeconds` field carries, or undefined when it is not a literal number. */
|
|
52956
|
-
function storedOffSeconds(composition) {
|
|
52957
|
-
const feature = composition.features.find((f) => f.cap === "power-source");
|
|
52958
|
-
if (feature === void 0 || feature.kind !== "fields") return void 0;
|
|
52959
|
-
const field = feature.fields["offSeconds"];
|
|
52960
|
-
if (field === void 0 || field.kind !== "expression") return void 0;
|
|
52961
|
-
const n = Number(field.expr);
|
|
52962
|
-
return field.expr.trim() === "" || !Number.isFinite(n) ? void 0 : n;
|
|
52963
|
-
}
|
|
52964
|
-
/**
|
|
52965
|
-
* The link a composition stores. An `existing` target names its own device; a
|
|
52966
|
-
* `new` target (an appliance helper) is the composer's own device, so the caller
|
|
52967
|
-
* passes the block id and a new-target composition without one has no link.
|
|
52968
|
-
*/
|
|
52969
|
-
function powerSourceLinkOfComposition(composition, blockId) {
|
|
52970
|
-
if (composition === null) return null;
|
|
52971
|
-
let device;
|
|
52972
|
-
if (composition.target.kind === "existing") device = composition.target.device;
|
|
52973
|
-
else if (blockId !== void 0) device = composedDeviceRef(blockId);
|
|
52974
|
-
else return null;
|
|
52975
|
-
const feature = composition.features.find((f) => f.cap === "power-source");
|
|
52976
|
-
if (feature === void 0 || feature.kind !== "fields" || feature.enabled === false) return null;
|
|
52977
|
-
const field = feature.fields["switchOn"];
|
|
52978
|
-
if (field === void 0) return null;
|
|
52979
|
-
const read = fieldReads(field).find((r) => r.cap === "switch");
|
|
52980
|
-
if (read === void 0) return null;
|
|
52981
|
-
return {
|
|
52982
|
-
device,
|
|
52983
|
-
switch: read.source,
|
|
52984
|
-
offSeconds: normalizeOffSeconds(storedOffSeconds(composition))
|
|
52985
|
-
};
|
|
52986
|
-
}
|
|
52987
|
-
var UNSIGNED = /^\d+(?:\.\d+)?$/;
|
|
52988
|
-
var SIGNED = /^-?\d+(?:\.\d+)?$/;
|
|
52989
|
-
var IDENT = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
52990
|
-
function unsignedToken(value) {
|
|
52991
|
-
return token(value, UNSIGNED);
|
|
52992
|
-
}
|
|
52993
|
-
function signedToken(value) {
|
|
52994
|
-
return token(value, SIGNED);
|
|
52995
|
-
}
|
|
52996
|
-
function constantExpr(value) {
|
|
52997
|
-
if (typeof value === "string") return JSON.stringify(value);
|
|
52998
|
-
if (typeof value === "number") return signedToken(value);
|
|
52999
|
-
if (typeof value === "boolean") return value ? "true" : "false";
|
|
53000
|
-
return "null";
|
|
53001
|
-
}
|
|
53002
|
-
/**
|
|
53003
|
-
* Canonical text of a replace target's override (D984): the field keeps its
|
|
53004
|
-
* NATIVE value (`native`) when that value is one of `unlessNative`, becomes
|
|
53005
|
-
* `whenSourceTrue` while the boolean source (`x`) is true, else keeps native.
|
|
53006
|
-
* A null source is falsy, so an unknown source leaves the native value.
|
|
53007
|
-
*/
|
|
53008
|
-
function overrideExpr(whenSourceTrue, unlessNative) {
|
|
53009
|
-
const guard = unlessNative.map((value) => `native == ${JSON.stringify(value)}`).join(" || ");
|
|
53010
|
-
const inner = `(x ? ${JSON.stringify(whenSourceTrue)} : native)`;
|
|
53011
|
-
return guard === "" ? inner.slice(1, -1) : `${guard} ? native : ${inner}`;
|
|
53012
|
-
}
|
|
53013
|
-
function isIdentifier(path) {
|
|
53014
|
-
return IDENT.test(path);
|
|
53015
|
-
}
|
|
53016
|
-
function dwellExpr(comparison, threshold, start, stop) {
|
|
53017
|
-
return `dwell(x ${comparison === "gte" ? ">=" : "<="} ${threshold}, ${start}, ${stop})`;
|
|
53018
|
-
}
|
|
53019
|
-
function linearExpr(inner, scale, offset, clampMin, clampMax) {
|
|
53020
|
-
const arithmetic = `${inner} * ${scale} + ${offset}`;
|
|
53021
|
-
if (clampMin === null || clampMax === null) return arithmetic;
|
|
53022
|
-
return `clamp(${arithmetic}, ${clampMin}, ${clampMax})`;
|
|
53023
|
-
}
|
|
53024
|
-
function token(value, pattern) {
|
|
53025
|
-
if (!Number.isFinite(value)) return null;
|
|
53026
|
-
const text = Object.is(value, -0) ? "0" : String(value);
|
|
53027
|
-
return pattern.test(text) ? text : null;
|
|
53028
|
-
}
|
|
53029
52776
|
var COLOR_MODE_FEATURES = [
|
|
53030
52777
|
DeviceFeature.LightColorRgb,
|
|
53031
52778
|
DeviceFeature.LightColorHsv,
|
|
@@ -53628,6 +53375,48 @@ function integralDraft(spec, retention = DEFAULT_HISTORY_RETENTION) {
|
|
|
53628
53375
|
})
|
|
53629
53376
|
};
|
|
53630
53377
|
}
|
|
53378
|
+
var UNSIGNED = /^\d+(?:\.\d+)?$/;
|
|
53379
|
+
var SIGNED = /^-?\d+(?:\.\d+)?$/;
|
|
53380
|
+
var IDENT = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
53381
|
+
function unsignedToken(value) {
|
|
53382
|
+
return token(value, UNSIGNED);
|
|
53383
|
+
}
|
|
53384
|
+
function signedToken(value) {
|
|
53385
|
+
return token(value, SIGNED);
|
|
53386
|
+
}
|
|
53387
|
+
function constantExpr(value) {
|
|
53388
|
+
if (typeof value === "string") return JSON.stringify(value);
|
|
53389
|
+
if (typeof value === "number") return signedToken(value);
|
|
53390
|
+
if (typeof value === "boolean") return value ? "true" : "false";
|
|
53391
|
+
return "null";
|
|
53392
|
+
}
|
|
53393
|
+
/**
|
|
53394
|
+
* Canonical text of a replace target's override (D984): the field keeps its
|
|
53395
|
+
* NATIVE value (`native`) when that value is one of `unlessNative`, becomes
|
|
53396
|
+
* `whenSourceTrue` while the boolean source (`x`) is true, else keeps native.
|
|
53397
|
+
* A null source is falsy, so an unknown source leaves the native value.
|
|
53398
|
+
*/
|
|
53399
|
+
function overrideExpr(whenSourceTrue, unlessNative) {
|
|
53400
|
+
const guard = unlessNative.map((value) => `native == ${JSON.stringify(value)}`).join(" || ");
|
|
53401
|
+
const inner = `(x ? ${JSON.stringify(whenSourceTrue)} : native)`;
|
|
53402
|
+
return guard === "" ? inner.slice(1, -1) : `${guard} ? native : ${inner}`;
|
|
53403
|
+
}
|
|
53404
|
+
function isIdentifier(path) {
|
|
53405
|
+
return IDENT.test(path);
|
|
53406
|
+
}
|
|
53407
|
+
function dwellExpr(comparison, threshold, start, stop) {
|
|
53408
|
+
return `dwell(x ${comparison === "gte" ? ">=" : "<="} ${threshold}, ${start}, ${stop})`;
|
|
53409
|
+
}
|
|
53410
|
+
function linearExpr(inner, scale, offset, clampMin, clampMax) {
|
|
53411
|
+
const arithmetic = `${inner} * ${scale} + ${offset}`;
|
|
53412
|
+
if (clampMin === null || clampMax === null) return arithmetic;
|
|
53413
|
+
return `clamp(${arithmetic}, ${clampMin}, ${clampMax})`;
|
|
53414
|
+
}
|
|
53415
|
+
function token(value, pattern) {
|
|
53416
|
+
if (!Number.isFinite(value)) return null;
|
|
53417
|
+
const text = Object.is(value, -0) ? "0" : String(value);
|
|
53418
|
+
return pattern.test(text) ? text : null;
|
|
53419
|
+
}
|
|
53631
53420
|
/**
|
|
53632
53421
|
* Math helpers projected onto a new sensor (D944 phase 3). A threshold is the
|
|
53633
53422
|
* `schmitt` builtin, a difference and a ratio are small expressions, a sum is
|
|
@@ -53783,10 +53572,6 @@ function expressionDraft(spec) {
|
|
|
53783
53572
|
draft: spec.output === "boolean" ? binarySensor(spec, source) : numericSensor(spec, source)
|
|
53784
53573
|
};
|
|
53785
53574
|
}
|
|
53786
|
-
/**
|
|
53787
|
-
* Project a helper spec onto the composition the composer already runs (D944).
|
|
53788
|
-
* Pure: it stores nothing. A group does not compile to `avg(...)` / `any(...)`.
|
|
53789
|
-
*/
|
|
53790
53575
|
function sameSource(a, b) {
|
|
53791
53576
|
return a.addonId === b.addonId && a.stableId === b.stableId;
|
|
53792
53577
|
}
|
|
@@ -53878,162 +53663,10 @@ function expressionSource(expr, bindings = {}) {
|
|
|
53878
53663
|
bindings
|
|
53879
53664
|
};
|
|
53880
53665
|
}
|
|
53881
|
-
function compileAppliance(spec) {
|
|
53882
|
-
const member = spec.member;
|
|
53883
|
-
if (member.cap !== "power-meter" || member.fieldPath !== "power") return {
|
|
53884
|
-
ok: false,
|
|
53885
|
-
problems: [problem("member-constraint", "helper.member", "an appliance helper reads power-meter.power")]
|
|
53886
|
-
};
|
|
53887
|
-
const powerSwitch = spec.powerSwitch;
|
|
53888
|
-
if (powerSwitch !== void 0 && (powerSwitch.cap !== "switch" || powerSwitch.fieldPath !== "on")) return {
|
|
53889
|
-
ok: false,
|
|
53890
|
-
problems: [problem("member-constraint", "helper.powerSwitch", "the power plug of an appliance helper is a switch, read at switch.on")]
|
|
53891
|
-
};
|
|
53892
|
-
const threshold = unsignedToken(spec.thresholdWatts);
|
|
53893
|
-
const start = unsignedToken(spec.startDwellMs);
|
|
53894
|
-
const stop = unsignedToken(spec.stopDwellMs);
|
|
53895
|
-
if (threshold === null || spec.thresholdWatts <= 0) return {
|
|
53896
|
-
ok: false,
|
|
53897
|
-
problems: [problem("kind-mismatch", "helper.thresholdWatts", "the threshold is watts above which the appliance is running")]
|
|
53898
|
-
};
|
|
53899
|
-
if (start === null || stop === null) return {
|
|
53900
|
-
ok: false,
|
|
53901
|
-
problems: [problem("kind-mismatch", "helper.startDwellMs", "start and stop dwells are a non-negative number of milliseconds")]
|
|
53902
|
-
};
|
|
53903
|
-
const read = {
|
|
53904
|
-
kind: "from",
|
|
53905
|
-
source: member.source,
|
|
53906
|
-
cap: member.cap,
|
|
53907
|
-
fieldPath: member.fieldPath
|
|
53908
|
-
};
|
|
53909
|
-
const dwell = dwellExpr("gte", threshold, start, stop);
|
|
53910
|
-
const clock = expressionSource("now");
|
|
53911
|
-
const powerSourceFeatures = powerSwitch === void 0 ? [] : [{
|
|
53912
|
-
kind: "fields",
|
|
53913
|
-
cap: "power-source",
|
|
53914
|
-
fields: {
|
|
53915
|
-
switchOn: {
|
|
53916
|
-
kind: "from",
|
|
53917
|
-
source: powerSwitch.source,
|
|
53918
|
-
cap: powerSwitch.cap,
|
|
53919
|
-
fieldPath: powerSwitch.fieldPath
|
|
53920
|
-
},
|
|
53921
|
-
offSeconds: expressionSource(String(normalizeOffSeconds(spec.offSeconds))),
|
|
53922
|
-
lastFetchedAt: clock
|
|
53923
|
-
}
|
|
53924
|
-
}];
|
|
53925
|
-
return parseDraft({
|
|
53926
|
-
target: {
|
|
53927
|
-
kind: "new",
|
|
53928
|
-
type: applianceDeviceType(spec.appliance)
|
|
53929
|
-
},
|
|
53930
|
-
helper: spec,
|
|
53931
|
-
features: [
|
|
53932
|
-
{
|
|
53933
|
-
kind: "fields",
|
|
53934
|
-
cap: "running-state",
|
|
53935
|
-
fields: {
|
|
53936
|
-
running: expressionSource(dwell, { x: read }),
|
|
53937
|
-
source: expressionSource("\"assigned\""),
|
|
53938
|
-
phase: expressionSource("null"),
|
|
53939
|
-
lastFetchedAt: clock,
|
|
53940
|
-
since: expressionSource(`latchedAt(${dwell})`, { x: read })
|
|
53941
|
-
}
|
|
53942
|
-
},
|
|
53943
|
-
{
|
|
53944
|
-
kind: "fields",
|
|
53945
|
-
cap: "power-meter",
|
|
53946
|
-
fields: {
|
|
53947
|
-
power: read,
|
|
53948
|
-
lastFetchedAt: clock
|
|
53949
|
-
}
|
|
53950
|
-
},
|
|
53951
|
-
...powerSourceFeatures
|
|
53952
|
-
]
|
|
53953
|
-
});
|
|
53954
|
-
}
|
|
53955
|
-
function compileHeater(spec) {
|
|
53956
|
-
if (spec.plug.cap !== "switch" || spec.plug.fieldPath !== "on") return {
|
|
53957
|
-
ok: false,
|
|
53958
|
-
problems: [problem("member-constraint", "helper.plug", "the plug of a heater helper is a switch, read at switch.on")]
|
|
53959
|
-
};
|
|
53960
|
-
const meter = spec.meter;
|
|
53961
|
-
if (meter !== void 0 && (meter.cap !== "power-meter" || meter.fieldPath !== "power")) return {
|
|
53962
|
-
ok: false,
|
|
53963
|
-
problems: [problem("member-constraint", "helper.meter", "the meter of a heater helper reads power-meter.power")]
|
|
53964
|
-
};
|
|
53965
|
-
const threshold = unsignedToken(spec.thresholdWatts);
|
|
53966
|
-
const start = unsignedToken(spec.startDwellMs);
|
|
53967
|
-
const stop = unsignedToken(spec.stopDwellMs);
|
|
53968
|
-
if (threshold === null || spec.thresholdWatts <= 0 || start === null || stop === null) return {
|
|
53969
|
-
ok: false,
|
|
53970
|
-
problems: [problem("kind-mismatch", "helper.thresholdWatts", "the threshold is positive watts; the dwells are a non-negative number of milliseconds")]
|
|
53971
|
-
};
|
|
53972
|
-
const plugRead = {
|
|
53973
|
-
kind: "from",
|
|
53974
|
-
source: spec.plug.source,
|
|
53975
|
-
cap: spec.plug.cap,
|
|
53976
|
-
fieldPath: spec.plug.fieldPath
|
|
53977
|
-
};
|
|
53978
|
-
const clock = expressionSource("now");
|
|
53979
|
-
const meterRead = meter === void 0 ? void 0 : {
|
|
53980
|
-
kind: "from",
|
|
53981
|
-
source: meter.source,
|
|
53982
|
-
cap: meter.cap,
|
|
53983
|
-
fieldPath: meter.fieldPath
|
|
53984
|
-
};
|
|
53985
|
-
const dwell = dwellExpr("gte", threshold, start, stop);
|
|
53986
|
-
const running = meterRead === void 0 ? expressionSource("x", { x: plugRead }) : expressionSource(dwell, { x: meterRead });
|
|
53987
|
-
const since = meterRead === void 0 ? expressionSource("latchedAt(x)", { x: plugRead }) : expressionSource(`latchedAt(${dwell})`, { x: meterRead });
|
|
53988
|
-
return parseDraft({
|
|
53989
|
-
target: {
|
|
53990
|
-
kind: "new",
|
|
53991
|
-
type: HEATER_DEVICE_TYPE
|
|
53992
|
-
},
|
|
53993
|
-
helper: spec,
|
|
53994
|
-
features: [
|
|
53995
|
-
{
|
|
53996
|
-
kind: "fields",
|
|
53997
|
-
cap: "switch",
|
|
53998
|
-
fields: {
|
|
53999
|
-
on: plugRead,
|
|
54000
|
-
lastChangedAt: clock
|
|
54001
|
-
},
|
|
54002
|
-
commands: { setState: {
|
|
54003
|
-
kind: "forward",
|
|
54004
|
-
source: spec.plug.source,
|
|
54005
|
-
cap: "switch",
|
|
54006
|
-
method: "setState"
|
|
54007
|
-
} }
|
|
54008
|
-
},
|
|
54009
|
-
{
|
|
54010
|
-
kind: "fields",
|
|
54011
|
-
cap: "running-state",
|
|
54012
|
-
fields: {
|
|
54013
|
-
running,
|
|
54014
|
-
source: expressionSource("\"assigned\""),
|
|
54015
|
-
phase: expressionSource("null"),
|
|
54016
|
-
lastFetchedAt: clock,
|
|
54017
|
-
since
|
|
54018
|
-
}
|
|
54019
|
-
},
|
|
54020
|
-
...meterRead === void 0 ? [] : [{
|
|
54021
|
-
kind: "fields",
|
|
54022
|
-
cap: "power-meter",
|
|
54023
|
-
fields: {
|
|
54024
|
-
power: meterRead,
|
|
54025
|
-
lastFetchedAt: clock
|
|
54026
|
-
}
|
|
54027
|
-
}]
|
|
54028
|
-
]
|
|
54029
|
-
});
|
|
54030
|
-
}
|
|
54031
53666
|
/** Compile a helper template to a new-device composition. Refusals are named. */
|
|
54032
53667
|
function compileHelper(spec, retention = DEFAULT_HISTORY_RETENTION) {
|
|
54033
53668
|
switch (spec.kind) {
|
|
54034
53669
|
case "group": return compileGroup(spec);
|
|
54035
|
-
case "appliance": return compileAppliance(spec);
|
|
54036
|
-
case "heater": return compileHeater(spec);
|
|
54037
53670
|
case "statistic": {
|
|
54038
53671
|
const built = statisticDraft(spec, retention);
|
|
54039
53672
|
if (built.problems.length > 0) return {
|
|
@@ -54099,10 +53732,6 @@ function compileGroup(spec) {
|
|
|
54099
53732
|
function sameHelperBody(stored, compiled) {
|
|
54100
53733
|
return JSON.stringify(stored.target) === JSON.stringify(compiled.target) && JSON.stringify(stored.features) === JSON.stringify(compiled.features);
|
|
54101
53734
|
}
|
|
54102
|
-
/**
|
|
54103
|
-
* Save-time checks a pure compile cannot make: the compiled features must be
|
|
54104
|
-
* this spec's, and members that report a quantity must share one (D944 §4).
|
|
54105
|
-
*/
|
|
54106
53735
|
function quantityProblems(spec, facts) {
|
|
54107
53736
|
if (spec.kind !== "group") return [];
|
|
54108
53737
|
const template = groupTemplate(spec.templateId);
|
|
@@ -54139,19 +53768,10 @@ function helperSaveProblems(composition, facts) {
|
|
|
54139
53768
|
const compiled = compileHelper(spec);
|
|
54140
53769
|
if (!compiled.ok) return compiled.problems;
|
|
54141
53770
|
if (!sameHelperBody(composition, compiled.composition)) return [problem("helper-mismatch", "helper", "the stored features are not this template — the helper spec is the only writer")];
|
|
54142
|
-
if (spec.kind === "appliance") return applianceMemberProblems(spec.member, facts);
|
|
54143
53771
|
if (spec.kind === "arithmetic") return arithmeticQuantityProblems(spec, facts);
|
|
54144
53772
|
if (spec.kind !== "group") return [];
|
|
54145
53773
|
return [...quantityProblems(spec, facts), ...deviceTypeProblems(spec, facts)];
|
|
54146
53774
|
}
|
|
54147
|
-
function applianceMemberProblems(member, facts) {
|
|
54148
|
-
const fact = facts.get(compositionSourceKey(member.source));
|
|
54149
|
-
if (fact === void 0) return [];
|
|
54150
|
-
const problems = [];
|
|
54151
|
-
if (fact.deviceType !== void 0 && fact.deviceType !== DeviceType.Sensor && fact.deviceType !== DeviceType.Switch) problems.push(problem("member-constraint", "helper.member", `an appliance helper reads a sensor or a switch; this member is a ${fact.deviceType}`));
|
|
54152
|
-
if (fact.quantity !== void 0 && fact.quantity !== "power") problems.push(problem("mixed-quantity", "helper.member", `an appliance helper reads power (W); this member is ${fact.quantity}`));
|
|
54153
|
-
return problems;
|
|
54154
|
-
}
|
|
54155
53775
|
/**
|
|
54156
53776
|
* A sum, a difference and a ratio combine readings of ONE quantity. The ratio
|
|
54157
53777
|
* of two powers is a plain number, but a power over an energy is not a ratio of
|
|
@@ -54787,6 +54407,169 @@ function describeComposableCaps(defs, deviceType) {
|
|
|
54787
54407
|
}).toSorted((a, b) => a.cap.localeCompare(b.cap));
|
|
54788
54408
|
}
|
|
54789
54409
|
/**
|
|
54410
|
+
* A saved Customize assignment (D936). The schema is the type: callers use
|
|
54411
|
+
* `z.infer`, they do not restate the shape.
|
|
54412
|
+
*/
|
|
54413
|
+
var OverrideSourceSchema = zod.z.object({
|
|
54414
|
+
addonId: zod.z.string().min(1),
|
|
54415
|
+
stableId: zod.z.string().min(1),
|
|
54416
|
+
cap: zod.z.string().min(1),
|
|
54417
|
+
fieldPath: zod.z.string().min(1)
|
|
54418
|
+
});
|
|
54419
|
+
var IdentityTransformDraftSchema = zod.z.object({ kind: zod.z.literal("identity") });
|
|
54420
|
+
var InvertTransformDraftSchema = zod.z.object({ kind: zod.z.literal("invert") });
|
|
54421
|
+
var ThresholdTransformDraftSchema = zod.z.object({
|
|
54422
|
+
kind: zod.z.literal("threshold"),
|
|
54423
|
+
comparison: zod.z.enum(["gte", "lte"]),
|
|
54424
|
+
threshold: zod.z.number(),
|
|
54425
|
+
startDwellMs: zod.z.number().nonnegative(),
|
|
54426
|
+
stopDwellMs: zod.z.number().nonnegative()
|
|
54427
|
+
});
|
|
54428
|
+
var LinearTransformDraftSchema = zod.z.object({
|
|
54429
|
+
kind: zod.z.literal("linear"),
|
|
54430
|
+
scale: zod.z.number(),
|
|
54431
|
+
offset: zod.z.number(),
|
|
54432
|
+
clampMin: zod.z.number().optional(),
|
|
54433
|
+
clampMax: zod.z.number().optional()
|
|
54434
|
+
});
|
|
54435
|
+
var EnumMapTransformDraftSchema = zod.z.object({
|
|
54436
|
+
kind: zod.z.literal("enum-map"),
|
|
54437
|
+
mapping: zod.z.record(zod.z.string(), zod.z.string().nullable())
|
|
54438
|
+
});
|
|
54439
|
+
var NumberBridgeTransformDraftSchema = zod.z.object({ kind: zod.z.literal("number") });
|
|
54440
|
+
var CustomizeTransformDraftSchema = zod.z.discriminatedUnion("kind", [
|
|
54441
|
+
IdentityTransformDraftSchema,
|
|
54442
|
+
InvertTransformDraftSchema,
|
|
54443
|
+
ThresholdTransformDraftSchema,
|
|
54444
|
+
LinearTransformDraftSchema,
|
|
54445
|
+
EnumMapTransformDraftSchema,
|
|
54446
|
+
NumberBridgeTransformDraftSchema
|
|
54447
|
+
]);
|
|
54448
|
+
var ScalarOverrideDraftSchema = zod.z.object({
|
|
54449
|
+
kind: zod.z.literal("scalar"),
|
|
54450
|
+
cap: zod.z.string().min(1),
|
|
54451
|
+
targetId: zod.z.string().min(1),
|
|
54452
|
+
source: OverrideSourceSchema,
|
|
54453
|
+
transform: CustomizeTransformDraftSchema
|
|
54454
|
+
});
|
|
54455
|
+
var KeyedArrayOverrideDraftSchema = zod.z.object({
|
|
54456
|
+
kind: zod.z.literal("keyedArray"),
|
|
54457
|
+
cap: zod.z.string().min(1),
|
|
54458
|
+
targetId: zod.z.string().min(1),
|
|
54459
|
+
key: zod.z.string().min(1),
|
|
54460
|
+
label: zod.z.string().min(1),
|
|
54461
|
+
fieldPath: zod.z.string().min(1),
|
|
54462
|
+
source: OverrideSourceSchema,
|
|
54463
|
+
transform: CustomizeTransformDraftSchema
|
|
54464
|
+
});
|
|
54465
|
+
var PulseOverrideDraftSchema = zod.z.object({
|
|
54466
|
+
kind: zod.z.literal("pulse"),
|
|
54467
|
+
cap: zod.z.string().min(1),
|
|
54468
|
+
targetId: zod.z.string().min(1),
|
|
54469
|
+
enabled: zod.z.boolean(),
|
|
54470
|
+
debounceMs: zod.z.number().nonnegative(),
|
|
54471
|
+
edges: zod.z.array(zod.z.enum([
|
|
54472
|
+
"rising",
|
|
54473
|
+
"button",
|
|
54474
|
+
"native-event"
|
|
54475
|
+
])).min(1).optional(),
|
|
54476
|
+
sources: zod.z.array(OverrideSourceSchema).min(1)
|
|
54477
|
+
});
|
|
54478
|
+
var SpanSourceDraftSchema = OverrideSourceSchema.extend({ mode: zod.z.enum([
|
|
54479
|
+
"in-addition",
|
|
54480
|
+
"confirm",
|
|
54481
|
+
"replace"
|
|
54482
|
+
]).optional() });
|
|
54483
|
+
var SpanOverrideDraftSchema = zod.z.object({
|
|
54484
|
+
kind: zod.z.literal("span"),
|
|
54485
|
+
cap: zod.z.string().min(1),
|
|
54486
|
+
targetId: zod.z.string().min(1),
|
|
54487
|
+
timeoutMs: zod.z.number().nonnegative(),
|
|
54488
|
+
cooldownMs: zod.z.number().nonnegative().optional(),
|
|
54489
|
+
sources: zod.z.array(SpanSourceDraftSchema)
|
|
54490
|
+
});
|
|
54491
|
+
zod.z.discriminatedUnion("kind", [
|
|
54492
|
+
ScalarOverrideDraftSchema,
|
|
54493
|
+
KeyedArrayOverrideDraftSchema,
|
|
54494
|
+
PulseOverrideDraftSchema,
|
|
54495
|
+
SpanOverrideDraftSchema
|
|
54496
|
+
]);
|
|
54497
|
+
zod.z.object({
|
|
54498
|
+
targetId: zod.z.string().min(1),
|
|
54499
|
+
configured: zod.z.boolean(),
|
|
54500
|
+
source: zod.z.enum(["native", "assigned"]),
|
|
54501
|
+
state: zod.z.enum([
|
|
54502
|
+
"active",
|
|
54503
|
+
"stale",
|
|
54504
|
+
"released",
|
|
54505
|
+
"unavailable"
|
|
54506
|
+
]),
|
|
54507
|
+
reason: zod.z.string().nullable()
|
|
54508
|
+
});
|
|
54509
|
+
/**
|
|
54510
|
+
* What a running-threshold proposal says (planning#405). The schema is the
|
|
54511
|
+
* type: the algorithm, the capability method and the UI all read `z.infer`.
|
|
54512
|
+
*
|
|
54513
|
+
* A proposal is read-only advice: it carries the numbers it was derived from
|
|
54514
|
+
* (`evidence`) so the operator can judge it, and an `insufficient` answer names
|
|
54515
|
+
* WHY with a typed reason and the catalog defaults, never an invented number.
|
|
54516
|
+
*/
|
|
54517
|
+
var RunningProposalTierSchema = zod.z.enum(["raw", "5m"]);
|
|
54518
|
+
var RunningProposalConfidenceSchema = zod.z.enum([
|
|
54519
|
+
"high",
|
|
54520
|
+
"medium",
|
|
54521
|
+
"low"
|
|
54522
|
+
]);
|
|
54523
|
+
var RunningProposalInsufficientReasonSchema = zod.z.enum([
|
|
54524
|
+
"no-history",
|
|
54525
|
+
"span-too-short",
|
|
54526
|
+
"truncated",
|
|
54527
|
+
"no-idle-floor",
|
|
54528
|
+
"no-runs",
|
|
54529
|
+
"no-separation"
|
|
54530
|
+
]);
|
|
54531
|
+
var RunningProposalReplaySchema = zod.z.object({
|
|
54532
|
+
/** Intervals the real dwell expression held true over the window. */
|
|
54533
|
+
intervals: zod.z.number().int().nonnegative(),
|
|
54534
|
+
/** Intervals outside every run, or a second interval inside one. */
|
|
54535
|
+
extra: zod.z.number().int().nonnegative(),
|
|
54536
|
+
/** Runs without an interval of their own (none, or merged into a neighbour). */
|
|
54537
|
+
missed: zod.z.number().int().nonnegative()
|
|
54538
|
+
});
|
|
54539
|
+
var RunningProposalEvidenceSchema = zod.z.object({
|
|
54540
|
+
tier: RunningProposalTierSchema,
|
|
54541
|
+
spanMs: zod.z.number().nonnegative(),
|
|
54542
|
+
from: zod.z.number(),
|
|
54543
|
+
to: zod.z.number(),
|
|
54544
|
+
points: zod.z.number().int().nonnegative(),
|
|
54545
|
+
runsFound: zod.z.number().int().nonnegative(),
|
|
54546
|
+
pausesFound: zod.z.number().int().nonnegative(),
|
|
54547
|
+
longestPauseMs: zod.z.number().nonnegative(),
|
|
54548
|
+
idleFloorW: zod.z.number(),
|
|
54549
|
+
noiseCeilingW: zod.z.number(),
|
|
54550
|
+
plateauW: zod.z.number(),
|
|
54551
|
+
replay: RunningProposalReplaySchema
|
|
54552
|
+
});
|
|
54553
|
+
var RunningProposalInsufficientEvidenceSchema = zod.z.object({
|
|
54554
|
+
spanMs: zod.z.number().nonnegative(),
|
|
54555
|
+
points: zod.z.number().int().nonnegative(),
|
|
54556
|
+
runsFound: zod.z.number().int().nonnegative()
|
|
54557
|
+
});
|
|
54558
|
+
var RunningThresholdProposalSchema = zod.z.discriminatedUnion("state", [zod.z.object({
|
|
54559
|
+
state: zod.z.literal("proposal"),
|
|
54560
|
+
transform: ThresholdTransformDraftSchema,
|
|
54561
|
+
evidence: RunningProposalEvidenceSchema,
|
|
54562
|
+
confidence: RunningProposalConfidenceSchema,
|
|
54563
|
+
/** Why the confidence is not higher; empty when nothing held it back. */
|
|
54564
|
+
notes: zod.z.array(zod.z.string())
|
|
54565
|
+
}), zod.z.object({
|
|
54566
|
+
state: zod.z.literal("insufficient"),
|
|
54567
|
+
reason: RunningProposalInsufficientReasonSchema,
|
|
54568
|
+
evidence: RunningProposalInsufficientEvidenceSchema,
|
|
54569
|
+
/** The catalog defaults, offered as what stands when nothing better is known. */
|
|
54570
|
+
fallback: ThresholdTransformDraftSchema
|
|
54571
|
+
})]);
|
|
54572
|
+
/**
|
|
54790
54573
|
* The report of a one-shot "move this owner's plaintext secrets into the
|
|
54791
54574
|
* keychain" run (D878). COUNTS only - never a value, never a ref.
|
|
54792
54575
|
*
|
|
@@ -55283,6 +55066,21 @@ var coreBlocksCapability = {
|
|
|
55283
55066
|
access: "view"
|
|
55284
55067
|
}),
|
|
55285
55068
|
/**
|
|
55069
|
+
* Propose the running threshold and dwells of a SOURCE device's power
|
|
55070
|
+
* field from its own history (planning#405). Read-only advice: nothing is
|
|
55071
|
+
* stored, the operator applies it through the ordinary save. An answer
|
|
55072
|
+
* with too little history says why, with the catalog defaults.
|
|
55073
|
+
*/
|
|
55074
|
+
proposeRunningThreshold: method(zod.z.object({
|
|
55075
|
+
deviceId: zod.z.number().int(),
|
|
55076
|
+
cap: zod.z.string().min(1),
|
|
55077
|
+
fieldPath: zod.z.string().min(1),
|
|
55078
|
+
deviceType: zod.z.enum(DeviceType).optional()
|
|
55079
|
+
}), RunningThresholdProposalSchema, {
|
|
55080
|
+
auth: "admin",
|
|
55081
|
+
access: "view"
|
|
55082
|
+
}),
|
|
55083
|
+
/**
|
|
55286
55084
|
* An automation block reports one run (or one coalesced skip) to the hub's
|
|
55287
55085
|
* `runs` ledger. Only the block itself may: the transport stamps
|
|
55288
55086
|
* `callerAddonId`, and anything but `core-block-<blockId>` is refused.
|
|
@@ -61279,7 +61077,7 @@ var FanPresetCaptureResultSchema = zod.z.object({
|
|
|
61279
61077
|
items: zod.z.array(FanCaptureItemSchema),
|
|
61280
61078
|
omitted: zod.z.array(FanCaptureOmissionSchema)
|
|
61281
61079
|
});
|
|
61282
|
-
var deviceInput$
|
|
61080
|
+
var deviceInput$2 = zod.z.object({ deviceId: zod.z.number().int().nonnegative() });
|
|
61283
61081
|
var fanPresetsCustomize = {
|
|
61284
61082
|
version: 1,
|
|
61285
61083
|
targets: [{
|
|
@@ -61297,12 +61095,12 @@ var fanPresetsCapability = {
|
|
|
61297
61095
|
scope: "system",
|
|
61298
61096
|
mode: "singleton",
|
|
61299
61097
|
methods: {
|
|
61300
|
-
getPresets: method(deviceInput$
|
|
61301
|
-
setPresets: method(deviceInput$
|
|
61098
|
+
getPresets: method(deviceInput$2, zod.z.array(FanPresetSchema), { auth: "protected" }),
|
|
61099
|
+
setPresets: method(deviceInput$2.extend({ presets: zod.z.array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
|
|
61302
61100
|
kind: "mutation",
|
|
61303
61101
|
auth: "admin"
|
|
61304
61102
|
}),
|
|
61305
|
-
applyPreset: method(deviceInput$
|
|
61103
|
+
applyPreset: method(deviceInput$2.extend({ presetId: zod.z.string().min(1) }), FanPresetApplyResultSchema, {
|
|
61306
61104
|
kind: "mutation",
|
|
61307
61105
|
auth: "protected"
|
|
61308
61106
|
}),
|
|
@@ -61315,7 +61113,7 @@ var fanPresetsCapability = {
|
|
|
61315
61113
|
* unknown is left out and named in `omitted`, never captured as 0. Nothing
|
|
61316
61114
|
* is saved.
|
|
61317
61115
|
*/
|
|
61318
|
-
capturePreset: method(deviceInput$
|
|
61116
|
+
capturePreset: method(deviceInput$2.extend({
|
|
61319
61117
|
fields: zod.z.array(FanCaptureFieldSchema).optional(),
|
|
61320
61118
|
steps: zod.z.array(ActionStepSchema).max(20).default([])
|
|
61321
61119
|
}), FanPresetCaptureResultSchema, { auth: "protected" })
|
|
@@ -80174,6 +79972,117 @@ var powerMeterCapability = {
|
|
|
80174
79972
|
volatileStateFields: ["lastFetchedAt"],
|
|
80175
79973
|
customize: powerMeterCustomize
|
|
80176
79974
|
};
|
|
79975
|
+
var PowerSourceRefusalReasonSchema = zod.z.enum([
|
|
79976
|
+
"no-power-source",
|
|
79977
|
+
"switch-missing",
|
|
79978
|
+
"switch-offline",
|
|
79979
|
+
"switch-unknown",
|
|
79980
|
+
"restart-in-progress",
|
|
79981
|
+
"switch-call-failed"
|
|
79982
|
+
]);
|
|
79983
|
+
var PowerSourceActionResultSchema = zod.z.discriminatedUnion("accepted", [zod.z.object({ accepted: zod.z.literal(true) }), zod.z.object({
|
|
79984
|
+
accepted: zod.z.literal(false),
|
|
79985
|
+
reason: PowerSourceRefusalReasonSchema,
|
|
79986
|
+
/** One line for the operator, naming the switch. */
|
|
79987
|
+
message: zod.z.string()
|
|
79988
|
+
})]);
|
|
79989
|
+
var PowerSourceInfoSchema = zod.z.object({
|
|
79990
|
+
/** False when the device has no power source linked; the rest is then empty. */
|
|
79991
|
+
linked: zod.z.boolean(),
|
|
79992
|
+
switchDeviceId: zod.z.number().nullable(),
|
|
79993
|
+
switchName: zod.z.string().nullable(),
|
|
79994
|
+
/** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
|
|
79995
|
+
switchOn: zod.z.boolean().nullable(),
|
|
79996
|
+
switchOnline: zod.z.boolean().nullable(),
|
|
79997
|
+
restartInProgress: zod.z.boolean(),
|
|
79998
|
+
offSeconds: zod.z.number().int()
|
|
79999
|
+
});
|
|
80000
|
+
/** The composed slice: the switch state the link mirrors, plus the stored off time. */
|
|
80001
|
+
var PowerSourceStateSchema = zod.z.object({
|
|
80002
|
+
/** Null while the switch has not reported: unknown is never `false` (D393). */
|
|
80003
|
+
switchOn: zod.z.boolean().nullable(),
|
|
80004
|
+
offSeconds: zod.z.number().int(),
|
|
80005
|
+
lastFetchedAt: zod.z.number()
|
|
80006
|
+
});
|
|
80007
|
+
var POWER_SOURCE_DEVICE_TYPES = [
|
|
80008
|
+
DeviceType.Gateway,
|
|
80009
|
+
DeviceType.Hub,
|
|
80010
|
+
DeviceType.Camera,
|
|
80011
|
+
DeviceType.Sensor,
|
|
80012
|
+
DeviceType.MediaPlayer,
|
|
80013
|
+
DeviceType.Vacuum,
|
|
80014
|
+
DeviceType.Generic,
|
|
80015
|
+
DeviceType.Washer,
|
|
80016
|
+
DeviceType.Dryer,
|
|
80017
|
+
DeviceType.Dishwasher,
|
|
80018
|
+
DeviceType.PetFountain,
|
|
80019
|
+
DeviceType.Fan,
|
|
80020
|
+
DeviceType.Humidifier,
|
|
80021
|
+
DeviceType.Climate,
|
|
80022
|
+
DeviceType.WaterHeater
|
|
80023
|
+
];
|
|
80024
|
+
var powerSourceCustomize = {
|
|
80025
|
+
version: 1,
|
|
80026
|
+
targets: [{
|
|
80027
|
+
id: "switch",
|
|
80028
|
+
cardinality: "scalar",
|
|
80029
|
+
vocabulary: {
|
|
80030
|
+
cap: "power-source",
|
|
80031
|
+
stateField: "switchOn"
|
|
80032
|
+
},
|
|
80033
|
+
deviceTypes: POWER_SOURCE_DEVICE_TYPES,
|
|
80034
|
+
apply: "add",
|
|
80035
|
+
path: "switchOn",
|
|
80036
|
+
sources: [{
|
|
80037
|
+
kind: "switch",
|
|
80038
|
+
transforms: [{ kind: "identity" }]
|
|
80039
|
+
}],
|
|
80040
|
+
companions: [{
|
|
80041
|
+
kind: "constant",
|
|
80042
|
+
path: "offSeconds",
|
|
80043
|
+
value: 10,
|
|
80044
|
+
when: "add"
|
|
80045
|
+
}, {
|
|
80046
|
+
kind: "clock",
|
|
80047
|
+
path: "lastFetchedAt",
|
|
80048
|
+
when: "always"
|
|
80049
|
+
}],
|
|
80050
|
+
sourceReport: { status: "assignment-status" }
|
|
80051
|
+
}]
|
|
80052
|
+
};
|
|
80053
|
+
var deviceInput$1 = zod.z.object({ deviceId: zod.z.number().int().nonnegative() });
|
|
80054
|
+
var powerSourceCapability = {
|
|
80055
|
+
name: "power-source",
|
|
80056
|
+
scope: "device",
|
|
80057
|
+
mode: "singleton",
|
|
80058
|
+
deviceTypes: POWER_SOURCE_DEVICE_TYPES,
|
|
80059
|
+
methods: {
|
|
80060
|
+
getStatus: systemMethod(deviceInput$1, PowerSourceInfoSchema, { auth: "admin" }),
|
|
80061
|
+
powerOn: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
|
|
80062
|
+
kind: "mutation",
|
|
80063
|
+
auth: "admin"
|
|
80064
|
+
}),
|
|
80065
|
+
powerOff: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
|
|
80066
|
+
kind: "mutation",
|
|
80067
|
+
auth: "admin"
|
|
80068
|
+
}),
|
|
80069
|
+
forceRestart: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
|
|
80070
|
+
kind: "mutation",
|
|
80071
|
+
auth: "admin"
|
|
80072
|
+
})
|
|
80073
|
+
},
|
|
80074
|
+
runtimeState: PowerSourceStateSchema,
|
|
80075
|
+
customize: powerSourceCustomize,
|
|
80076
|
+
/**
|
|
80077
|
+
* Runtime-state durability: **session** — mirrored from the linked switch on
|
|
80078
|
+
* its next report; a restored value would outlive the reading it names.
|
|
80079
|
+
*
|
|
80080
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
80081
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
80082
|
+
*/
|
|
80083
|
+
durability: "session",
|
|
80084
|
+
history: "none"
|
|
80085
|
+
};
|
|
80177
80086
|
/**
|
|
80178
80087
|
* Presence cap. Models HA `person.*` and `device_tracker.*` entities
|
|
80179
80088
|
* on `DeviceType.Presence`. Read-only — no setters: presence is
|
|
@@ -92559,6 +92468,335 @@ zod.z.discriminatedUnion("kind", [zod.z.object({
|
|
|
92559
92468
|
kind: zod.z.literal("pronto"),
|
|
92560
92469
|
code: zod.z.string()
|
|
92561
92470
|
})]);
|
|
92471
|
+
/**
|
|
92472
|
+
* Propose a running threshold from a device's own power history (planning#405).
|
|
92473
|
+
*
|
|
92474
|
+
* Pure and deterministic: the same series gives the same answer. The series is
|
|
92475
|
+
* a HELD-VALUE step series — a point's value stands until the next point — which
|
|
92476
|
+
* is how device-history stores a gauge, so "time at a level" is exact, not a
|
|
92477
|
+
* count of samples.
|
|
92478
|
+
*
|
|
92479
|
+
* 1. idle floor F = time-weighted median; noise ceiling N = highest value seen
|
|
92480
|
+
* near F. A device that is not near one level most of the time has no floor.
|
|
92481
|
+
* 2. coarse activity = above max(2N, N + 5 W); consecutive stretches are episodes.
|
|
92482
|
+
* 3. gaps between episodes split in two by the largest log-scale jump (>= 3x):
|
|
92483
|
+
* the short ones are pauses INSIDE a run (a soak), the long ones separate runs.
|
|
92484
|
+
* 4. T = geometric mean of N and the plateau's 10th percentile, snapped to a
|
|
92485
|
+
* grid a person would type; stop dwell covers the longest pause; start dwell
|
|
92486
|
+
* covers the longest standby blip above T.
|
|
92487
|
+
* 5. the numbers are proved by REPLAY through the real `dwell` evaluation: each
|
|
92488
|
+
* run must hold exactly one true interval and nothing may flap outside.
|
|
92489
|
+
*/
|
|
92490
|
+
var SECOND_MS = 1e3;
|
|
92491
|
+
var MINUTE_MS$1 = 60 * SECOND_MS;
|
|
92492
|
+
var PROPOSAL_MIN_SPAN_MS = 24 * (60 * MINUTE_MS$1);
|
|
92493
|
+
var MIN_ACTIVE_MS = 10 * MINUTE_MS$1;
|
|
92494
|
+
var IDLE_BAND_FRACTION = .5;
|
|
92495
|
+
var IDLE_BAND_MIN_W = 3;
|
|
92496
|
+
var MIN_IDLE_SHARE = .5;
|
|
92497
|
+
var COARSE_FACTOR = 2;
|
|
92498
|
+
var COARSE_MARGIN_W = 5;
|
|
92499
|
+
var PAUSE_JUMP_FACTOR = 3;
|
|
92500
|
+
var GAP_MARGIN_W = 2;
|
|
92501
|
+
var STOP_FACTOR = 1.5;
|
|
92502
|
+
var STOP_STEP_MS = 30 * SECOND_MS;
|
|
92503
|
+
var STOP_MIN_MS = 60 * SECOND_MS;
|
|
92504
|
+
var STOP_MAX_MS = 20 * MINUTE_MS$1;
|
|
92505
|
+
var START_STEP_MS = 10 * SECOND_MS;
|
|
92506
|
+
var START_MIN_MS = 10 * SECOND_MS;
|
|
92507
|
+
var STOP_WALK_STEPS = 6;
|
|
92508
|
+
var PLATEAU_QUANTILE = .1;
|
|
92509
|
+
var HIGH_CONFIDENCE_RUNS = 5;
|
|
92510
|
+
var MEDIUM_CONFIDENCE_RUNS = 2;
|
|
92511
|
+
/** The thresholds an operator would type, in watts. */
|
|
92512
|
+
var THRESHOLD_GRID_W = [
|
|
92513
|
+
1,
|
|
92514
|
+
2,
|
|
92515
|
+
3,
|
|
92516
|
+
5,
|
|
92517
|
+
8,
|
|
92518
|
+
10,
|
|
92519
|
+
15,
|
|
92520
|
+
20,
|
|
92521
|
+
30,
|
|
92522
|
+
50,
|
|
92523
|
+
75,
|
|
92524
|
+
100,
|
|
92525
|
+
150,
|
|
92526
|
+
200,
|
|
92527
|
+
300,
|
|
92528
|
+
500
|
|
92529
|
+
];
|
|
92530
|
+
function proposeRunningThreshold(series) {
|
|
92531
|
+
const segments = toSegments(series);
|
|
92532
|
+
const spanMs = segments.length === 0 ? 0 : series.to - (segments[0]?.start ?? series.to);
|
|
92533
|
+
const insufficient = (reason, runsFound) => ({
|
|
92534
|
+
state: "insufficient",
|
|
92535
|
+
reason,
|
|
92536
|
+
evidence: {
|
|
92537
|
+
spanMs,
|
|
92538
|
+
points: series.points.length,
|
|
92539
|
+
runsFound
|
|
92540
|
+
},
|
|
92541
|
+
fallback: {
|
|
92542
|
+
kind: "threshold",
|
|
92543
|
+
comparison: "gte",
|
|
92544
|
+
threshold: 5,
|
|
92545
|
+
startDwellMs: RUNNING_POWER_START_DELAY_MS,
|
|
92546
|
+
stopDwellMs: RUNNING_POWER_STOP_DELAY_MS
|
|
92547
|
+
}
|
|
92548
|
+
});
|
|
92549
|
+
if (series.truncated) return insufficient("truncated", 0);
|
|
92550
|
+
if (segments.length === 0) return insufficient("no-history", 0);
|
|
92551
|
+
if (spanMs < 864e5) return insufficient("span-too-short", 0);
|
|
92552
|
+
const idleFloor = weightedQuantile(weigh(segments), .5);
|
|
92553
|
+
const band = Math.max(IDLE_BAND_MIN_W, IDLE_BAND_FRACTION * idleFloor);
|
|
92554
|
+
const quiet = segments.filter((s) => Math.abs(s.value - idleFloor) <= band);
|
|
92555
|
+
if (durationOf(quiet) < MIN_IDLE_SHARE * durationOf(segments)) return insufficient("no-idle-floor", 0);
|
|
92556
|
+
const noise = Math.max(idleFloor, ...quiet.map((s) => s.value));
|
|
92557
|
+
const coarse = Math.max(COARSE_FACTOR * noise, noise + COARSE_MARGIN_W);
|
|
92558
|
+
const active = segments.filter((s) => s.value > coarse);
|
|
92559
|
+
const episodes = mergeContiguous(active);
|
|
92560
|
+
if (durationOf(active) < MIN_ACTIVE_MS || episodes.length === 0) return insufficient("no-runs", 0);
|
|
92561
|
+
const { runs, pauses, betweenGaps } = splitRuns(episodes);
|
|
92562
|
+
const plateau = weightedQuantile(weigh(active.filter((s) => runs.some((r) => s.start < r.end && s.end > r.start))), PLATEAU_QUANTILE);
|
|
92563
|
+
const threshold = pickThreshold(noise, plateau);
|
|
92564
|
+
if (threshold === null) return insufficient("no-separation", runs.length);
|
|
92565
|
+
const notes = [];
|
|
92566
|
+
const longestPause = pauses.length === 0 ? 0 : Math.max(...pauses);
|
|
92567
|
+
let stop = clamp(roundUp(STOP_FACTOR * longestPause, STOP_STEP_MS), STOP_MIN_MS, STOP_MAX_MS);
|
|
92568
|
+
const shortestGap = betweenGaps.length === 0 ? null : Math.min(...betweenGaps);
|
|
92569
|
+
if (shortestGap !== null && stop > shortestGap / 2) notes.push("stop-dwell-exceeds-half-of-shortest-gap");
|
|
92570
|
+
const blips = excursionsOutside(segments, threshold, runs);
|
|
92571
|
+
let start = Math.max(START_MIN_MS, roundUp(STOP_FACTOR * maxOf(blips), START_STEP_MS));
|
|
92572
|
+
const shortestRun = Math.min(...runs.map((r) => r.end - r.start));
|
|
92573
|
+
if (start > shortestRun / 2) {
|
|
92574
|
+
notes.push("start-dwell-exceeds-half-of-shortest-run");
|
|
92575
|
+
start = Math.max(START_MIN_MS, Math.floor(shortestRun / 2 / START_STEP_MS) * START_STEP_MS);
|
|
92576
|
+
}
|
|
92577
|
+
let replay = replayDwell(segments, series.to, threshold, start, stop, runs);
|
|
92578
|
+
for (let step = 0; step < STOP_WALK_STEPS && !isClean(replay) && stop < STOP_MAX_MS; step += 1) {
|
|
92579
|
+
stop = Math.min(STOP_MAX_MS, roundUp(stop * STOP_FACTOR, STOP_STEP_MS));
|
|
92580
|
+
replay = replayDwell(segments, series.to, threshold, start, stop, runs);
|
|
92581
|
+
}
|
|
92582
|
+
if (!isClean(replay)) notes.push("replay-not-clean");
|
|
92583
|
+
return {
|
|
92584
|
+
state: "proposal",
|
|
92585
|
+
transform: {
|
|
92586
|
+
kind: "threshold",
|
|
92587
|
+
comparison: "gte",
|
|
92588
|
+
threshold,
|
|
92589
|
+
startDwellMs: start,
|
|
92590
|
+
stopDwellMs: stop
|
|
92591
|
+
},
|
|
92592
|
+
evidence: {
|
|
92593
|
+
tier: series.tier,
|
|
92594
|
+
spanMs,
|
|
92595
|
+
from: series.from,
|
|
92596
|
+
to: series.to,
|
|
92597
|
+
points: series.points.length,
|
|
92598
|
+
runsFound: runs.length,
|
|
92599
|
+
pausesFound: pauses.length,
|
|
92600
|
+
longestPauseMs: longestPause,
|
|
92601
|
+
idleFloorW: idleFloor,
|
|
92602
|
+
noiseCeilingW: noise,
|
|
92603
|
+
plateauW: plateau,
|
|
92604
|
+
replay
|
|
92605
|
+
},
|
|
92606
|
+
confidence: confidenceOf(runs.length, series.tier, notes),
|
|
92607
|
+
notes
|
|
92608
|
+
};
|
|
92609
|
+
}
|
|
92610
|
+
function confidenceOf(runs, tier, notes) {
|
|
92611
|
+
if (notes.length > 0 || runs < MEDIUM_CONFIDENCE_RUNS) return "low";
|
|
92612
|
+
if (runs >= HIGH_CONFIDENCE_RUNS && tier === "raw") return "high";
|
|
92613
|
+
return "medium";
|
|
92614
|
+
}
|
|
92615
|
+
function isClean(replay) {
|
|
92616
|
+
return replay.extra === 0 && replay.missed === 0;
|
|
92617
|
+
}
|
|
92618
|
+
function toSegments(series) {
|
|
92619
|
+
const steps = [];
|
|
92620
|
+
if (series.before !== null) steps.push({
|
|
92621
|
+
t: series.from,
|
|
92622
|
+
value: series.before.value
|
|
92623
|
+
});
|
|
92624
|
+
for (const p of series.points) if (p.t >= series.from && p.t < series.to) steps.push(p);
|
|
92625
|
+
steps.sort((a, b) => a.t - b.t);
|
|
92626
|
+
const out = [];
|
|
92627
|
+
steps.forEach((step, i) => {
|
|
92628
|
+
const end = steps[i + 1]?.t ?? series.to;
|
|
92629
|
+
if (step.value === null || !Number.isFinite(step.value) || end <= step.t) return;
|
|
92630
|
+
out.push({
|
|
92631
|
+
start: step.t,
|
|
92632
|
+
end,
|
|
92633
|
+
value: step.value
|
|
92634
|
+
});
|
|
92635
|
+
});
|
|
92636
|
+
return out;
|
|
92637
|
+
}
|
|
92638
|
+
function durationOf(spans) {
|
|
92639
|
+
return spans.reduce((sum, s) => sum + (s.end - s.start), 0);
|
|
92640
|
+
}
|
|
92641
|
+
function maxOf(values) {
|
|
92642
|
+
return values.length === 0 ? 0 : Math.max(...values);
|
|
92643
|
+
}
|
|
92644
|
+
function clamp(value, min, max) {
|
|
92645
|
+
return Math.min(max, Math.max(min, value));
|
|
92646
|
+
}
|
|
92647
|
+
function roundUp(value, step) {
|
|
92648
|
+
return Math.ceil(value / step) * step;
|
|
92649
|
+
}
|
|
92650
|
+
/** Time-weighted quantile: the first value whose cumulative weight reaches `q`. */
|
|
92651
|
+
function weightedQuantile(items, q) {
|
|
92652
|
+
const rows = [...items].sort((a, b) => a.value - b.value);
|
|
92653
|
+
const total = rows.reduce((sum, r) => sum + r.weight, 0);
|
|
92654
|
+
let seen = 0;
|
|
92655
|
+
for (const row of rows) {
|
|
92656
|
+
seen += row.weight;
|
|
92657
|
+
if (seen >= q * total) return row.value;
|
|
92658
|
+
}
|
|
92659
|
+
return rows[rows.length - 1]?.value ?? 0;
|
|
92660
|
+
}
|
|
92661
|
+
function weigh(segments) {
|
|
92662
|
+
return segments.map((s) => ({
|
|
92663
|
+
value: s.value,
|
|
92664
|
+
weight: s.end - s.start
|
|
92665
|
+
}));
|
|
92666
|
+
}
|
|
92667
|
+
/** Contiguous segments (one ends where the next starts) become one span. */
|
|
92668
|
+
function mergeContiguous(segments) {
|
|
92669
|
+
const out = [];
|
|
92670
|
+
for (const s of segments) {
|
|
92671
|
+
const last = out[out.length - 1];
|
|
92672
|
+
if (last !== void 0 && last.end === s.start) out[out.length - 1] = {
|
|
92673
|
+
start: last.start,
|
|
92674
|
+
end: s.end
|
|
92675
|
+
};
|
|
92676
|
+
else out.push({
|
|
92677
|
+
start: s.start,
|
|
92678
|
+
end: s.end
|
|
92679
|
+
});
|
|
92680
|
+
}
|
|
92681
|
+
return out;
|
|
92682
|
+
}
|
|
92683
|
+
/**
|
|
92684
|
+
* Gaps between episodes: the largest log-scale jump (>= 3x) in the sorted gaps
|
|
92685
|
+
* separates pauses inside a run from the gaps between runs. No jump: every gap
|
|
92686
|
+
* separates runs — a lone pause is indistinguishable from a short standby.
|
|
92687
|
+
*/
|
|
92688
|
+
function splitRuns(episodes) {
|
|
92689
|
+
const gaps = episodes.slice(1).map((e, i) => e.start - (episodes[i]?.end ?? e.start));
|
|
92690
|
+
const sorted = [...gaps].sort((a, b) => a - b);
|
|
92691
|
+
let cut = null;
|
|
92692
|
+
let best = PAUSE_JUMP_FACTOR;
|
|
92693
|
+
for (let i = 0; i + 1 < sorted.length; i += 1) {
|
|
92694
|
+
const lo = sorted[i] ?? 0;
|
|
92695
|
+
const hi = sorted[i + 1] ?? 0;
|
|
92696
|
+
const ratio = lo > 0 ? hi / lo : Number.POSITIVE_INFINITY;
|
|
92697
|
+
if (ratio >= best) {
|
|
92698
|
+
best = ratio;
|
|
92699
|
+
cut = lo;
|
|
92700
|
+
}
|
|
92701
|
+
}
|
|
92702
|
+
const isPause = (gap) => cut !== null && gap <= cut;
|
|
92703
|
+
const runs = [];
|
|
92704
|
+
episodes.forEach((e, i) => {
|
|
92705
|
+
const gapBefore = i === 0 ? null : gaps[i - 1] ?? null;
|
|
92706
|
+
const last = runs[runs.length - 1];
|
|
92707
|
+
if (last !== void 0 && gapBefore !== null && isPause(gapBefore)) runs[runs.length - 1] = {
|
|
92708
|
+
start: last.start,
|
|
92709
|
+
end: e.end
|
|
92710
|
+
};
|
|
92711
|
+
else runs.push({
|
|
92712
|
+
start: e.start,
|
|
92713
|
+
end: e.end
|
|
92714
|
+
});
|
|
92715
|
+
});
|
|
92716
|
+
return {
|
|
92717
|
+
runs,
|
|
92718
|
+
pauses: gaps.filter(isPause),
|
|
92719
|
+
betweenGaps: gaps.filter((g) => !isPause(g))
|
|
92720
|
+
};
|
|
92721
|
+
}
|
|
92722
|
+
/** The grid value nearest (in log scale) to the geometric mean that still separates. */
|
|
92723
|
+
function pickThreshold(noise, plateau) {
|
|
92724
|
+
const target = Math.sqrt(Math.max(noise, .5) * plateau);
|
|
92725
|
+
let best = null;
|
|
92726
|
+
let bestDistance = Number.POSITIVE_INFINITY;
|
|
92727
|
+
for (const candidate of THRESHOLD_GRID_W) {
|
|
92728
|
+
if (candidate < noise + GAP_MARGIN_W || candidate > plateau) continue;
|
|
92729
|
+
const distance = Math.abs(Math.log(candidate / target));
|
|
92730
|
+
if (distance < bestDistance) {
|
|
92731
|
+
best = candidate;
|
|
92732
|
+
bestDistance = distance;
|
|
92733
|
+
}
|
|
92734
|
+
}
|
|
92735
|
+
return best;
|
|
92736
|
+
}
|
|
92737
|
+
/** Durations of stretches at or above `threshold` that lie outside every run. */
|
|
92738
|
+
function excursionsOutside(segments, threshold, runs) {
|
|
92739
|
+
return mergeContiguous(segments.filter((s) => s.value >= threshold)).filter((h) => !runs.some((r) => h.start < r.end && h.end > r.start)).map((h) => h.end - h.start);
|
|
92740
|
+
}
|
|
92741
|
+
/** Drive the real `dwell` evaluation over the series, deadlines included. */
|
|
92742
|
+
function replayDwell(segments, to, threshold, startMs, stopMs, runs) {
|
|
92743
|
+
const call = {
|
|
92744
|
+
kind: "dwell",
|
|
92745
|
+
pendingSince: null,
|
|
92746
|
+
latched: null,
|
|
92747
|
+
seenSince: null
|
|
92748
|
+
};
|
|
92749
|
+
let deadline = null;
|
|
92750
|
+
const hooks = { noteDeadline: (at) => {
|
|
92751
|
+
deadline = at;
|
|
92752
|
+
} };
|
|
92753
|
+
const intervals = [];
|
|
92754
|
+
let openAt = null;
|
|
92755
|
+
const evaluate = (active, at) => {
|
|
92756
|
+
deadline = null;
|
|
92757
|
+
const answer = evaluateDwell(active, startMs, stopMs, call, at, hooks);
|
|
92758
|
+
if (answer === true && openAt === null) openAt = at;
|
|
92759
|
+
if (answer !== true && openAt !== null) {
|
|
92760
|
+
intervals.push({
|
|
92761
|
+
start: openAt,
|
|
92762
|
+
end: at
|
|
92763
|
+
});
|
|
92764
|
+
openAt = null;
|
|
92765
|
+
}
|
|
92766
|
+
};
|
|
92767
|
+
segments.forEach((segment, i) => {
|
|
92768
|
+
const active = segment.value >= threshold;
|
|
92769
|
+
evaluate(active, segment.start);
|
|
92770
|
+
const next = segments[i + 1]?.start ?? to;
|
|
92771
|
+
while (deadline !== null && deadline <= next) evaluate(active, deadline);
|
|
92772
|
+
});
|
|
92773
|
+
if (openAt !== null) intervals.push({
|
|
92774
|
+
start: openAt,
|
|
92775
|
+
end: to
|
|
92776
|
+
});
|
|
92777
|
+
return judge(intervals, runs);
|
|
92778
|
+
}
|
|
92779
|
+
function judge(intervals, runs) {
|
|
92780
|
+
const hits = (i, r) => i.start < r.end && i.end > r.start;
|
|
92781
|
+
let extra = 0;
|
|
92782
|
+
let merged = 0;
|
|
92783
|
+
for (const interval of intervals) {
|
|
92784
|
+
const touched = runs.filter((r) => hits(interval, r)).length;
|
|
92785
|
+
if (touched === 0) extra += 1;
|
|
92786
|
+
merged += Math.max(0, touched - 1);
|
|
92787
|
+
}
|
|
92788
|
+
let missed = merged;
|
|
92789
|
+
for (const run of runs) {
|
|
92790
|
+
const mine = intervals.filter((i) => hits(i, run)).length;
|
|
92791
|
+
if (mine === 0) missed += 1;
|
|
92792
|
+
extra += Math.max(0, mine - 1);
|
|
92793
|
+
}
|
|
92794
|
+
return {
|
|
92795
|
+
intervals: intervals.length,
|
|
92796
|
+
extra,
|
|
92797
|
+
missed
|
|
92798
|
+
};
|
|
92799
|
+
}
|
|
92562
92800
|
function isValueOf(slot, value) {
|
|
92563
92801
|
return value.slot === slot;
|
|
92564
92802
|
}
|
|
@@ -93030,6 +93268,54 @@ function lockDoorLinkOfComposition(composition) {
|
|
|
93030
93268
|
sensor: x.source
|
|
93031
93269
|
};
|
|
93032
93270
|
}
|
|
93271
|
+
/**
|
|
93272
|
+
* Which smart switch powers a device (the `power-source` Customize extension):
|
|
93273
|
+
* the source its stored `power-source.switchOn` field reads, and the off time of
|
|
93274
|
+
* a forced restart stored beside it. Read from the STORED composition, never kept
|
|
93275
|
+
* as a second copy (D676). Shared by the hub (which acts on the switch) and the
|
|
93276
|
+
* admin UI (which shows it).
|
|
93277
|
+
*/
|
|
93278
|
+
/**
|
|
93279
|
+
* The stored off time, or the default when none is stored. A stored number out
|
|
93280
|
+
* of range is CLAMPED to the bounds (a hand-written value never refuses the
|
|
93281
|
+
* link, it just cannot cut power for an absurd time); a non-integer is rounded.
|
|
93282
|
+
*/
|
|
93283
|
+
function normalizeOffSeconds(value) {
|
|
93284
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return 10;
|
|
93285
|
+
return Math.min(120, Math.max(3, Math.round(value)));
|
|
93286
|
+
}
|
|
93287
|
+
/** The constant a stored `offSeconds` field carries, or undefined when it is not a literal number. */
|
|
93288
|
+
function storedOffSeconds(composition) {
|
|
93289
|
+
const feature = composition.features.find((f) => f.cap === "power-source");
|
|
93290
|
+
if (feature === void 0 || feature.kind !== "fields") return void 0;
|
|
93291
|
+
const field = feature.fields["offSeconds"];
|
|
93292
|
+
if (field === void 0 || field.kind !== "expression") return void 0;
|
|
93293
|
+
const n = Number(field.expr);
|
|
93294
|
+
return field.expr.trim() === "" || !Number.isFinite(n) ? void 0 : n;
|
|
93295
|
+
}
|
|
93296
|
+
/**
|
|
93297
|
+
* The link a composition stores. An `existing` target names its own device; a
|
|
93298
|
+
* `new` target (a composed device) is the composer's own device, so the caller
|
|
93299
|
+
* passes the block id and a new-target composition without one has no link.
|
|
93300
|
+
*/
|
|
93301
|
+
function powerSourceLinkOfComposition(composition, blockId) {
|
|
93302
|
+
if (composition === null) return null;
|
|
93303
|
+
let device;
|
|
93304
|
+
if (composition.target.kind === "existing") device = composition.target.device;
|
|
93305
|
+
else if (blockId !== void 0) device = composedDeviceRef(blockId);
|
|
93306
|
+
else return null;
|
|
93307
|
+
const feature = composition.features.find((f) => f.cap === "power-source");
|
|
93308
|
+
if (feature === void 0 || feature.kind !== "fields" || feature.enabled === false) return null;
|
|
93309
|
+
const field = feature.fields["switchOn"];
|
|
93310
|
+
if (field === void 0) return null;
|
|
93311
|
+
const read = fieldReads(field).find((r) => r.cap === "switch");
|
|
93312
|
+
if (read === void 0) return null;
|
|
93313
|
+
return {
|
|
93314
|
+
device,
|
|
93315
|
+
switch: read.source,
|
|
93316
|
+
offSeconds: normalizeOffSeconds(storedOffSeconds(composition))
|
|
93317
|
+
};
|
|
93318
|
+
}
|
|
93033
93319
|
SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
|
|
93034
93320
|
function fromRead(source, cap, fieldPath) {
|
|
93035
93321
|
return {
|
|
@@ -96145,6 +96431,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
96145
96431
|
access: "create",
|
|
96146
96432
|
role: "admin"
|
|
96147
96433
|
},
|
|
96434
|
+
"coreBlocks.proposeRunningThreshold": {
|
|
96435
|
+
capName: "core-blocks",
|
|
96436
|
+
capScope: "system",
|
|
96437
|
+
addonId: null,
|
|
96438
|
+
access: "view",
|
|
96439
|
+
role: "admin"
|
|
96440
|
+
},
|
|
96148
96441
|
"coreBlocks.reportAutomationRun": {
|
|
96149
96442
|
capName: "core-blocks",
|
|
96150
96443
|
capScope: "system",
|
|
@@ -105693,6 +105986,11 @@ Object.freeze({
|
|
|
105693
105986
|
form: "single",
|
|
105694
105987
|
optional: false
|
|
105695
105988
|
}],
|
|
105989
|
+
"coreBlocks.proposeRunningThreshold": [{
|
|
105990
|
+
name: "deviceId",
|
|
105991
|
+
form: "single",
|
|
105992
|
+
optional: false
|
|
105993
|
+
}],
|
|
105696
105994
|
"cover.close": [{
|
|
105697
105995
|
name: "deviceId",
|
|
105698
105996
|
form: "single",
|
|
@@ -108704,106 +109002,6 @@ var SESSION_ONLY_POLICY = {
|
|
|
108704
109002
|
durability: "session",
|
|
108705
109003
|
volatileFields: []
|
|
108706
109004
|
};
|
|
108707
|
-
/**
|
|
108708
|
-
* A saved Customize assignment (D936). The schema is the type: callers use
|
|
108709
|
-
* `z.infer`, they do not restate the shape.
|
|
108710
|
-
*/
|
|
108711
|
-
var OverrideSourceSchema = zod.z.object({
|
|
108712
|
-
addonId: zod.z.string().min(1),
|
|
108713
|
-
stableId: zod.z.string().min(1),
|
|
108714
|
-
cap: zod.z.string().min(1),
|
|
108715
|
-
fieldPath: zod.z.string().min(1)
|
|
108716
|
-
});
|
|
108717
|
-
var IdentityTransformDraftSchema = zod.z.object({ kind: zod.z.literal("identity") });
|
|
108718
|
-
var InvertTransformDraftSchema = zod.z.object({ kind: zod.z.literal("invert") });
|
|
108719
|
-
var ThresholdTransformDraftSchema = zod.z.object({
|
|
108720
|
-
kind: zod.z.literal("threshold"),
|
|
108721
|
-
comparison: zod.z.enum(["gte", "lte"]),
|
|
108722
|
-
threshold: zod.z.number(),
|
|
108723
|
-
startDwellMs: zod.z.number().nonnegative(),
|
|
108724
|
-
stopDwellMs: zod.z.number().nonnegative()
|
|
108725
|
-
});
|
|
108726
|
-
var LinearTransformDraftSchema = zod.z.object({
|
|
108727
|
-
kind: zod.z.literal("linear"),
|
|
108728
|
-
scale: zod.z.number(),
|
|
108729
|
-
offset: zod.z.number(),
|
|
108730
|
-
clampMin: zod.z.number().optional(),
|
|
108731
|
-
clampMax: zod.z.number().optional()
|
|
108732
|
-
});
|
|
108733
|
-
var EnumMapTransformDraftSchema = zod.z.object({
|
|
108734
|
-
kind: zod.z.literal("enum-map"),
|
|
108735
|
-
mapping: zod.z.record(zod.z.string(), zod.z.string().nullable())
|
|
108736
|
-
});
|
|
108737
|
-
var NumberBridgeTransformDraftSchema = zod.z.object({ kind: zod.z.literal("number") });
|
|
108738
|
-
var CustomizeTransformDraftSchema = zod.z.discriminatedUnion("kind", [
|
|
108739
|
-
IdentityTransformDraftSchema,
|
|
108740
|
-
InvertTransformDraftSchema,
|
|
108741
|
-
ThresholdTransformDraftSchema,
|
|
108742
|
-
LinearTransformDraftSchema,
|
|
108743
|
-
EnumMapTransformDraftSchema,
|
|
108744
|
-
NumberBridgeTransformDraftSchema
|
|
108745
|
-
]);
|
|
108746
|
-
var ScalarOverrideDraftSchema = zod.z.object({
|
|
108747
|
-
kind: zod.z.literal("scalar"),
|
|
108748
|
-
cap: zod.z.string().min(1),
|
|
108749
|
-
targetId: zod.z.string().min(1),
|
|
108750
|
-
source: OverrideSourceSchema,
|
|
108751
|
-
transform: CustomizeTransformDraftSchema
|
|
108752
|
-
});
|
|
108753
|
-
var KeyedArrayOverrideDraftSchema = zod.z.object({
|
|
108754
|
-
kind: zod.z.literal("keyedArray"),
|
|
108755
|
-
cap: zod.z.string().min(1),
|
|
108756
|
-
targetId: zod.z.string().min(1),
|
|
108757
|
-
key: zod.z.string().min(1),
|
|
108758
|
-
label: zod.z.string().min(1),
|
|
108759
|
-
fieldPath: zod.z.string().min(1),
|
|
108760
|
-
source: OverrideSourceSchema,
|
|
108761
|
-
transform: CustomizeTransformDraftSchema
|
|
108762
|
-
});
|
|
108763
|
-
var PulseOverrideDraftSchema = zod.z.object({
|
|
108764
|
-
kind: zod.z.literal("pulse"),
|
|
108765
|
-
cap: zod.z.string().min(1),
|
|
108766
|
-
targetId: zod.z.string().min(1),
|
|
108767
|
-
enabled: zod.z.boolean(),
|
|
108768
|
-
debounceMs: zod.z.number().nonnegative(),
|
|
108769
|
-
edges: zod.z.array(zod.z.enum([
|
|
108770
|
-
"rising",
|
|
108771
|
-
"button",
|
|
108772
|
-
"native-event"
|
|
108773
|
-
])).min(1).optional(),
|
|
108774
|
-
sources: zod.z.array(OverrideSourceSchema).min(1)
|
|
108775
|
-
});
|
|
108776
|
-
var SpanSourceDraftSchema = OverrideSourceSchema.extend({ mode: zod.z.enum([
|
|
108777
|
-
"in-addition",
|
|
108778
|
-
"confirm",
|
|
108779
|
-
"replace"
|
|
108780
|
-
]).optional() });
|
|
108781
|
-
var SpanOverrideDraftSchema = zod.z.object({
|
|
108782
|
-
kind: zod.z.literal("span"),
|
|
108783
|
-
cap: zod.z.string().min(1),
|
|
108784
|
-
targetId: zod.z.string().min(1),
|
|
108785
|
-
timeoutMs: zod.z.number().nonnegative(),
|
|
108786
|
-
cooldownMs: zod.z.number().nonnegative().optional(),
|
|
108787
|
-
sources: zod.z.array(SpanSourceDraftSchema)
|
|
108788
|
-
});
|
|
108789
|
-
zod.z.discriminatedUnion("kind", [
|
|
108790
|
-
ScalarOverrideDraftSchema,
|
|
108791
|
-
KeyedArrayOverrideDraftSchema,
|
|
108792
|
-
PulseOverrideDraftSchema,
|
|
108793
|
-
SpanOverrideDraftSchema
|
|
108794
|
-
]);
|
|
108795
|
-
zod.z.object({
|
|
108796
|
-
targetId: zod.z.string().min(1),
|
|
108797
|
-
configured: zod.z.boolean(),
|
|
108798
|
-
source: zod.z.enum(["native", "assigned"]),
|
|
108799
|
-
state: zod.z.enum([
|
|
108800
|
-
"active",
|
|
108801
|
-
"stale",
|
|
108802
|
-
"released",
|
|
108803
|
-
"unavailable"
|
|
108804
|
-
]),
|
|
108805
|
-
reason: zod.z.string().nullable()
|
|
108806
|
-
});
|
|
108807
109005
|
var G711_SCALE_CORRECTION_DB = {
|
|
108808
109006
|
PCMU: 20 * Math.log10(4),
|
|
108809
109007
|
PCMA: 20 * Math.log10(8)
|
|
@@ -111091,6 +111289,12 @@ Object.defineProperty(exports, "HUB_MDNS_TXT_KEYS", {
|
|
|
111091
111289
|
return HUB_MDNS_TXT_KEYS;
|
|
111092
111290
|
}
|
|
111093
111291
|
});
|
|
111292
|
+
Object.defineProperty(exports, "HelperMemberSchema", {
|
|
111293
|
+
enumerable: true,
|
|
111294
|
+
get: function() {
|
|
111295
|
+
return HelperMemberSchema;
|
|
111296
|
+
}
|
|
111297
|
+
});
|
|
111094
111298
|
Object.defineProperty(exports, "HvacModeSchema", {
|
|
111095
111299
|
enumerable: true,
|
|
111096
111300
|
get: function() {
|
|
@@ -111205,6 +111409,12 @@ Object.defineProperty(exports, "PREFERENCES_MAX_VALUE_BYTES", {
|
|
|
111205
111409
|
return PREFERENCES_MAX_VALUE_BYTES;
|
|
111206
111410
|
}
|
|
111207
111411
|
});
|
|
111412
|
+
Object.defineProperty(exports, "PROPOSAL_MIN_SPAN_MS", {
|
|
111413
|
+
enumerable: true,
|
|
111414
|
+
get: function() {
|
|
111415
|
+
return PROPOSAL_MIN_SPAN_MS;
|
|
111416
|
+
}
|
|
111417
|
+
});
|
|
111208
111418
|
Object.defineProperty(exports, "PlaintextSecretError", {
|
|
111209
111419
|
enumerable: true,
|
|
111210
111420
|
get: function() {
|
|
@@ -112213,6 +112423,12 @@ Object.defineProperty(exports, "historyItemFieldPath", {
|
|
|
112213
112423
|
return historyItemFieldPath;
|
|
112214
112424
|
}
|
|
112215
112425
|
});
|
|
112426
|
+
Object.defineProperty(exports, "historyRetentionFromSettings", {
|
|
112427
|
+
enumerable: true,
|
|
112428
|
+
get: function() {
|
|
112429
|
+
return historyRetentionFromSettings;
|
|
112430
|
+
}
|
|
112431
|
+
});
|
|
112216
112432
|
Object.defineProperty(exports, "historyUnitFor", {
|
|
112217
112433
|
enumerable: true,
|
|
112218
112434
|
get: function() {
|
|
@@ -112747,6 +112963,12 @@ Object.defineProperty(exports, "procedureAuthKey", {
|
|
|
112747
112963
|
return procedureAuthKey;
|
|
112748
112964
|
}
|
|
112749
112965
|
});
|
|
112966
|
+
Object.defineProperty(exports, "proposeRunningThreshold", {
|
|
112967
|
+
enumerable: true,
|
|
112968
|
+
get: function() {
|
|
112969
|
+
return proposeRunningThreshold;
|
|
112970
|
+
}
|
|
112971
|
+
});
|
|
112750
112972
|
Object.defineProperty(exports, "ptzAutotrackCapability", {
|
|
112751
112973
|
enumerable: true,
|
|
112752
112974
|
get: function() {
|