@camstack/server 1.2.802 → 1.2.804
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 +12 -0
- package/dist/api/trpc/generated-cap-routers.js +18 -0
- package/package.json +7 -10
- package/system/dist/{agent-https-CzMpclQr.js → agent-https-BFvIRgIa.js} +1 -1
- package/system/dist/{agent-https-CfPGbJ21.mjs → agent-https-Bp70et-W.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/composed-device.d.ts +5 -0
- package/system/dist/builtins/composer/composer.addon.js +42 -6
- package/system/dist/builtins/composer/composer.addon.mjs +42 -6
- package/system/dist/builtins/composer/composer.d.ts +13 -0
- 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/core-blocks.addon.js +65 -6
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +65 -6
- package/system/dist/builtins/core-blocks/timed-run/timed-run-service.d.ts +17 -0
- package/system/dist/builtins/core-blocks/timed-run/timed-run-wiring.d.ts +6 -0
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-config-contribution.d.ts +1 -0
- package/system/dist/builtins/device-manager/device-manager.addon.js +47 -2
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +47 -2
- package/system/dist/builtins/device-manager/timed-run-config-schema.d.ts +18 -0
- 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 +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- 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 +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -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 +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- 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 +3 -3
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-CJxojquW.mjs → capture-engine-CQBSd3V1.mjs} +1 -1
- package/system/dist/{capture-engine-Us8Ocffb.js → capture-engine-Sh4zAKR0.js} +1 -1
- package/system/dist/{composition-sources-DcsjjTIu.mjs → composition-sources-BxSmsp0_.mjs} +1 -1
- package/system/dist/{composition-sources-D2z7D7bY.js → composition-sources-rAsv2tZD.js} +1 -1
- package/system/dist/{constants-BOMAH5bO.js → constants-BCQCUHl9.js} +1 -1
- package/system/dist/{constants-DVqHyOzQ.mjs → constants-BfgfqUFH.mjs} +1 -1
- package/system/dist/{device-ca-NlhUUsex.js → device-ca-BgCwLzMX.js} +1 -1
- package/system/dist/{device-ca-zAWpen18.mjs → device-ca-D7JZLEAn.mjs} +1 -1
- package/system/dist/{dist-BccX5DOW.js → dist-BpIvMLVc.js} +595 -374
- package/system/dist/{dist-DYrP8WdD.mjs → dist-Bvw9utDk.mjs} +572 -375
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-DpRlDWJY.js → hub-mdns-ciao-DZwGhLx-.js} +2 -2
- package/system/dist/{hub-mdns-ciao-BleXDm2r.mjs → hub-mdns-ciao-qefBaLZn.mjs} +2 -2
- package/system/dist/index.js +16 -10
- package/system/dist/index.mjs +16 -10
- package/system/dist/{legacy-integration-rows-door-BUyPyv8f.mjs → legacy-integration-rows-door-DCfOpaG3.mjs} +1 -1
- package/system/dist/{legacy-integration-rows-door-D2ZrX431.js → legacy-integration-rows-door-gqcsQX0L.js} +1 -1
- package/system/dist/{restore-archive-B1PE_1S2.mjs → restore-archive-BS6gi0i-.mjs} +1 -1
- package/system/dist/{restore-archive-DMUCmY3H.js → restore-archive-BtgtMV29.js} +1 -1
- package/system/dist/{wal-maintenance-CmNAtKgj.js → wal-maintenance-CyyJs8fh.js} +0 -0
- package/system/dist/{wal-maintenance-Ce71BVDk.mjs → wal-maintenance-DBCFpkyy.mjs} +0 -0
- package/system/package.json +1 -1
|
@@ -803,7 +803,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
803
803
|
return EventCategory;
|
|
804
804
|
}({});
|
|
805
805
|
//#endregion
|
|
806
|
-
//#region ../types/dist/device-type-
|
|
806
|
+
//#region ../types/dist/device-type-DxCT0krO.mjs
|
|
807
807
|
/**
|
|
808
808
|
import { errMsg } from '@camstack/types'
|
|
809
809
|
* Extract a human-readable message from an unknown error value.
|
|
@@ -965,6 +965,13 @@ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
|
965
965
|
* filters that want "all devices with on-motion behaviour".
|
|
966
966
|
*/
|
|
967
967
|
DeviceFeature["MotionTrigger"] = "motion-trigger";
|
|
968
|
+
/**
|
|
969
|
+
* Device can be run for a chosen time and then stopped. Mirrors the
|
|
970
|
+
* `timed-run` wrapper cap — the cap is bound by the core-blocks addon, not by
|
|
971
|
+
* a driver, so the flag is derived from the device's bindings
|
|
972
|
+
* (`featuresOfBoundCaps`). Gates the quick-run control in the viewer.
|
|
973
|
+
*/
|
|
974
|
+
DeviceFeature["TimedRun"] = "timed-run";
|
|
968
975
|
/** Light supports rgb-triplet color via `color` cap. */
|
|
969
976
|
DeviceFeature["LightColorRgb"] = "light-color-rgb";
|
|
970
977
|
/** Light supports HSV color via `color` cap. */
|
|
@@ -1076,6 +1083,15 @@ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
|
1076
1083
|
return DeviceFeature;
|
|
1077
1084
|
}({});
|
|
1078
1085
|
/**
|
|
1086
|
+
* The features a device carries because a capability is bound on it: a bound cap
|
|
1087
|
+
* whose name IS a `DeviceFeature` value. One rule for a device whose cap set
|
|
1088
|
+
* is not decided by one driver (a composed device, a wrapper cap) — a feature
|
|
1089
|
+
* is never listed twice, once as a cap and once as a table of names.
|
|
1090
|
+
*/
|
|
1091
|
+
function featuresOfBoundCaps(capNames) {
|
|
1092
|
+
return Object.values(DeviceFeature).filter((feature) => capNames.includes(feature));
|
|
1093
|
+
}
|
|
1094
|
+
/**
|
|
1079
1095
|
* Semantic role a device plays within its parent. Populated by driver
|
|
1080
1096
|
* addons when creating accessory devices (Reolink siren/floodlight/
|
|
1081
1097
|
* PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
|
|
@@ -1188,7 +1204,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
1188
1204
|
return DeviceRole;
|
|
1189
1205
|
}({});
|
|
1190
1206
|
//#endregion
|
|
1191
|
-
//#region ../types/dist/sleep-
|
|
1207
|
+
//#region ../types/dist/sleep-BPebgzeJ.mjs
|
|
1192
1208
|
/**
|
|
1193
1209
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
1194
1210
|
* window to float samples (D455).
|
|
@@ -8779,13 +8795,25 @@ Object.freeze({
|
|
|
8779
8795
|
"path": "temperature",
|
|
8780
8796
|
"valueType": "number"
|
|
8781
8797
|
}],
|
|
8782
|
-
"timed-run": [
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8798
|
+
"timed-run": [
|
|
8799
|
+
{
|
|
8800
|
+
"path": "activeUntil",
|
|
8801
|
+
"valueType": "number"
|
|
8802
|
+
},
|
|
8803
|
+
{
|
|
8804
|
+
"path": "requestedBy",
|
|
8805
|
+
"valueType": "string"
|
|
8806
|
+
},
|
|
8807
|
+
{
|
|
8808
|
+
"path": "quickRun.duration",
|
|
8809
|
+
"valueType": "number"
|
|
8810
|
+
},
|
|
8811
|
+
{
|
|
8812
|
+
"path": "quickRun.unit",
|
|
8813
|
+
"valueType": "enum",
|
|
8814
|
+
"enumValues": ["s", "min"]
|
|
8815
|
+
}
|
|
8816
|
+
],
|
|
8789
8817
|
"update": [
|
|
8790
8818
|
{
|
|
8791
8819
|
"path": "currentVersion",
|
|
@@ -9118,7 +9146,7 @@ function sleep(ms) {
|
|
|
9118
9146
|
return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
|
|
9119
9147
|
}
|
|
9120
9148
|
//#endregion
|
|
9121
|
-
//#region ../types/dist/composition-
|
|
9149
|
+
//#region ../types/dist/composition-Bx0JvKUU.mjs
|
|
9122
9150
|
var AUDIO_ENCODER_BY_CODEC = {
|
|
9123
9151
|
opus: "libopus",
|
|
9124
9152
|
aac: "aac",
|
|
@@ -54952,8 +54980,9 @@ function planComposition(composition, lookupCap, target) {
|
|
|
54952
54980
|
}, lookupCap, servedCommands));
|
|
54953
54981
|
}
|
|
54954
54982
|
const result = planFeature(feature, index, featureTarget, lookupCap, servedCommands);
|
|
54955
|
-
|
|
54956
|
-
|
|
54983
|
+
if (compositionFeatureEnabled(feature)) return result;
|
|
54984
|
+
return {
|
|
54985
|
+
problems: Object.keys(feature.fields).length === 0 ? result.problems.filter((p) => p.code !== "missing-field") : result.problems,
|
|
54957
54986
|
fields: [],
|
|
54958
54987
|
features: [],
|
|
54959
54988
|
events: []
|
|
@@ -85734,93 +85763,27 @@ var RunningFlipEventDataSchema = zod.z.object({
|
|
|
85734
85763
|
phase: zod.z.string().nullable()
|
|
85735
85764
|
});
|
|
85736
85765
|
var RUNNING_DEVICE_TYPES = Object.values(DeviceType);
|
|
85737
|
-
/**
|
|
85738
|
-
|
|
85739
|
-
|
|
85740
|
-
|
|
85741
|
-
|
|
85742
|
-
|
|
85743
|
-
|
|
85744
|
-
|
|
85745
|
-
|
|
85746
|
-
|
|
85747
|
-
|
|
85748
|
-
|
|
85749
|
-
|
|
85750
|
-
|
|
85751
|
-
|
|
85752
|
-
|
|
85753
|
-
|
|
85754
|
-
|
|
85755
|
-
|
|
85756
|
-
|
|
85757
|
-
|
|
85758
|
-
DeviceType.WaterHeater,
|
|
85759
|
-
DeviceType.Humidifier,
|
|
85760
|
-
DeviceType.Fan,
|
|
85761
|
-
DeviceType.Climate,
|
|
85762
|
-
DeviceType.Thermostat,
|
|
85763
|
-
DeviceType.PetFeeder,
|
|
85764
|
-
DeviceType.Heater
|
|
85765
|
-
],
|
|
85766
|
-
apply: "add",
|
|
85767
|
-
path: "running",
|
|
85768
|
-
sources: [
|
|
85769
|
-
{
|
|
85770
|
-
kind: "switch",
|
|
85771
|
-
transforms: [{ kind: "identity" }]
|
|
85772
|
-
},
|
|
85773
|
-
{
|
|
85774
|
-
kind: "binary",
|
|
85775
|
-
transforms: [{ kind: "identity" }, { kind: "invert" }]
|
|
85776
|
-
},
|
|
85777
|
-
{
|
|
85778
|
-
kind: "numeric",
|
|
85779
|
-
requiredUnit: "W",
|
|
85780
|
-
transforms: [{
|
|
85781
|
-
kind: "threshold",
|
|
85782
|
-
comparisons: ["gte", "lte"],
|
|
85783
|
-
comparison: "gte",
|
|
85784
|
-
defaultThreshold: 5,
|
|
85785
|
-
defaultStartDwellMs: RUNNING_POWER_START_DELAY_MS,
|
|
85786
|
-
defaultStopDwellMs: RUNNING_POWER_STOP_DELAY_MS,
|
|
85787
|
-
thresholdUnit: "W"
|
|
85788
|
-
}]
|
|
85789
|
-
}
|
|
85790
|
-
],
|
|
85791
|
-
companions: [
|
|
85792
|
-
{
|
|
85793
|
-
kind: "constant",
|
|
85794
|
-
path: "source",
|
|
85795
|
-
value: "assigned",
|
|
85796
|
-
when: "always"
|
|
85797
|
-
},
|
|
85798
|
-
{
|
|
85799
|
-
kind: "constant",
|
|
85800
|
-
path: "phase",
|
|
85801
|
-
value: null,
|
|
85802
|
-
when: "add"
|
|
85803
|
-
},
|
|
85804
|
-
{
|
|
85805
|
-
kind: "clock",
|
|
85806
|
-
path: "lastFetchedAt",
|
|
85807
|
-
when: "always"
|
|
85808
|
-
},
|
|
85809
|
-
{
|
|
85810
|
-
kind: "transition-time",
|
|
85811
|
-
path: "since",
|
|
85812
|
-
sourceChangedAt: "prefer"
|
|
85813
|
-
}
|
|
85814
|
-
],
|
|
85815
|
-
sourceReport: {
|
|
85816
|
-
status: "assignment-status",
|
|
85817
|
-
runtimeField: "source",
|
|
85818
|
-
nativeValue: "native",
|
|
85819
|
-
assignedValue: "assigned"
|
|
85820
|
-
},
|
|
85821
|
-
advancedExpression: true
|
|
85822
|
-
}]
|
|
85823
|
-
};
|
|
85766
|
+
/**
|
|
85767
|
+
* Customize offers "running" only where a job makes sense (D933): a cycle,
|
|
85768
|
+
* a clean, a mow, playback, or another appliance that is on and working.
|
|
85769
|
+
* The cap itself stays on every type — a camera can still report running
|
|
85770
|
+
* natively; it just has no card.
|
|
85771
|
+
*/
|
|
85772
|
+
var RUNNING_CUSTOMIZE_DEVICE_TYPES = [
|
|
85773
|
+
DeviceType.Washer,
|
|
85774
|
+
DeviceType.Dryer,
|
|
85775
|
+
DeviceType.Dishwasher,
|
|
85776
|
+
DeviceType.Vacuum,
|
|
85777
|
+
DeviceType.LawnMower,
|
|
85778
|
+
DeviceType.MediaPlayer,
|
|
85779
|
+
DeviceType.WaterHeater,
|
|
85780
|
+
DeviceType.Humidifier,
|
|
85781
|
+
DeviceType.Fan,
|
|
85782
|
+
DeviceType.Climate,
|
|
85783
|
+
DeviceType.Thermostat,
|
|
85784
|
+
DeviceType.PetFeeder,
|
|
85785
|
+
DeviceType.Heater
|
|
85786
|
+
];
|
|
85824
85787
|
var runningStateCapability = {
|
|
85825
85788
|
name: "running-state",
|
|
85826
85789
|
scope: "device",
|
|
@@ -85840,7 +85803,78 @@ var runningStateCapability = {
|
|
|
85840
85803
|
durability: "restored",
|
|
85841
85804
|
history: { fields: { running: { kind: "boolean" } } },
|
|
85842
85805
|
volatileStateFields: ["lastFetchedAt"],
|
|
85843
|
-
customize:
|
|
85806
|
+
customize: {
|
|
85807
|
+
version: 1,
|
|
85808
|
+
overridable: [{
|
|
85809
|
+
path: "running",
|
|
85810
|
+
by: "running"
|
|
85811
|
+
}],
|
|
85812
|
+
targets: [{
|
|
85813
|
+
id: "running",
|
|
85814
|
+
cardinality: "scalar",
|
|
85815
|
+
vocabulary: {
|
|
85816
|
+
cap: "running-state",
|
|
85817
|
+
stateField: "running"
|
|
85818
|
+
},
|
|
85819
|
+
deviceTypes: RUNNING_CUSTOMIZE_DEVICE_TYPES,
|
|
85820
|
+
apply: "add",
|
|
85821
|
+
path: "running",
|
|
85822
|
+
sources: [
|
|
85823
|
+
{
|
|
85824
|
+
kind: "switch",
|
|
85825
|
+
transforms: [{ kind: "identity" }]
|
|
85826
|
+
},
|
|
85827
|
+
{
|
|
85828
|
+
kind: "binary",
|
|
85829
|
+
transforms: [{ kind: "identity" }, { kind: "invert" }]
|
|
85830
|
+
},
|
|
85831
|
+
{
|
|
85832
|
+
kind: "numeric",
|
|
85833
|
+
requiredUnit: "W",
|
|
85834
|
+
transforms: [{
|
|
85835
|
+
kind: "threshold",
|
|
85836
|
+
comparisons: ["gte", "lte"],
|
|
85837
|
+
comparison: "gte",
|
|
85838
|
+
defaultThreshold: 5,
|
|
85839
|
+
defaultStartDwellMs: RUNNING_POWER_START_DELAY_MS,
|
|
85840
|
+
defaultStopDwellMs: RUNNING_POWER_STOP_DELAY_MS,
|
|
85841
|
+
thresholdUnit: "W"
|
|
85842
|
+
}]
|
|
85843
|
+
}
|
|
85844
|
+
],
|
|
85845
|
+
companions: [
|
|
85846
|
+
{
|
|
85847
|
+
kind: "constant",
|
|
85848
|
+
path: "source",
|
|
85849
|
+
value: "assigned",
|
|
85850
|
+
when: "always"
|
|
85851
|
+
},
|
|
85852
|
+
{
|
|
85853
|
+
kind: "constant",
|
|
85854
|
+
path: "phase",
|
|
85855
|
+
value: null,
|
|
85856
|
+
when: "add"
|
|
85857
|
+
},
|
|
85858
|
+
{
|
|
85859
|
+
kind: "clock",
|
|
85860
|
+
path: "lastFetchedAt",
|
|
85861
|
+
when: "always"
|
|
85862
|
+
},
|
|
85863
|
+
{
|
|
85864
|
+
kind: "transition-time",
|
|
85865
|
+
path: "since",
|
|
85866
|
+
sourceChangedAt: "prefer"
|
|
85867
|
+
}
|
|
85868
|
+
],
|
|
85869
|
+
sourceReport: {
|
|
85870
|
+
status: "assignment-status",
|
|
85871
|
+
runtimeField: "source",
|
|
85872
|
+
nativeValue: "native",
|
|
85873
|
+
assignedValue: "assigned"
|
|
85874
|
+
},
|
|
85875
|
+
advancedExpression: true
|
|
85876
|
+
}]
|
|
85877
|
+
}
|
|
85844
85878
|
};
|
|
85845
85879
|
/**
|
|
85846
85880
|
* scene-monitor — device-scoped reference-region state cap. An operator marks
|
|
@@ -89511,12 +89545,14 @@ var TIMED_RUN_LIMITS = {
|
|
|
89511
89545
|
[DeviceType.Heater]: {
|
|
89512
89546
|
actuator: "switch",
|
|
89513
89547
|
maxSeconds: 10800,
|
|
89514
|
-
unit: "min"
|
|
89548
|
+
unit: "min",
|
|
89549
|
+
quickRunDefault: 30
|
|
89515
89550
|
},
|
|
89516
89551
|
[DeviceType.PetFountain]: {
|
|
89517
89552
|
actuator: "pet-fountain",
|
|
89518
89553
|
maxSeconds: 300,
|
|
89519
|
-
unit: "s"
|
|
89554
|
+
unit: "s",
|
|
89555
|
+
quickRunDefault: 60
|
|
89520
89556
|
}
|
|
89521
89557
|
};
|
|
89522
89558
|
var TIMED_RUN_DEVICE_TYPES = [DeviceType.Heater, DeviceType.PetFountain];
|
|
@@ -89527,6 +89563,27 @@ function timedRunLimitOf(deviceType) {
|
|
|
89527
89563
|
function timedRunSeconds(duration, unit) {
|
|
89528
89564
|
return unit === "min" ? duration * 60 : duration;
|
|
89529
89565
|
}
|
|
89566
|
+
/** The longest run of a limit, in the unit the operator thinks of it in. */
|
|
89567
|
+
function timedRunMaxIn(limit) {
|
|
89568
|
+
return limit.unit === "min" ? Math.floor(limit.maxSeconds / 60) : limit.maxSeconds;
|
|
89569
|
+
}
|
|
89570
|
+
/** One duration, as the one-tap run asks for it. */
|
|
89571
|
+
var TimedRunQuickRunSchema = zod.z.object({
|
|
89572
|
+
duration: zod.z.number().positive().finite(),
|
|
89573
|
+
unit: TimedRunUnitSchema
|
|
89574
|
+
});
|
|
89575
|
+
/**
|
|
89576
|
+
* The one-tap run of a device: the duration the operator stored for it, else the
|
|
89577
|
+
* type's default, never above the type's maximum. A stored value that is not a
|
|
89578
|
+
* usable number is the default (a hand-edited row never breaks the button).
|
|
89579
|
+
*/
|
|
89580
|
+
function timedRunQuickRun(limit, stored) {
|
|
89581
|
+
const max = timedRunMaxIn(limit);
|
|
89582
|
+
return {
|
|
89583
|
+
duration: Math.min((stored !== null && Number.isFinite(stored) && stored > 0 ? stored : null) ?? limit.quickRunDefault, max),
|
|
89584
|
+
unit: limit.unit
|
|
89585
|
+
};
|
|
89586
|
+
}
|
|
89530
89587
|
/** Why a request was not carried out. Typed, so a caller can say it in words. */
|
|
89531
89588
|
var TimedRunRefusalSchema = zod.z.enum([
|
|
89532
89589
|
"unsupported-device",
|
|
@@ -89547,8 +89604,23 @@ var TimedRunStatusSchema = zod.z.object({
|
|
|
89547
89604
|
activeUntil: zod.z.number().nullable(),
|
|
89548
89605
|
/** Who asked for the run (a user id or an addon id); `null` when nothing is armed or it did not say. */
|
|
89549
89606
|
requestedBy: zod.z.string().nullable(),
|
|
89607
|
+
/**
|
|
89608
|
+
* The one-tap run of THIS device: what a "Run" button on any surface starts. `null` when
|
|
89609
|
+
* the device is gone or its type has no timed run; a status from before this field
|
|
89610
|
+
* existed has none, and a surface falls back to the type's default.
|
|
89611
|
+
*/
|
|
89612
|
+
quickRun: TimedRunQuickRunSchema.nullable(),
|
|
89550
89613
|
lastFetchedAt: zod.z.number()
|
|
89551
89614
|
});
|
|
89615
|
+
/** What the settings form needs: the unit, the bounds and the type's default. */
|
|
89616
|
+
var TimedRunOptionsSchema = zod.z.object({
|
|
89617
|
+
unit: TimedRunUnitSchema,
|
|
89618
|
+
/** The longest run, in `unit`. */
|
|
89619
|
+
maxDuration: zod.z.number(),
|
|
89620
|
+
defaultDuration: zod.z.number()
|
|
89621
|
+
});
|
|
89622
|
+
/** The one-tap run duration, in the type's unit; `null` returns to the type's default. */
|
|
89623
|
+
var TimedRunSettingsPatchSchema = zod.z.object({ quickRunDuration: zod.z.number().positive().finite().nullable().optional() });
|
|
89552
89624
|
var timedRunCapability = {
|
|
89553
89625
|
name: "timed-run",
|
|
89554
89626
|
scope: "device",
|
|
@@ -89556,7 +89628,24 @@ var timedRunCapability = {
|
|
|
89556
89628
|
kind: "wrapper",
|
|
89557
89629
|
defaultActive: true,
|
|
89558
89630
|
deviceTypes: TIMED_RUN_DEVICE_TYPES,
|
|
89631
|
+
deviceConfig: { ui: {
|
|
89632
|
+
kind: "derived-form",
|
|
89633
|
+
builderId: "timed-run",
|
|
89634
|
+
tab: "general"
|
|
89635
|
+
} },
|
|
89559
89636
|
methods: {
|
|
89637
|
+
getOptions: method(zod.z.object({ deviceId: zod.z.number().int() }), TimedRunOptionsSchema),
|
|
89638
|
+
/**
|
|
89639
|
+
* The one-tap run of this device. A duration above the type's maximum is
|
|
89640
|
+
* REFUSED (thrown), like `runFor`: the maximum is a safety bound.
|
|
89641
|
+
*/
|
|
89642
|
+
setSettings: method(zod.z.object({
|
|
89643
|
+
deviceId: zod.z.number().int(),
|
|
89644
|
+
settings: TimedRunSettingsPatchSchema
|
|
89645
|
+
}), zod.z.void(), {
|
|
89646
|
+
kind: "mutation",
|
|
89647
|
+
auth: "admin"
|
|
89648
|
+
}),
|
|
89560
89649
|
/**
|
|
89561
89650
|
* Turn the device on and arm its off. A run already armed is replaced (the
|
|
89562
89651
|
* new deadline wins). Refuses with a typed reason above the type's maximum.
|
|
@@ -94133,255 +94222,6 @@ function evaluateAggregate(input) {
|
|
|
94133
94222
|
counts
|
|
94134
94223
|
};
|
|
94135
94224
|
}
|
|
94136
|
-
/**
|
|
94137
|
-
* One composed field, evaluated from what its sources say NOW (D659).
|
|
94138
|
-
*
|
|
94139
|
-
* Pure. The composer calls it on every source change, and the slice-5 editor
|
|
94140
|
-
* will call it for its live preview, so both see the same answer.
|
|
94141
|
-
*
|
|
94142
|
-
* The rules (spec §2):
|
|
94143
|
-
* - a source that is offline or unreadable keeps its last value and is marked
|
|
94144
|
-
* STALE; the field is stale and keeps computing (D49);
|
|
94145
|
-
* - a source that is GONE makes the field UNAVAILABLE, `fatal`, and never a
|
|
94146
|
-
* plausible number (D393);
|
|
94147
|
-
* - a source that is unavailable but NOT gone (e.g. a cap unregistered at
|
|
94148
|
-
* runtime, R7b) makes the field UNAVAILABLE, non-fatal, `value: null`: it
|
|
94149
|
-
* may come back on its own, no block failure is raised for it;
|
|
94150
|
-
* - an expression that fails on a value makes the field unavailable for that
|
|
94151
|
-
* value, and NOT fatal: the next value may compute.
|
|
94152
|
-
*
|
|
94153
|
-
* `confirmed` (D663, D49): whether a NON-fatal unavailability is an ANSWER — a
|
|
94154
|
-
* cap the provider unregistered and a re-read agreed, a field the source
|
|
94155
|
-
* reported without, an expression that failed on a value — or only the
|
|
94156
|
-
* absence of one (a failed read, a first or empty read, a source not tracked
|
|
94157
|
-
* yet). Only a confirmed unavailability may hand a `release`-mode field back
|
|
94158
|
-
* to the native provider; an unconfirmed one holds it on its last value.
|
|
94159
|
-
* Absent means NOT confirmed. Fatal is always confirmed.
|
|
94160
|
-
*
|
|
94161
|
-
* When an expression has more than one unavailable binding, a FATAL one always
|
|
94162
|
-
* wins the outcome, regardless of position: every binding is scanned before
|
|
94163
|
-
* the field is judged, so an earlier non-fatal binding (e.g. a cap that is
|
|
94164
|
-
* momentarily unregistered) can never hide a later fatal one (a deleted
|
|
94165
|
-
* source) behind an early return.
|
|
94166
|
-
*/
|
|
94167
|
-
function describeRead(read) {
|
|
94168
|
-
return `${compositionSourceKey(read.source)} ${read.cap}.${read.fieldPath}`;
|
|
94169
|
-
}
|
|
94170
|
-
function isConfirmed(reading) {
|
|
94171
|
-
return reading.fatal || reading.confirmed === true;
|
|
94172
|
-
}
|
|
94173
|
-
function fromReading(reading, read) {
|
|
94174
|
-
if (reading.state === "unavailable") return {
|
|
94175
|
-
state: "unavailable",
|
|
94176
|
-
value: null,
|
|
94177
|
-
reason: `${describeRead(read)}: ${reading.reason}`,
|
|
94178
|
-
fatal: reading.fatal,
|
|
94179
|
-
confirmed: isConfirmed(reading)
|
|
94180
|
-
};
|
|
94181
|
-
return {
|
|
94182
|
-
state: reading.state,
|
|
94183
|
-
value: reading.value,
|
|
94184
|
-
reason: reading.state === "stale" ? `${describeRead(read)}: ${reading.reason}` : null,
|
|
94185
|
-
deadline: null
|
|
94186
|
-
};
|
|
94187
|
-
}
|
|
94188
|
-
function expressionOutcome(source, read, now, stateful) {
|
|
94189
|
-
const values = {};
|
|
94190
|
-
const staleReasons = [];
|
|
94191
|
-
let fatalUnavailable = null;
|
|
94192
|
-
let nonFatalUnavailable = null;
|
|
94193
|
-
for (const [name, binding] of Object.entries(source.bindings)) {
|
|
94194
|
-
if (binding.kind === "literal") {
|
|
94195
|
-
values[name] = binding.value;
|
|
94196
|
-
continue;
|
|
94197
|
-
}
|
|
94198
|
-
const reading = read(binding);
|
|
94199
|
-
if (reading.state === "unavailable") {
|
|
94200
|
-
const outcome = {
|
|
94201
|
-
state: "unavailable",
|
|
94202
|
-
value: null,
|
|
94203
|
-
reason: `binding \`${name}\` (${describeRead(binding)}): ${reading.reason}`,
|
|
94204
|
-
fatal: reading.fatal,
|
|
94205
|
-
confirmed: isConfirmed(reading)
|
|
94206
|
-
};
|
|
94207
|
-
if (reading.fatal) {
|
|
94208
|
-
fatalUnavailable = outcome;
|
|
94209
|
-
break;
|
|
94210
|
-
}
|
|
94211
|
-
if (nonFatalUnavailable === null || outcome.confirmed && !nonFatalUnavailable.confirmed) nonFatalUnavailable = outcome;
|
|
94212
|
-
continue;
|
|
94213
|
-
}
|
|
94214
|
-
values[name] = reading.value;
|
|
94215
|
-
if (reading.state === "fresh" && reading.transition !== void 0 && stateful !== void 0) stateful.expressionMemory.dwellTransition = reading.transition;
|
|
94216
|
-
if (reading.state === "stale") staleReasons.push(`\`${name}\`: ${reading.reason}`);
|
|
94217
|
-
}
|
|
94218
|
-
const unavailable = fatalUnavailable ?? nonFatalUnavailable;
|
|
94219
|
-
if (unavailable !== null) {
|
|
94220
|
-
if (stateful !== void 0 && stateful.currentOutput !== void 0 && expressionContainsBuiltinCall(source.expr, "count")) return {
|
|
94221
|
-
state: "stale",
|
|
94222
|
-
value: evaluateCount(null, {
|
|
94223
|
-
kind: "count",
|
|
94224
|
-
highWater: null,
|
|
94225
|
-
primed: false
|
|
94226
|
-
}, stateful.currentOutput),
|
|
94227
|
-
reason: `${unavailable.reason}; holding the last accumulator value`,
|
|
94228
|
-
deadline: null
|
|
94229
|
-
};
|
|
94230
|
-
return unavailable;
|
|
94231
|
-
}
|
|
94232
|
-
const deadlines = [];
|
|
94233
|
-
const hooks = {
|
|
94234
|
-
noteDeadline: (at) => deadlines.push(at),
|
|
94235
|
-
...stateful?.timerDriven === true ? { timerDriven: true } : {},
|
|
94236
|
-
convert: (value, from, to) => tryConvertUnit(value, normalizeUnit(from) ?? from, normalizeUnit(to) ?? to) ?? null
|
|
94237
|
-
};
|
|
94238
|
-
const result = evaluateExpressionSource(source.expr, values, now, {
|
|
94239
|
-
hooks,
|
|
94240
|
-
...stateful === void 0 ? {} : { invokeStateful: (invocation) => evaluateStatefulExpressionCall(stateful.callPathPrefix === void 0 ? invocation : {
|
|
94241
|
-
...invocation,
|
|
94242
|
-
path: `${stateful.callPathPrefix}@${invocation.path}`
|
|
94243
|
-
}, stateful.expressionMemory, {
|
|
94244
|
-
currentOutput: stateful.currentOutput,
|
|
94245
|
-
startedAtMs: stateful.startedAtMs,
|
|
94246
|
-
nowMs: now
|
|
94247
|
-
}, hooks) }
|
|
94248
|
-
});
|
|
94249
|
-
const transition = stateful?.expressionMemory.dwellTransition ?? null;
|
|
94250
|
-
if (stateful !== void 0) stateful.expressionMemory.dwellTransition = null;
|
|
94251
|
-
if (!result.ok) return {
|
|
94252
|
-
state: "unavailable",
|
|
94253
|
-
value: null,
|
|
94254
|
-
reason: `the expression failed: ${result.error}`,
|
|
94255
|
-
fatal: false,
|
|
94256
|
-
confirmed: true,
|
|
94257
|
-
expressionFailed: true
|
|
94258
|
-
};
|
|
94259
|
-
return {
|
|
94260
|
-
state: staleReasons.length > 0 ? "stale" : "fresh",
|
|
94261
|
-
value: result.value,
|
|
94262
|
-
reason: staleReasons.length > 0 ? staleReasons.join("; ") : null,
|
|
94263
|
-
deadline: deadlines.length > 0 ? Math.min(...deadlines) : null,
|
|
94264
|
-
...transition === null ? {} : { transition }
|
|
94265
|
-
};
|
|
94266
|
-
}
|
|
94267
|
-
function aggregateRead(reading) {
|
|
94268
|
-
if (reading.state === "unavailable") return {
|
|
94269
|
-
state: "unavailable",
|
|
94270
|
-
fatal: reading.fatal,
|
|
94271
|
-
reason: reading.reason
|
|
94272
|
-
};
|
|
94273
|
-
return {
|
|
94274
|
-
state: reading.state,
|
|
94275
|
-
value: reading.value,
|
|
94276
|
-
...reading.state === "stale" ? { reason: reading.reason } : {}
|
|
94277
|
-
};
|
|
94278
|
-
}
|
|
94279
|
-
function aggregateField(source, read) {
|
|
94280
|
-
const outcome = evaluateAggregate({
|
|
94281
|
-
reducer: source.reducer,
|
|
94282
|
-
...source.activeWhen === void 0 ? {} : { activeWhen: source.activeWhen },
|
|
94283
|
-
members: source.reads.map((item) => aggregateRead(read(item))),
|
|
94284
|
-
publish: source.publish,
|
|
94285
|
-
empty: source.empty
|
|
94286
|
-
});
|
|
94287
|
-
if (outcome.kind === "value") return {
|
|
94288
|
-
state: "fresh",
|
|
94289
|
-
value: outcome.value,
|
|
94290
|
-
reason: null,
|
|
94291
|
-
deadline: null
|
|
94292
|
-
};
|
|
94293
|
-
return {
|
|
94294
|
-
state: "unavailable",
|
|
94295
|
-
value: null,
|
|
94296
|
-
reason: outcome.reason,
|
|
94297
|
-
fatal: outcome.fatal,
|
|
94298
|
-
confirmed: true
|
|
94299
|
-
};
|
|
94300
|
-
}
|
|
94301
|
-
function evaluateCompositionField(input) {
|
|
94302
|
-
const { source } = input;
|
|
94303
|
-
switch (source.kind) {
|
|
94304
|
-
case "from": return fromReading(input.read(source), source);
|
|
94305
|
-
case "expression": return expressionOutcome(source, input.read, input.now, input.stateful);
|
|
94306
|
-
case "aggregate": return aggregateField(source, input.read);
|
|
94307
|
-
case "series": return {
|
|
94308
|
-
state: "unavailable",
|
|
94309
|
-
value: null,
|
|
94310
|
-
reason: "a series field is written from device history",
|
|
94311
|
-
fatal: false,
|
|
94312
|
-
confirmed: false
|
|
94313
|
-
};
|
|
94314
|
-
case "code": return {
|
|
94315
|
-
state: "unavailable",
|
|
94316
|
-
value: null,
|
|
94317
|
-
reason: "code fields are not runnable in the composer — they arrive in slice 4",
|
|
94318
|
-
fatal: true,
|
|
94319
|
-
confirmed: true
|
|
94320
|
-
};
|
|
94321
|
-
}
|
|
94322
|
-
}
|
|
94323
|
-
function lockDoorLinkOfComposition(composition) {
|
|
94324
|
-
if (composition === null || composition.target.kind !== "existing") return null;
|
|
94325
|
-
const feature = composition.features.find((f) => f.cap === "lock-control");
|
|
94326
|
-
if (feature === void 0 || feature.kind !== "fields") return null;
|
|
94327
|
-
const state = feature.fields["state"];
|
|
94328
|
-
if (state === void 0 || state.kind !== "expression") return null;
|
|
94329
|
-
const x = state.bindings["x"];
|
|
94330
|
-
if (x === void 0 || x.kind !== "from") return null;
|
|
94331
|
-
return {
|
|
94332
|
-
lock: composition.target.device,
|
|
94333
|
-
sensor: x.source
|
|
94334
|
-
};
|
|
94335
|
-
}
|
|
94336
|
-
/**
|
|
94337
|
-
* Which smart switch powers a device (the `power-source` Customize extension):
|
|
94338
|
-
* the source its stored `power-source.switchOn` field reads, and the off time of
|
|
94339
|
-
* a forced restart stored beside it. Read from the STORED composition, never kept
|
|
94340
|
-
* as a second copy (D676). Shared by the hub (which acts on the switch) and the
|
|
94341
|
-
* admin UI (which shows it).
|
|
94342
|
-
*/
|
|
94343
|
-
/**
|
|
94344
|
-
* The stored off time, or the default when none is stored. A stored number out
|
|
94345
|
-
* of range is CLAMPED to the bounds (a hand-written value never refuses the
|
|
94346
|
-
* link, it just cannot cut power for an absurd time); a non-integer is rounded.
|
|
94347
|
-
*/
|
|
94348
|
-
function normalizeOffSeconds(value) {
|
|
94349
|
-
if (typeof value !== "number" || !Number.isFinite(value)) return 10;
|
|
94350
|
-
return Math.min(120, Math.max(3, Math.round(value)));
|
|
94351
|
-
}
|
|
94352
|
-
/** The constant a stored `offSeconds` field carries, or undefined when it is not a literal number. */
|
|
94353
|
-
function storedOffSeconds(composition) {
|
|
94354
|
-
const feature = composition.features.find((f) => f.cap === "power-source");
|
|
94355
|
-
if (feature === void 0 || feature.kind !== "fields") return void 0;
|
|
94356
|
-
const field = feature.fields["offSeconds"];
|
|
94357
|
-
if (field === void 0 || field.kind !== "expression") return void 0;
|
|
94358
|
-
const n = Number(field.expr);
|
|
94359
|
-
return field.expr.trim() === "" || !Number.isFinite(n) ? void 0 : n;
|
|
94360
|
-
}
|
|
94361
|
-
/**
|
|
94362
|
-
* The link a composition stores. An `existing` target names its own device; a
|
|
94363
|
-
* `new` target (a composed device) is the composer's own device, so the caller
|
|
94364
|
-
* passes the block id and a new-target composition without one has no link.
|
|
94365
|
-
*/
|
|
94366
|
-
function powerSourceLinkOfComposition(composition, blockId) {
|
|
94367
|
-
if (composition === null) return null;
|
|
94368
|
-
let device;
|
|
94369
|
-
if (composition.target.kind === "existing") device = composition.target.device;
|
|
94370
|
-
else if (blockId !== void 0) device = composedDeviceRef(blockId);
|
|
94371
|
-
else return null;
|
|
94372
|
-
const feature = composition.features.find((f) => f.cap === "power-source");
|
|
94373
|
-
if (feature === void 0 || feature.kind !== "fields" || feature.enabled === false) return null;
|
|
94374
|
-
const field = feature.fields["switchOn"];
|
|
94375
|
-
if (field === void 0) return null;
|
|
94376
|
-
const read = fieldReads(field).find((r) => r.cap === "switch");
|
|
94377
|
-
if (read === void 0) return null;
|
|
94378
|
-
return {
|
|
94379
|
-
device,
|
|
94380
|
-
switch: read.source,
|
|
94381
|
-
offSeconds: normalizeOffSeconds(storedOffSeconds(composition))
|
|
94382
|
-
};
|
|
94383
|
-
}
|
|
94384
|
-
SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
|
|
94385
94225
|
function fromRead(source, cap, fieldPath) {
|
|
94386
94226
|
return {
|
|
94387
94227
|
kind: "from",
|
|
@@ -94400,17 +94240,16 @@ function expression(expr, bindings) {
|
|
|
94400
94240
|
function literal(expr) {
|
|
94401
94241
|
return expression(expr, {});
|
|
94402
94242
|
}
|
|
94403
|
-
|
|
94404
|
-
var catalog$4 = CAP_CUSTOMIZE_CATALOG;
|
|
94243
|
+
var catalog$5 = CAP_CUSTOMIZE_CATALOG;
|
|
94405
94244
|
function compileScalarOverride(input) {
|
|
94406
|
-
const target = catalogTarget$
|
|
94407
|
-
if (target === null || target.cardinality !== "scalar" || target.path === void 0) return fail$
|
|
94408
|
-
if (input.draft.transform.kind === "enum-map") return fail$
|
|
94245
|
+
const target = catalogTarget$4(input.draft.cap, input.draft.targetId);
|
|
94246
|
+
if (target === null || target.cardinality !== "scalar" || target.path === void 0) return fail$2("target");
|
|
94247
|
+
if (input.draft.transform.kind === "enum-map") return fail$2("enum");
|
|
94409
94248
|
const source = sourceSpec$1(target, input.sourceValueKind, input.draft.source.cap);
|
|
94410
|
-
if (source === null) return fail$
|
|
94411
|
-
if (source.requiredUnit !== void 0 && input.sourceUnit !== source.requiredUnit) return fail$
|
|
94249
|
+
if (source === null) return fail$2("source-kind");
|
|
94250
|
+
if (source.requiredUnit !== void 0 && input.sourceUnit !== source.requiredUnit) return fail$2("unit");
|
|
94412
94251
|
const allowed = input.draft.transform.kind === "number" ? "identity" : input.draft.transform.kind;
|
|
94413
|
-
if (!source.transformKinds.includes(allowed)) return fail$
|
|
94252
|
+
if (!source.transformKinds.includes(allowed)) return fail$2("transform");
|
|
94414
94253
|
if (target.override !== void 0) return compileOverride(input, target.path, target.override);
|
|
94415
94254
|
const value = compileValue$1(input);
|
|
94416
94255
|
if (!value.ok) return value;
|
|
@@ -94431,7 +94270,7 @@ function compileScalarOverride(input) {
|
|
|
94431
94270
|
* companion — the native slice keeps its own clock.
|
|
94432
94271
|
*/
|
|
94433
94272
|
function compileOverride(input, path, rule) {
|
|
94434
|
-
if (input.sourceValueKind !== "boolean" || input.draft.transform.kind !== "identity") return fail$
|
|
94273
|
+
if (input.sourceValueKind !== "boolean" || input.draft.transform.kind !== "identity") return fail$2("source-kind");
|
|
94435
94274
|
const read = fromRead(refOf$1(input.draft), input.draft.source.cap, input.draft.source.fieldPath);
|
|
94436
94275
|
const field = expression(overrideExpr(rule.whenSourceTrue, rule.unlessNative), {
|
|
94437
94276
|
x: read,
|
|
@@ -94446,14 +94285,14 @@ function compileOverride(input, path, rule) {
|
|
|
94446
94285
|
}
|
|
94447
94286
|
};
|
|
94448
94287
|
}
|
|
94449
|
-
function fail$
|
|
94288
|
+
function fail$2(reason) {
|
|
94450
94289
|
return {
|
|
94451
94290
|
ok: false,
|
|
94452
94291
|
reason
|
|
94453
94292
|
};
|
|
94454
94293
|
}
|
|
94455
|
-
function catalogTarget$
|
|
94456
|
-
const entry = catalog$
|
|
94294
|
+
function catalogTarget$4(cap, targetId) {
|
|
94295
|
+
const entry = catalog$5[cap];
|
|
94457
94296
|
if (entry === void 0) return null;
|
|
94458
94297
|
return entry.targets.find((target) => target.id === targetId) ?? null;
|
|
94459
94298
|
}
|
|
@@ -94474,7 +94313,7 @@ function compileValue$1(input) {
|
|
|
94474
94313
|
value: identityValue(read, input.sourceValueKind)
|
|
94475
94314
|
};
|
|
94476
94315
|
if (transform.kind === "invert") {
|
|
94477
|
-
if (input.sourceValueKind !== "boolean") return fail$
|
|
94316
|
+
if (input.sourceValueKind !== "boolean") return fail$2("source-kind");
|
|
94478
94317
|
return {
|
|
94479
94318
|
ok: true,
|
|
94480
94319
|
value: expression("!x", { x: read })
|
|
@@ -94482,7 +94321,7 @@ function compileValue$1(input) {
|
|
|
94482
94321
|
}
|
|
94483
94322
|
if (transform.kind === "threshold") return thresholdValue(transform, read, transform.minSamples ?? evidenceSamples(input));
|
|
94484
94323
|
if (transform.kind === "linear") return linearValue$1(transform, read, input.sourceValueKind);
|
|
94485
|
-
return fail$
|
|
94324
|
+
return fail$2("transform");
|
|
94486
94325
|
}
|
|
94487
94326
|
function identityValue(read, valueKind) {
|
|
94488
94327
|
if (valueKind === "string") return expression("number(x)", { x: read });
|
|
@@ -94504,10 +94343,10 @@ function defaultThresholdSamples(cap, targetId, sourceCap) {
|
|
|
94504
94343
|
}
|
|
94505
94344
|
function thresholdValue(transform, read, minSamples) {
|
|
94506
94345
|
const threshold = unsignedToken(transform.threshold);
|
|
94507
|
-
if (threshold === null) return fail$
|
|
94346
|
+
if (threshold === null) return fail$2("threshold");
|
|
94508
94347
|
const start = unsignedToken(transform.startDwellMs);
|
|
94509
94348
|
const stop = unsignedToken(transform.stopDwellMs);
|
|
94510
|
-
if (start === null || stop === null) return fail$
|
|
94349
|
+
if (start === null || stop === null) return fail$2("dwell");
|
|
94511
94350
|
return {
|
|
94512
94351
|
ok: true,
|
|
94513
94352
|
value: expression(dwellExpr(transform.comparison, threshold, start, stop, minSamples), { x: read })
|
|
@@ -94516,7 +94355,7 @@ function thresholdValue(transform, read, minSamples) {
|
|
|
94516
94355
|
function linearValue$1(transform, read, valueKind) {
|
|
94517
94356
|
const scale = signedToken(transform.scale);
|
|
94518
94357
|
const offset = signedToken(transform.offset);
|
|
94519
|
-
if (scale === null || offset === null) return fail$
|
|
94358
|
+
if (scale === null || offset === null) return fail$2("scale");
|
|
94520
94359
|
const clamps = clampTokens$1(transform.clampMin, transform.clampMax);
|
|
94521
94360
|
if (!clamps.ok) return clamps;
|
|
94522
94361
|
return {
|
|
@@ -94532,10 +94371,10 @@ function clampTokens$1(clampMin, clampMax) {
|
|
|
94532
94371
|
max: null
|
|
94533
94372
|
}
|
|
94534
94373
|
};
|
|
94535
|
-
if (clampMin === void 0 || clampMax === void 0) return fail$
|
|
94374
|
+
if (clampMin === void 0 || clampMax === void 0) return fail$2("clamp");
|
|
94536
94375
|
const min = signedToken(clampMin);
|
|
94537
94376
|
const max = signedToken(clampMax);
|
|
94538
|
-
if (min === null || max === null || clampMin > clampMax) return fail$
|
|
94377
|
+
if (min === null || max === null || clampMin > clampMax) return fail$2("clamp");
|
|
94539
94378
|
return {
|
|
94540
94379
|
ok: true,
|
|
94541
94380
|
value: {
|
|
@@ -94545,7 +94384,7 @@ function clampTokens$1(clampMin, clampMax) {
|
|
|
94545
94384
|
};
|
|
94546
94385
|
}
|
|
94547
94386
|
function compileCompanions$1(input, target, value) {
|
|
94548
|
-
if (target.path === void 0) return fail$
|
|
94387
|
+
if (target.path === void 0) return fail$2("target");
|
|
94549
94388
|
const path = target.path;
|
|
94550
94389
|
return (target.companions ?? []).filter((companion) => companionIncluded$1(companion, input.apply)).reduce((acc, companion) => {
|
|
94551
94390
|
if (!acc.ok) return acc;
|
|
@@ -94573,7 +94412,7 @@ function companionIncluded$1(companion, apply) {
|
|
|
94573
94412
|
function companionField(input, path, companion, value) {
|
|
94574
94413
|
if (companion.kind === "constant") {
|
|
94575
94414
|
const expr = constantExpr(companion.value);
|
|
94576
|
-
if (expr === null) return fail$
|
|
94415
|
+
if (expr === null) return fail$2("scale");
|
|
94577
94416
|
return {
|
|
94578
94417
|
ok: true,
|
|
94579
94418
|
value: literal(expr)
|
|
@@ -94591,7 +94430,7 @@ function transitionField(input, path, sourceChangedAt, value) {
|
|
|
94591
94430
|
value: fromRead(refOf$1(input.draft), input.draft.source.cap, input.changedAtField)
|
|
94592
94431
|
};
|
|
94593
94432
|
if (input.apply === "replace") return stampOfValue(value);
|
|
94594
|
-
if (!isIdentifier(path)) return fail$
|
|
94433
|
+
if (!isIdentifier(path)) return fail$2("transform");
|
|
94595
94434
|
const bindings = { [path]: fromRead(input.device, input.draft.cap, path) };
|
|
94596
94435
|
return {
|
|
94597
94436
|
ok: true,
|
|
@@ -94607,7 +94446,7 @@ function stampOfValue(value) {
|
|
|
94607
94446
|
ok: true,
|
|
94608
94447
|
value: expression("latchedAt(x)", { x: value })
|
|
94609
94448
|
};
|
|
94610
|
-
return fail$
|
|
94449
|
+
return fail$2("transform");
|
|
94611
94450
|
}
|
|
94612
94451
|
function refOf$1(draft) {
|
|
94613
94452
|
return {
|
|
@@ -94615,6 +94454,340 @@ function refOf$1(draft) {
|
|
|
94615
94454
|
stableId: draft.source.stableId
|
|
94616
94455
|
};
|
|
94617
94456
|
}
|
|
94457
|
+
/**
|
|
94458
|
+
* Switch on = device on (D933, amended): a device with an ACTUATOR switch - its
|
|
94459
|
+
* own `switch`, the one that turns its function on - runs while that switch is on.
|
|
94460
|
+
* A SUPPLY switch (`power-source.switchOn`, an appliance on a plug) is never a
|
|
94461
|
+
* running source: the appliance keeps its power while it is idle.
|
|
94462
|
+
*
|
|
94463
|
+
* The default is derived from STRUCTURE (an actuator switch is present and no
|
|
94464
|
+
* supply relation is), computed at plan time and never written into the stored
|
|
94465
|
+
* composition: a stored composition is never rewritten silently, and an
|
|
94466
|
+
* authored `running` field always wins. The operator turns the default on and
|
|
94467
|
+
* off in the Customize running row ("Follow the device's switch").
|
|
94468
|
+
*/
|
|
94469
|
+
var RUNNING_CAP = "running-state";
|
|
94470
|
+
var SWITCH_CAP = "switch";
|
|
94471
|
+
var ON_FIELD = "on";
|
|
94472
|
+
var CHANGED_AT_FIELD = "lastChangedAt";
|
|
94473
|
+
function fieldsFeatureOf(composition, cap) {
|
|
94474
|
+
const feature = composition.features.find((f) => f.cap === cap);
|
|
94475
|
+
return feature !== void 0 && feature.kind === "fields" ? feature : null;
|
|
94476
|
+
}
|
|
94477
|
+
/** The device switch the composed `switch.on` reads, when it is one plain `from` of a switch. */
|
|
94478
|
+
function actuatorSwitchRead(composition) {
|
|
94479
|
+
const feature = fieldsFeatureOf(composition, SWITCH_CAP);
|
|
94480
|
+
if (feature === null || !compositionFeatureEnabled(feature)) return null;
|
|
94481
|
+
const field = feature.fields[ON_FIELD];
|
|
94482
|
+
if (field === void 0 || field.kind !== "from" || field.cap !== SWITCH_CAP) return null;
|
|
94483
|
+
return {
|
|
94484
|
+
source: field.source,
|
|
94485
|
+
cap: field.cap,
|
|
94486
|
+
fieldPath: field.fieldPath
|
|
94487
|
+
};
|
|
94488
|
+
}
|
|
94489
|
+
function hasSupplyRelation(composition) {
|
|
94490
|
+
const feature = fieldsFeatureOf(composition, "power-source");
|
|
94491
|
+
return feature !== null && compositionFeatureEnabled(feature) && feature.fields["switchOn"] !== void 0;
|
|
94492
|
+
}
|
|
94493
|
+
/** Anything stored for running - a rule, or the opt-out - is the operator's, and the default stays out of it. */
|
|
94494
|
+
function hasAuthoredRunning(composition) {
|
|
94495
|
+
return fieldsFeatureOf(composition, RUNNING_CAP) !== null;
|
|
94496
|
+
}
|
|
94497
|
+
/** A NEW device of a type that offers "running", with an actuator switch and no supply relation. */
|
|
94498
|
+
function actuatorSwitchDrivesRunning(composition) {
|
|
94499
|
+
const target = composition.target;
|
|
94500
|
+
if (target.kind !== "new") return false;
|
|
94501
|
+
if (!RUNNING_CUSTOMIZE_DEVICE_TYPES.some((type) => type === target.type)) return false;
|
|
94502
|
+
return actuatorSwitchRead(composition) !== null && !hasSupplyRelation(composition);
|
|
94503
|
+
}
|
|
94504
|
+
/** The `running-state` feature that reads the actuator switch: the one the scalar compiler stores. */
|
|
94505
|
+
function followSwitchRunningFeature(composition, host) {
|
|
94506
|
+
const read = actuatorSwitchRead(composition);
|
|
94507
|
+
if (read === null) return null;
|
|
94508
|
+
const compiled = compileScalarOverride({
|
|
94509
|
+
draft: {
|
|
94510
|
+
kind: "scalar",
|
|
94511
|
+
cap: RUNNING_CAP,
|
|
94512
|
+
targetId: "running",
|
|
94513
|
+
source: {
|
|
94514
|
+
...read.source,
|
|
94515
|
+
cap: read.cap,
|
|
94516
|
+
fieldPath: read.fieldPath
|
|
94517
|
+
},
|
|
94518
|
+
transform: { kind: "identity" }
|
|
94519
|
+
},
|
|
94520
|
+
device: host,
|
|
94521
|
+
apply: "add",
|
|
94522
|
+
sourceValueKind: "boolean",
|
|
94523
|
+
changedAtField: CHANGED_AT_FIELD,
|
|
94524
|
+
sourceUnit: null
|
|
94525
|
+
});
|
|
94526
|
+
return compiled.ok ? compiled.value : null;
|
|
94527
|
+
}
|
|
94528
|
+
/**
|
|
94529
|
+
* The composition the composer PLANS: the stored one, plus the derived running
|
|
94530
|
+
* field when nothing is authored for it. The input is never changed; with nothing
|
|
94531
|
+
* to add it is returned as it is.
|
|
94532
|
+
*/
|
|
94533
|
+
function withDefaultRunning(composition, blockId) {
|
|
94534
|
+
if (hasAuthoredRunning(composition) || !actuatorSwitchDrivesRunning(composition)) return composition;
|
|
94535
|
+
const feature = followSwitchRunningFeature(composition, composedDeviceRef(blockId));
|
|
94536
|
+
return feature === null ? composition : {
|
|
94537
|
+
...composition,
|
|
94538
|
+
features: [...composition.features, feature]
|
|
94539
|
+
};
|
|
94540
|
+
}
|
|
94541
|
+
/**
|
|
94542
|
+
* One composed field, evaluated from what its sources say NOW (D659).
|
|
94543
|
+
*
|
|
94544
|
+
* Pure. The composer calls it on every source change, and the slice-5 editor
|
|
94545
|
+
* will call it for its live preview, so both see the same answer.
|
|
94546
|
+
*
|
|
94547
|
+
* The rules (spec §2):
|
|
94548
|
+
* - a source that is offline or unreadable keeps its last value and is marked
|
|
94549
|
+
* STALE; the field is stale and keeps computing (D49);
|
|
94550
|
+
* - a source that is GONE makes the field UNAVAILABLE, `fatal`, and never a
|
|
94551
|
+
* plausible number (D393);
|
|
94552
|
+
* - a source that is unavailable but NOT gone (e.g. a cap unregistered at
|
|
94553
|
+
* runtime, R7b) makes the field UNAVAILABLE, non-fatal, `value: null`: it
|
|
94554
|
+
* may come back on its own, no block failure is raised for it;
|
|
94555
|
+
* - an expression that fails on a value makes the field unavailable for that
|
|
94556
|
+
* value, and NOT fatal: the next value may compute.
|
|
94557
|
+
*
|
|
94558
|
+
* `confirmed` (D663, D49): whether a NON-fatal unavailability is an ANSWER — a
|
|
94559
|
+
* cap the provider unregistered and a re-read agreed, a field the source
|
|
94560
|
+
* reported without, an expression that failed on a value — or only the
|
|
94561
|
+
* absence of one (a failed read, a first or empty read, a source not tracked
|
|
94562
|
+
* yet). Only a confirmed unavailability may hand a `release`-mode field back
|
|
94563
|
+
* to the native provider; an unconfirmed one holds it on its last value.
|
|
94564
|
+
* Absent means NOT confirmed. Fatal is always confirmed.
|
|
94565
|
+
*
|
|
94566
|
+
* When an expression has more than one unavailable binding, a FATAL one always
|
|
94567
|
+
* wins the outcome, regardless of position: every binding is scanned before
|
|
94568
|
+
* the field is judged, so an earlier non-fatal binding (e.g. a cap that is
|
|
94569
|
+
* momentarily unregistered) can never hide a later fatal one (a deleted
|
|
94570
|
+
* source) behind an early return.
|
|
94571
|
+
*/
|
|
94572
|
+
function describeRead(read) {
|
|
94573
|
+
return `${compositionSourceKey(read.source)} ${read.cap}.${read.fieldPath}`;
|
|
94574
|
+
}
|
|
94575
|
+
function isConfirmed(reading) {
|
|
94576
|
+
return reading.fatal || reading.confirmed === true;
|
|
94577
|
+
}
|
|
94578
|
+
function fromReading(reading, read) {
|
|
94579
|
+
if (reading.state === "unavailable") return {
|
|
94580
|
+
state: "unavailable",
|
|
94581
|
+
value: null,
|
|
94582
|
+
reason: `${describeRead(read)}: ${reading.reason}`,
|
|
94583
|
+
fatal: reading.fatal,
|
|
94584
|
+
confirmed: isConfirmed(reading)
|
|
94585
|
+
};
|
|
94586
|
+
return {
|
|
94587
|
+
state: reading.state,
|
|
94588
|
+
value: reading.value,
|
|
94589
|
+
reason: reading.state === "stale" ? `${describeRead(read)}: ${reading.reason}` : null,
|
|
94590
|
+
deadline: null
|
|
94591
|
+
};
|
|
94592
|
+
}
|
|
94593
|
+
function expressionOutcome(source, read, now, stateful) {
|
|
94594
|
+
const values = {};
|
|
94595
|
+
const staleReasons = [];
|
|
94596
|
+
let fatalUnavailable = null;
|
|
94597
|
+
let nonFatalUnavailable = null;
|
|
94598
|
+
for (const [name, binding] of Object.entries(source.bindings)) {
|
|
94599
|
+
if (binding.kind === "literal") {
|
|
94600
|
+
values[name] = binding.value;
|
|
94601
|
+
continue;
|
|
94602
|
+
}
|
|
94603
|
+
const reading = read(binding);
|
|
94604
|
+
if (reading.state === "unavailable") {
|
|
94605
|
+
const outcome = {
|
|
94606
|
+
state: "unavailable",
|
|
94607
|
+
value: null,
|
|
94608
|
+
reason: `binding \`${name}\` (${describeRead(binding)}): ${reading.reason}`,
|
|
94609
|
+
fatal: reading.fatal,
|
|
94610
|
+
confirmed: isConfirmed(reading)
|
|
94611
|
+
};
|
|
94612
|
+
if (reading.fatal) {
|
|
94613
|
+
fatalUnavailable = outcome;
|
|
94614
|
+
break;
|
|
94615
|
+
}
|
|
94616
|
+
if (nonFatalUnavailable === null || outcome.confirmed && !nonFatalUnavailable.confirmed) nonFatalUnavailable = outcome;
|
|
94617
|
+
continue;
|
|
94618
|
+
}
|
|
94619
|
+
values[name] = reading.value;
|
|
94620
|
+
if (reading.state === "fresh" && reading.transition !== void 0 && stateful !== void 0) stateful.expressionMemory.dwellTransition = reading.transition;
|
|
94621
|
+
if (reading.state === "stale") staleReasons.push(`\`${name}\`: ${reading.reason}`);
|
|
94622
|
+
}
|
|
94623
|
+
const unavailable = fatalUnavailable ?? nonFatalUnavailable;
|
|
94624
|
+
if (unavailable !== null) {
|
|
94625
|
+
if (stateful !== void 0 && stateful.currentOutput !== void 0 && expressionContainsBuiltinCall(source.expr, "count")) return {
|
|
94626
|
+
state: "stale",
|
|
94627
|
+
value: evaluateCount(null, {
|
|
94628
|
+
kind: "count",
|
|
94629
|
+
highWater: null,
|
|
94630
|
+
primed: false
|
|
94631
|
+
}, stateful.currentOutput),
|
|
94632
|
+
reason: `${unavailable.reason}; holding the last accumulator value`,
|
|
94633
|
+
deadline: null
|
|
94634
|
+
};
|
|
94635
|
+
return unavailable;
|
|
94636
|
+
}
|
|
94637
|
+
const deadlines = [];
|
|
94638
|
+
const hooks = {
|
|
94639
|
+
noteDeadline: (at) => deadlines.push(at),
|
|
94640
|
+
...stateful?.timerDriven === true ? { timerDriven: true } : {},
|
|
94641
|
+
convert: (value, from, to) => tryConvertUnit(value, normalizeUnit(from) ?? from, normalizeUnit(to) ?? to) ?? null
|
|
94642
|
+
};
|
|
94643
|
+
const result = evaluateExpressionSource(source.expr, values, now, {
|
|
94644
|
+
hooks,
|
|
94645
|
+
...stateful === void 0 ? {} : { invokeStateful: (invocation) => evaluateStatefulExpressionCall(stateful.callPathPrefix === void 0 ? invocation : {
|
|
94646
|
+
...invocation,
|
|
94647
|
+
path: `${stateful.callPathPrefix}@${invocation.path}`
|
|
94648
|
+
}, stateful.expressionMemory, {
|
|
94649
|
+
currentOutput: stateful.currentOutput,
|
|
94650
|
+
startedAtMs: stateful.startedAtMs,
|
|
94651
|
+
nowMs: now
|
|
94652
|
+
}, hooks) }
|
|
94653
|
+
});
|
|
94654
|
+
const transition = stateful?.expressionMemory.dwellTransition ?? null;
|
|
94655
|
+
if (stateful !== void 0) stateful.expressionMemory.dwellTransition = null;
|
|
94656
|
+
if (!result.ok) return {
|
|
94657
|
+
state: "unavailable",
|
|
94658
|
+
value: null,
|
|
94659
|
+
reason: `the expression failed: ${result.error}`,
|
|
94660
|
+
fatal: false,
|
|
94661
|
+
confirmed: true,
|
|
94662
|
+
expressionFailed: true
|
|
94663
|
+
};
|
|
94664
|
+
return {
|
|
94665
|
+
state: staleReasons.length > 0 ? "stale" : "fresh",
|
|
94666
|
+
value: result.value,
|
|
94667
|
+
reason: staleReasons.length > 0 ? staleReasons.join("; ") : null,
|
|
94668
|
+
deadline: deadlines.length > 0 ? Math.min(...deadlines) : null,
|
|
94669
|
+
...transition === null ? {} : { transition }
|
|
94670
|
+
};
|
|
94671
|
+
}
|
|
94672
|
+
function aggregateRead(reading) {
|
|
94673
|
+
if (reading.state === "unavailable") return {
|
|
94674
|
+
state: "unavailable",
|
|
94675
|
+
fatal: reading.fatal,
|
|
94676
|
+
reason: reading.reason
|
|
94677
|
+
};
|
|
94678
|
+
return {
|
|
94679
|
+
state: reading.state,
|
|
94680
|
+
value: reading.value,
|
|
94681
|
+
...reading.state === "stale" ? { reason: reading.reason } : {}
|
|
94682
|
+
};
|
|
94683
|
+
}
|
|
94684
|
+
function aggregateField(source, read) {
|
|
94685
|
+
const outcome = evaluateAggregate({
|
|
94686
|
+
reducer: source.reducer,
|
|
94687
|
+
...source.activeWhen === void 0 ? {} : { activeWhen: source.activeWhen },
|
|
94688
|
+
members: source.reads.map((item) => aggregateRead(read(item))),
|
|
94689
|
+
publish: source.publish,
|
|
94690
|
+
empty: source.empty
|
|
94691
|
+
});
|
|
94692
|
+
if (outcome.kind === "value") return {
|
|
94693
|
+
state: "fresh",
|
|
94694
|
+
value: outcome.value,
|
|
94695
|
+
reason: null,
|
|
94696
|
+
deadline: null
|
|
94697
|
+
};
|
|
94698
|
+
return {
|
|
94699
|
+
state: "unavailable",
|
|
94700
|
+
value: null,
|
|
94701
|
+
reason: outcome.reason,
|
|
94702
|
+
fatal: outcome.fatal,
|
|
94703
|
+
confirmed: true
|
|
94704
|
+
};
|
|
94705
|
+
}
|
|
94706
|
+
function evaluateCompositionField(input) {
|
|
94707
|
+
const { source } = input;
|
|
94708
|
+
switch (source.kind) {
|
|
94709
|
+
case "from": return fromReading(input.read(source), source);
|
|
94710
|
+
case "expression": return expressionOutcome(source, input.read, input.now, input.stateful);
|
|
94711
|
+
case "aggregate": return aggregateField(source, input.read);
|
|
94712
|
+
case "series": return {
|
|
94713
|
+
state: "unavailable",
|
|
94714
|
+
value: null,
|
|
94715
|
+
reason: "a series field is written from device history",
|
|
94716
|
+
fatal: false,
|
|
94717
|
+
confirmed: false
|
|
94718
|
+
};
|
|
94719
|
+
case "code": return {
|
|
94720
|
+
state: "unavailable",
|
|
94721
|
+
value: null,
|
|
94722
|
+
reason: "code fields are not runnable in the composer — they arrive in slice 4",
|
|
94723
|
+
fatal: true,
|
|
94724
|
+
confirmed: true
|
|
94725
|
+
};
|
|
94726
|
+
}
|
|
94727
|
+
}
|
|
94728
|
+
function lockDoorLinkOfComposition(composition) {
|
|
94729
|
+
if (composition === null || composition.target.kind !== "existing") return null;
|
|
94730
|
+
const feature = composition.features.find((f) => f.cap === "lock-control");
|
|
94731
|
+
if (feature === void 0 || feature.kind !== "fields") return null;
|
|
94732
|
+
const state = feature.fields["state"];
|
|
94733
|
+
if (state === void 0 || state.kind !== "expression") return null;
|
|
94734
|
+
const x = state.bindings["x"];
|
|
94735
|
+
if (x === void 0 || x.kind !== "from") return null;
|
|
94736
|
+
return {
|
|
94737
|
+
lock: composition.target.device,
|
|
94738
|
+
sensor: x.source
|
|
94739
|
+
};
|
|
94740
|
+
}
|
|
94741
|
+
/**
|
|
94742
|
+
* Which smart switch powers a device (the `power-source` Customize extension):
|
|
94743
|
+
* the source its stored `power-source.switchOn` field reads, and the off time of
|
|
94744
|
+
* a forced restart stored beside it. Read from the STORED composition, never kept
|
|
94745
|
+
* as a second copy (D676). Shared by the hub (which acts on the switch) and the
|
|
94746
|
+
* admin UI (which shows it).
|
|
94747
|
+
*/
|
|
94748
|
+
/**
|
|
94749
|
+
* The stored off time, or the default when none is stored. A stored number out
|
|
94750
|
+
* of range is CLAMPED to the bounds (a hand-written value never refuses the
|
|
94751
|
+
* link, it just cannot cut power for an absurd time); a non-integer is rounded.
|
|
94752
|
+
*/
|
|
94753
|
+
function normalizeOffSeconds(value) {
|
|
94754
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return 10;
|
|
94755
|
+
return Math.min(120, Math.max(3, Math.round(value)));
|
|
94756
|
+
}
|
|
94757
|
+
/** The constant a stored `offSeconds` field carries, or undefined when it is not a literal number. */
|
|
94758
|
+
function storedOffSeconds(composition) {
|
|
94759
|
+
const feature = composition.features.find((f) => f.cap === "power-source");
|
|
94760
|
+
if (feature === void 0 || feature.kind !== "fields") return void 0;
|
|
94761
|
+
const field = feature.fields["offSeconds"];
|
|
94762
|
+
if (field === void 0 || field.kind !== "expression") return void 0;
|
|
94763
|
+
const n = Number(field.expr);
|
|
94764
|
+
return field.expr.trim() === "" || !Number.isFinite(n) ? void 0 : n;
|
|
94765
|
+
}
|
|
94766
|
+
/**
|
|
94767
|
+
* The link a composition stores. An `existing` target names its own device; a
|
|
94768
|
+
* `new` target (a composed device) is the composer's own device, so the caller
|
|
94769
|
+
* passes the block id and a new-target composition without one has no link.
|
|
94770
|
+
*/
|
|
94771
|
+
function powerSourceLinkOfComposition(composition, blockId) {
|
|
94772
|
+
if (composition === null) return null;
|
|
94773
|
+
let device;
|
|
94774
|
+
if (composition.target.kind === "existing") device = composition.target.device;
|
|
94775
|
+
else if (blockId !== void 0) device = composedDeviceRef(blockId);
|
|
94776
|
+
else return null;
|
|
94777
|
+
const feature = composition.features.find((f) => f.cap === "power-source");
|
|
94778
|
+
if (feature === void 0 || feature.kind !== "fields" || feature.enabled === false) return null;
|
|
94779
|
+
const field = feature.fields["switchOn"];
|
|
94780
|
+
if (field === void 0) return null;
|
|
94781
|
+
const read = fieldReads(field).find((r) => r.cap === "switch");
|
|
94782
|
+
if (read === void 0) return null;
|
|
94783
|
+
return {
|
|
94784
|
+
device,
|
|
94785
|
+
switch: read.source,
|
|
94786
|
+
offSeconds: normalizeOffSeconds(storedOffSeconds(composition))
|
|
94787
|
+
};
|
|
94788
|
+
}
|
|
94789
|
+
SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
|
|
94790
|
+
String.raw`rose\(active(\d+), changed(\d+), (\d+(?:\.\d+)?)\)`;
|
|
94618
94791
|
DeviceRole.BinarySensor, DeviceRole.MotionSensor;
|
|
94619
94792
|
new Set(CAP_NAMES);
|
|
94620
94793
|
function isUnfilledRequiredProblem(problem) {
|
|
@@ -105420,6 +105593,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
105420
105593
|
access: "create",
|
|
105421
105594
|
role: "viewer"
|
|
105422
105595
|
},
|
|
105596
|
+
"timedRun.getOptions": {
|
|
105597
|
+
capName: "timed-run",
|
|
105598
|
+
capScope: "device",
|
|
105599
|
+
addonId: null,
|
|
105600
|
+
access: "view",
|
|
105601
|
+
role: "viewer"
|
|
105602
|
+
},
|
|
105423
105603
|
"timedRun.getStatus": {
|
|
105424
105604
|
capName: "timed-run",
|
|
105425
105605
|
capScope: "device",
|
|
@@ -105434,6 +105614,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
105434
105614
|
access: "create",
|
|
105435
105615
|
role: "viewer"
|
|
105436
105616
|
},
|
|
105617
|
+
"timedRun.setSettings": {
|
|
105618
|
+
capName: "timed-run",
|
|
105619
|
+
capScope: "device",
|
|
105620
|
+
addonId: null,
|
|
105621
|
+
access: "create",
|
|
105622
|
+
role: "admin"
|
|
105623
|
+
},
|
|
105437
105624
|
"toast.onToast": {
|
|
105438
105625
|
capName: "toast",
|
|
105439
105626
|
capScope: "system",
|
|
@@ -109201,6 +109388,11 @@ Object.freeze({
|
|
|
109201
109388
|
form: "single",
|
|
109202
109389
|
optional: false
|
|
109203
109390
|
}],
|
|
109391
|
+
"timedRun.getOptions": [{
|
|
109392
|
+
name: "deviceId",
|
|
109393
|
+
form: "single",
|
|
109394
|
+
optional: false
|
|
109395
|
+
}],
|
|
109204
109396
|
"timedRun.getStatus": [{
|
|
109205
109397
|
name: "deviceId",
|
|
109206
109398
|
form: "single",
|
|
@@ -109211,6 +109403,11 @@ Object.freeze({
|
|
|
109211
109403
|
form: "single",
|
|
109212
109404
|
optional: false
|
|
109213
109405
|
}],
|
|
109406
|
+
"timedRun.setSettings": [{
|
|
109407
|
+
name: "deviceId",
|
|
109408
|
+
form: "single",
|
|
109409
|
+
optional: false
|
|
109410
|
+
}],
|
|
109214
109411
|
"update.getStatus": [{
|
|
109215
109412
|
name: "deviceId",
|
|
109216
109413
|
form: "single",
|
|
@@ -113263,6 +113460,12 @@ Object.defineProperty(exports, "featureForwards", {
|
|
|
113263
113460
|
return featureForwards;
|
|
113264
113461
|
}
|
|
113265
113462
|
});
|
|
113463
|
+
Object.defineProperty(exports, "featuresOfBoundCaps", {
|
|
113464
|
+
enumerable: true,
|
|
113465
|
+
get: function() {
|
|
113466
|
+
return featuresOfBoundCaps;
|
|
113467
|
+
}
|
|
113468
|
+
});
|
|
113266
113469
|
Object.defineProperty(exports, "filesystemBrowseCapability", {
|
|
113267
113470
|
enumerable: true,
|
|
113268
113471
|
get: function() {
|
|
@@ -114253,6 +114456,18 @@ Object.defineProperty(exports, "timedRunLimitOf", {
|
|
|
114253
114456
|
return timedRunLimitOf;
|
|
114254
114457
|
}
|
|
114255
114458
|
});
|
|
114459
|
+
Object.defineProperty(exports, "timedRunMaxIn", {
|
|
114460
|
+
enumerable: true,
|
|
114461
|
+
get: function() {
|
|
114462
|
+
return timedRunMaxIn;
|
|
114463
|
+
}
|
|
114464
|
+
});
|
|
114465
|
+
Object.defineProperty(exports, "timedRunQuickRun", {
|
|
114466
|
+
enumerable: true,
|
|
114467
|
+
get: function() {
|
|
114468
|
+
return timedRunQuickRun;
|
|
114469
|
+
}
|
|
114470
|
+
});
|
|
114256
114471
|
Object.defineProperty(exports, "timedRunSeconds", {
|
|
114257
114472
|
enumerable: true,
|
|
114258
114473
|
get: function() {
|
|
@@ -114361,6 +114576,12 @@ Object.defineProperty(exports, "weekdayOfLocalDate", {
|
|
|
114361
114576
|
return weekdayOfLocalDate;
|
|
114362
114577
|
}
|
|
114363
114578
|
});
|
|
114579
|
+
Object.defineProperty(exports, "withDefaultRunning", {
|
|
114580
|
+
enumerable: true,
|
|
114581
|
+
get: function() {
|
|
114582
|
+
return withDefaultRunning;
|
|
114583
|
+
}
|
|
114584
|
+
});
|
|
114364
114585
|
Object.defineProperty(exports, "withLocationMode", {
|
|
114365
114586
|
enumerable: true,
|
|
114366
114587
|
get: function() {
|