@camstack/types 1.2.547 → 1.2.549
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 +20 -0
- package/dist/addon.js +5 -5
- package/dist/addon.mjs +5 -5
- package/dist/automation/condition-eval.d.ts +24 -0
- package/dist/automation/hold.d.ts +11 -0
- package/dist/automation/index.d.ts +6 -4
- package/dist/automation/recipe.d.ts +5 -0
- package/dist/automation/step-condition.d.ts +7 -2
- package/dist/automation/trace.d.ts +6 -0
- package/dist/automation/trigger-variables.d.ts +3 -1
- package/dist/automation/when-site.d.ts +27 -0
- package/dist/automation/when.d.ts +107 -1
- package/dist/capabilities/accessories.cap.d.ts +1 -1
- package/dist/capabilities/actions.cap.d.ts +2 -0
- package/dist/capabilities/battery.cap.d.ts +2 -2
- package/dist/capabilities/capability-definition.d.ts +47 -1
- package/dist/capabilities/climate-control.cap.d.ts +8 -1
- package/dist/capabilities/core-blocks.cap.d.ts +8 -0
- package/dist/capabilities/customize-catalog.d.ts +3 -1
- package/dist/capabilities/customize-spec.d.ts +26 -2
- package/dist/capabilities/device-manager.cap.d.ts +6 -0
- package/dist/capabilities/fan-control.cap.d.ts +248 -0
- package/dist/capabilities/fan-presets.cap.d.ts +172 -536
- package/dist/capabilities/group-active.cap.d.ts +1 -1
- package/dist/capabilities/group-commands.cap.d.ts +1 -1
- package/dist/capabilities/group-status.cap.d.ts +1 -1
- package/dist/capabilities/heating-valve.cap.d.ts +1 -1
- package/dist/capabilities/hero-layout.cap.d.ts +2 -0
- package/dist/capabilities/humidifier.cap.d.ts +5 -0
- package/dist/capabilities/humidity-sensor.cap.d.ts +1 -1
- package/dist/capabilities/index.d.ts +4 -4
- package/dist/capabilities/media-player.cap.d.ts +7 -0
- package/dist/capabilities/pet-fountain.cap.d.ts +5 -0
- package/dist/capabilities/power-meter.cap.d.ts +5 -5
- package/dist/capabilities/power-source.cap.d.ts +5 -0
- package/dist/capabilities/running-state.cap.d.ts +2 -2
- package/dist/capabilities/schedulers.cap.d.ts +2 -0
- package/dist/capabilities/switch.cap.d.ts +1 -1
- package/dist/capabilities/temperature-sensor.cap.d.ts +1 -1
- package/dist/capabilities/timed-run.cap.d.ts +19 -5
- package/dist/capabilities/water-heater.cap.d.ts +7 -0
- package/dist/client.js +7 -11
- package/dist/client.mjs +7 -11
- package/dist/{composed-stable-id-DrGLxjVF.js → composed-stable-id-CDNLq7Y8.js} +27 -10
- package/dist/{composed-stable-id-DFNyOFzz.mjs → composed-stable-id-CPp3votu.mjs} +27 -10
- package/dist/composition/composition-report.d.ts +6 -0
- package/dist/composition/evaluate-field.d.ts +7 -0
- package/dist/composition/field-kinds.d.ts +12 -1
- package/dist/composition/helpers/index.d.ts +1 -1
- package/dist/composition/helpers/source-pick.d.ts +0 -5
- package/dist/composition/power-source-link.d.ts +15 -0
- package/dist/composition/state-fields.d.ts +2 -0
- package/dist/composition/validate-composition.d.ts +15 -1
- package/dist/device/base-device-provider.d.ts +13 -0
- package/dist/device/device-control-resolution.d.ts +1 -33
- package/dist/device/device-kind.d.ts +36 -0
- package/dist/device/device-management.d.ts +3 -0
- package/dist/device/device-type.d.ts +27 -10
- package/dist/device/hero/hero-fragment.d.ts +2 -0
- package/dist/device/hero/hero-layout.d.ts +1 -3
- package/dist/device/hero/hero-look.d.ts +18 -12
- package/dist/device/hero/hero-scene.d.ts +9 -3
- package/dist/device/index.d.ts +2 -1
- package/dist/device/power-switch.d.ts +82 -0
- package/dist/device/schema-fields.d.ts +10 -1
- package/dist/generated/addon-api.d.ts +27 -0
- package/dist/generated/cap-input-defaults.d.ts +1 -1
- package/dist/generated/collection-array-methods.d.ts +1 -1
- package/dist/generated/customize-catalog.d.ts +257 -8
- package/dist/generated/method-access-map.d.ts +1 -1
- package/dist/generated/method-device-selectors.d.ts +1 -1
- package/dist/{implemented-methods-M5aguGon.mjs → implemented-methods-5YMDeE3f.mjs} +1 -1
- package/dist/{implemented-methods-8AU92riC.js → implemented-methods-Cj65uy2F.js} +1 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.js +1783 -451
- package/dist/index.mjs +1740 -445
- package/dist/node.js +2 -2
- package/dist/node.mjs +2 -2
- package/dist/{sleep-D_NpiLFP.mjs → sleep-Bn346wCJ.mjs} +46 -1
- package/dist/{sleep-vzHEmsrO.js → sleep-LFKpQ2_f.js} +46 -1
- package/dist/time/index.d.ts +1 -0
- package/dist/time/time-spec.d.ts +5 -0
- package/dist/time/time-window.d.ts +33 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_sleep = require("./sleep-
|
|
2
|
+
const require_sleep = require("./sleep-LFKpQ2_f.js");
|
|
3
3
|
const require_event_category = require("./event-category-BC4RRerT.js");
|
|
4
|
-
const require_composed_stable_id = require("./composed-stable-id-
|
|
5
|
-
const require_implemented_methods = require("./implemented-methods-
|
|
4
|
+
const require_composed_stable_id = require("./composed-stable-id-CDNLq7Y8.js");
|
|
5
|
+
const require_implemented_methods = require("./implemented-methods-Cj65uy2F.js");
|
|
6
6
|
const require_node_color = require("./node-color.js");
|
|
7
7
|
const require_convert = require("./convert-BmtM6K-5.js");
|
|
8
8
|
const require_enums = require("./enums.js");
|
|
@@ -31187,16 +31187,39 @@ function metaQuantity(schema) {
|
|
|
31187
31187
|
function quantityOfField(schema) {
|
|
31188
31188
|
return metaQuantity(schema) ?? metaQuantity(unwrapSchema(schema));
|
|
31189
31189
|
}
|
|
31190
|
+
function scalarKind(schema) {
|
|
31191
|
+
const s = unwrapSchema(schema);
|
|
31192
|
+
if (s instanceof zod.z.ZodNumber) return "number";
|
|
31193
|
+
if (s instanceof zod.z.ZodString) return "string";
|
|
31194
|
+
if (s instanceof zod.z.ZodBoolean) return "boolean";
|
|
31195
|
+
return null;
|
|
31196
|
+
}
|
|
31197
|
+
/** A union is a leaf only when EVERY member is a scalar; one object or array member keeps it out. */
|
|
31198
|
+
function unionMembersOf(s) {
|
|
31199
|
+
const members = [];
|
|
31200
|
+
for (const option of s.options) {
|
|
31201
|
+
if (!(option instanceof zod.z.ZodType)) return null;
|
|
31202
|
+
const kind = scalarKind(option);
|
|
31203
|
+
if (kind === null) return null;
|
|
31204
|
+
if (!members.includes(kind)) members.push(kind);
|
|
31205
|
+
}
|
|
31206
|
+
return members.length > 0 ? members : null;
|
|
31207
|
+
}
|
|
31190
31208
|
function leafKind(schema) {
|
|
31191
31209
|
const s = unwrapSchema(schema);
|
|
31192
31210
|
if (s instanceof zod.z.ZodEnum) return {
|
|
31193
31211
|
kind: "enum",
|
|
31194
31212
|
enumValues: s.options
|
|
31195
31213
|
};
|
|
31196
|
-
if (s instanceof zod.z.
|
|
31197
|
-
|
|
31198
|
-
|
|
31199
|
-
|
|
31214
|
+
if (s instanceof zod.z.ZodUnion) {
|
|
31215
|
+
const members = unionMembersOf(s);
|
|
31216
|
+
return members === null ? null : {
|
|
31217
|
+
kind: "union",
|
|
31218
|
+
unionMembers: members
|
|
31219
|
+
};
|
|
31220
|
+
}
|
|
31221
|
+
const scalar = scalarKind(s);
|
|
31222
|
+
return scalar === null ? null : { kind: scalar };
|
|
31200
31223
|
}
|
|
31201
31224
|
/** Walk a cap status schema into flat wireable leaf fields (dotted paths).
|
|
31202
31225
|
* Recurses into nested ZodObject (unwrapping nullable/optional/default first),
|
|
@@ -31221,6 +31244,7 @@ function enumerateSchemaFields(schema, prefix = "") {
|
|
|
31221
31244
|
path,
|
|
31222
31245
|
kind: leaf.kind,
|
|
31223
31246
|
...leaf.enumValues ? { enumValues: leaf.enumValues } : {},
|
|
31247
|
+
...leaf.unionMembers ? { unionMembers: leaf.unionMembers } : {},
|
|
31224
31248
|
...quantity !== void 0 ? { quantity } : {}
|
|
31225
31249
|
});
|
|
31226
31250
|
}
|
|
@@ -32304,7 +32328,7 @@ function weekdayOfLocalDate(localDate) {
|
|
|
32304
32328
|
const { y, m, d } = parseLocalDate(localDate);
|
|
32305
32329
|
return WEEKDAY_BY_INDEX[new Date(Date.UTC(y, m - 1, d)).getUTCDay()] ?? "sun";
|
|
32306
32330
|
}
|
|
32307
|
-
function addDays(localDate, days) {
|
|
32331
|
+
function addDays$1(localDate, days) {
|
|
32308
32332
|
const { y, m, d } = parseLocalDate(localDate);
|
|
32309
32333
|
return new Date(Date.UTC(y, m - 1, d + days)).toISOString().slice(0, 10);
|
|
32310
32334
|
}
|
|
@@ -32368,9 +32392,9 @@ function nextOccurrence(spec, afterMs, site, options = {}) {
|
|
|
32368
32392
|
const at = occurrenceOn(spec, own, site);
|
|
32369
32393
|
return at !== null && at > afterMs ? at : null;
|
|
32370
32394
|
}
|
|
32371
|
-
const first = addDays(localDateOf(afterMs, site.timeZone), -1);
|
|
32395
|
+
const first = addDays$1(localDateOf(afterMs, site.timeZone), -1);
|
|
32372
32396
|
for (let i = 0; i < 400; i += 1) {
|
|
32373
|
-
const localDate = addDays(first, i);
|
|
32397
|
+
const localDate = addDays$1(first, i);
|
|
32374
32398
|
if (days !== void 0 && !days.includes(weekdayOfLocalDate(localDate))) continue;
|
|
32375
32399
|
const at = occurrenceOn(spec, localDate, site);
|
|
32376
32400
|
if (at !== null && at > afterMs) return at;
|
|
@@ -32414,7 +32438,8 @@ function zoneOnlySite(timeZone) {
|
|
|
32414
32438
|
return {
|
|
32415
32439
|
lat: 0,
|
|
32416
32440
|
lon: 0,
|
|
32417
|
-
timeZone
|
|
32441
|
+
timeZone,
|
|
32442
|
+
zoneOnly: true
|
|
32418
32443
|
};
|
|
32419
32444
|
}
|
|
32420
32445
|
//#endregion
|
|
@@ -32607,6 +32632,8 @@ var BecomesWatch = class {
|
|
|
32607
32632
|
spec;
|
|
32608
32633
|
deps;
|
|
32609
32634
|
previous = void 0;
|
|
32635
|
+
/** The value the field left at its last change — a re-report does not move it. */
|
|
32636
|
+
from = void 0;
|
|
32610
32637
|
seeded = false;
|
|
32611
32638
|
core;
|
|
32612
32639
|
handle = void 0;
|
|
@@ -32651,13 +32678,15 @@ var BecomesWatch = class {
|
|
|
32651
32678
|
const previous = this.previous;
|
|
32652
32679
|
const first = !this.seeded;
|
|
32653
32680
|
this.seeded = true;
|
|
32681
|
+
if (!first && value !== previous) this.from = previous;
|
|
32654
32682
|
this.previous = value;
|
|
32655
32683
|
const holds = predicateOf(this.spec, value);
|
|
32656
32684
|
if (this.core === void 0) {
|
|
32657
32685
|
if (first) return;
|
|
32658
32686
|
if (holds === void 0 ? value !== previous : holds && predicateOf(this.spec, previous) !== true) this.deps.emit({
|
|
32659
32687
|
kind: "fire",
|
|
32660
|
-
value
|
|
32688
|
+
value,
|
|
32689
|
+
from: this.from
|
|
32661
32690
|
});
|
|
32662
32691
|
return;
|
|
32663
32692
|
}
|
|
@@ -32713,6 +32742,7 @@ var BecomesWatch = class {
|
|
|
32713
32742
|
this.deps.emit({
|
|
32714
32743
|
kind: "fire",
|
|
32715
32744
|
value: this.previous,
|
|
32745
|
+
from: this.from,
|
|
32716
32746
|
hold: this.trace("fired", reading)
|
|
32717
32747
|
});
|
|
32718
32748
|
}
|
|
@@ -32775,6 +32805,13 @@ var AutomationConditionOperatorSchema = zod.z.enum([
|
|
|
32775
32805
|
"in"
|
|
32776
32806
|
]);
|
|
32777
32807
|
/**
|
|
32808
|
+
* The stable name of an event leaf. A path (`when.0.1`) moves when a row is
|
|
32809
|
+
* reordered; the id does not, so a `triggered-by` leaf keeps pointing at the
|
|
32810
|
+
* same row. Optional: a leaf nothing refers to needs none.
|
|
32811
|
+
*/
|
|
32812
|
+
var EVENT_LEAF_ID_RE = /^[A-Za-z0-9_-]{1,40}$/;
|
|
32813
|
+
var eventLeafId = { id: zod.z.string().regex(EVENT_LEAF_ID_RE).optional() };
|
|
32814
|
+
/**
|
|
32778
32815
|
* D8 compliance, and it is the reason a "becomes" leaf is not merely an event
|
|
32779
32816
|
* subscription: it evaluates against the **state mirror**, which is reconciled,
|
|
32780
32817
|
* and an event only WAKES the evaluation. A dropped event therefore DELAYS a
|
|
@@ -32782,6 +32819,7 @@ var AutomationConditionOperatorSchema = zod.z.enum([
|
|
|
32782
32819
|
*/
|
|
32783
32820
|
var DeviceBecomesLeafSchema = zod.z.object({
|
|
32784
32821
|
kind: zod.z.literal("device-becomes"),
|
|
32822
|
+
...eventLeafId,
|
|
32785
32823
|
deviceId: zod.z.number().int().nonnegative(),
|
|
32786
32824
|
cap: zod.z.string().min(1),
|
|
32787
32825
|
fieldPath: zod.z.string().min(1),
|
|
@@ -32834,6 +32872,7 @@ var DeviceBecomesLeafSchema = zod.z.object({
|
|
|
32834
32872
|
});
|
|
32835
32873
|
var DeviceEventLeafSchema = zod.z.object({
|
|
32836
32874
|
kind: zod.z.literal("device-event"),
|
|
32875
|
+
...eventLeafId,
|
|
32837
32876
|
/** An `EventCategory` value. */
|
|
32838
32877
|
category: zod.z.string().min(1),
|
|
32839
32878
|
deviceId: zod.z.number().int().nonnegative().optional()
|
|
@@ -32846,18 +32885,24 @@ var DeviceEventLeafSchema = zod.z.object({
|
|
|
32846
32885
|
*/
|
|
32847
32886
|
var ScheduleLeafSchema = zod.z.object({
|
|
32848
32887
|
kind: zod.z.literal("schedule"),
|
|
32888
|
+
...eventLeafId,
|
|
32849
32889
|
at: TimeSpecSchema.optional(),
|
|
32850
32890
|
days: zod.z.array(WeekdayKeySchema).min(1).max(7).optional(),
|
|
32851
32891
|
/** @deprecated legacy cron — new schedules use `at`. */
|
|
32852
32892
|
cron: zod.z.string().min(1).max(120).optional()
|
|
32853
32893
|
}).refine((leaf) => leaf.at === void 0 !== (leaf.cron === void 0), { message: "a schedule names exactly one of `at` (a time spec) and `cron` (legacy)" }).refine((leaf) => leaf.days === void 0 || leaf.at !== void 0, { message: "`days` goes with `at`; a cron expression carries its own days" });
|
|
32854
|
-
var ManualLeafSchema = zod.z.object({
|
|
32894
|
+
var ManualLeafSchema = zod.z.object({
|
|
32895
|
+
kind: zod.z.literal("manual"),
|
|
32896
|
+
...eventLeafId
|
|
32897
|
+
});
|
|
32855
32898
|
var IntervalLeafSchema = zod.z.object({
|
|
32856
32899
|
kind: zod.z.literal("interval"),
|
|
32900
|
+
...eventLeafId,
|
|
32857
32901
|
minutes: zod.z.number().int().min(1).max(1440)
|
|
32858
32902
|
});
|
|
32859
32903
|
var DetectionLeafSchema = zod.z.object({
|
|
32860
32904
|
kind: zod.z.literal("detection"),
|
|
32905
|
+
...eventLeafId,
|
|
32861
32906
|
/** One macro class each, optionally narrowed by a label; a track of any listed subject fires. */
|
|
32862
32907
|
subjects: zod.z.array(DetectionSubjectSchema).min(1),
|
|
32863
32908
|
deviceIds: zod.z.array(zod.z.number().int().nonnegative()).min(1),
|
|
@@ -32868,6 +32913,7 @@ var DetectionLeafSchema = zod.z.object({
|
|
|
32868
32913
|
});
|
|
32869
32914
|
var StationaryLeafSchema = zod.z.object({
|
|
32870
32915
|
kind: zod.z.literal("stationary"),
|
|
32916
|
+
...eventLeafId,
|
|
32871
32917
|
deviceIds: zod.z.array(zod.z.number().int().nonnegative()).min(1),
|
|
32872
32918
|
subjects: zod.z.array(StationarySubjectSchema).min(1).optional(),
|
|
32873
32919
|
zones: zod.z.array(zod.z.string().min(1)).min(1).optional(),
|
|
@@ -32913,6 +32959,43 @@ var StationaryPresentLeafSchema = zod.z.object({
|
|
|
32913
32959
|
minCount: zod.z.number().int().positive().optional()
|
|
32914
32960
|
});
|
|
32915
32961
|
/**
|
|
32962
|
+
* True while the site-local clock is inside a daily window and/or on one of
|
|
32963
|
+
* the named days. `days` names the local day a window STARTS on, so
|
|
32964
|
+
* 22:00-06:00 on weekdays is still inside at 01:00 Saturday. A one-date spec
|
|
32965
|
+
* (`kind: 'date'`) is refused: only a clock time or a sun event makes a window
|
|
32966
|
+
* that repeats every day.
|
|
32967
|
+
*/
|
|
32968
|
+
var TimeIsLeafSchema = zod.z.object({
|
|
32969
|
+
kind: zod.z.literal("time-is"),
|
|
32970
|
+
between: zod.z.object({
|
|
32971
|
+
from: TimeSpecSchema,
|
|
32972
|
+
to: TimeSpecSchema
|
|
32973
|
+
}).optional(),
|
|
32974
|
+
days: zod.z.array(WeekdayKeySchema).min(1).max(7).optional()
|
|
32975
|
+
}).superRefine((leaf, ctx) => {
|
|
32976
|
+
if (leaf.between === void 0 && leaf.days === void 0) ctx.addIssue({
|
|
32977
|
+
code: "custom",
|
|
32978
|
+
message: "a time-is leaf needs a between window, days, or both"
|
|
32979
|
+
});
|
|
32980
|
+
for (const end of ["from", "to"]) if (leaf.between?.[end].kind === "date") ctx.addIssue({
|
|
32981
|
+
code: "custom",
|
|
32982
|
+
message: "a one-date time cannot bound a daily window: use a clock time or a sun event",
|
|
32983
|
+
path: ["between", end]
|
|
32984
|
+
});
|
|
32985
|
+
});
|
|
32986
|
+
/** How many event leaves one `triggered-by` names. */
|
|
32987
|
+
var TRIGGERED_BY_MAX_IDS = 20;
|
|
32988
|
+
/**
|
|
32989
|
+
* True for the run that one of the named event leaves started. It reads the
|
|
32990
|
+
* run, not a device: in the tree it is judged against the leaf that fired, in
|
|
32991
|
+
* a step guard against the trigger the run carries. A run no event leaf
|
|
32992
|
+
* started (a state-only tree becoming true) is false.
|
|
32993
|
+
*/
|
|
32994
|
+
var TriggeredByLeafSchema = zod.z.object({
|
|
32995
|
+
kind: zod.z.literal("triggered-by"),
|
|
32996
|
+
leafIds: zod.z.array(zod.z.string().regex(EVENT_LEAF_ID_RE)).min(1).max(20)
|
|
32997
|
+
});
|
|
32998
|
+
/**
|
|
32916
32999
|
* The escape hatch: the bounded expression engine over named device bindings.
|
|
32917
33000
|
* Declared as a plain object so a discriminated union can read `kind`; the
|
|
32918
33001
|
* author-time validation is the SAME function `ExpressionSourceSchema` runs.
|
|
@@ -32958,7 +33041,9 @@ var AutomationWhenSchema = zod.z.lazy(() => zod.z.discriminatedUnion("kind", [
|
|
|
32958
33041
|
StationaryLeafSchema,
|
|
32959
33042
|
DeviceIsLeafSchema,
|
|
32960
33043
|
StationaryPresentLeafSchema,
|
|
32961
|
-
ExpressionLeafSchema
|
|
33044
|
+
ExpressionLeafSchema,
|
|
33045
|
+
TimeIsLeafSchema,
|
|
33046
|
+
TriggeredByLeafSchema
|
|
32962
33047
|
]));
|
|
32963
33048
|
var EVENT_KINDS = new Set([
|
|
32964
33049
|
"device-becomes",
|
|
@@ -33012,6 +33097,46 @@ function hasEventLeaves(node) {
|
|
|
33012
33097
|
});
|
|
33013
33098
|
return found;
|
|
33014
33099
|
}
|
|
33100
|
+
/** The event leaves of the tree that carry an id, in tree order. */
|
|
33101
|
+
function identifiedEventLeaves(when) {
|
|
33102
|
+
const found = [];
|
|
33103
|
+
forEachLeaf(when, (leaf, path) => {
|
|
33104
|
+
if (isEventLeaf(leaf) && leaf.id !== void 0) found.push({
|
|
33105
|
+
id: leaf.id,
|
|
33106
|
+
path,
|
|
33107
|
+
leaf
|
|
33108
|
+
});
|
|
33109
|
+
});
|
|
33110
|
+
return found;
|
|
33111
|
+
}
|
|
33112
|
+
/** The id of the event leaf at `path` (`when.0.1`); null when the leaf has none or the path names no event leaf. */
|
|
33113
|
+
function eventLeafIdAt(when, path) {
|
|
33114
|
+
return identifiedEventLeaves(when).find((entry) => entry.path === path)?.id ?? null;
|
|
33115
|
+
}
|
|
33116
|
+
/** Does the tree hold a `triggered-by` leaf? */
|
|
33117
|
+
function hasTriggeredByLeaves(when) {
|
|
33118
|
+
let found = false;
|
|
33119
|
+
forEachLeaf(when, (leaf) => {
|
|
33120
|
+
if (leaf.kind === "triggered-by") found = true;
|
|
33121
|
+
});
|
|
33122
|
+
return found;
|
|
33123
|
+
}
|
|
33124
|
+
/** Why a `triggered-by` leaf is refused outside an automation: there is no trigger row to name. */
|
|
33125
|
+
var TRIGGERED_BY_NEEDS_AUTOMATION = "\"triggered by\" reads which trigger started an automation — an action or a scheduler has no trigger rows, so it could never be true here";
|
|
33126
|
+
/**
|
|
33127
|
+
* What is wrong with the `triggered-by` leaves of `tree`, given the ids the
|
|
33128
|
+
* automation's event leaves carry: an id nothing carries can never be true.
|
|
33129
|
+
* `where` names the tree in the message (`the rules`, `step 2`).
|
|
33130
|
+
*/
|
|
33131
|
+
function triggeredByIssue(tree, knownIds, where) {
|
|
33132
|
+
let issue = null;
|
|
33133
|
+
forEachLeaf(tree, (leaf) => {
|
|
33134
|
+
if (issue !== null || leaf.kind !== "triggered-by") return;
|
|
33135
|
+
const missing = leaf.leafIds.find((id) => !knownIds.has(id));
|
|
33136
|
+
if (missing !== void 0) issue = `${where}: "triggered by" names the trigger "${missing}", and no trigger row of this automation has that id — pick one of its trigger rows`;
|
|
33137
|
+
});
|
|
33138
|
+
return issue;
|
|
33139
|
+
}
|
|
33015
33140
|
function hasEmptyContainer(node) {
|
|
33016
33141
|
if (isLeaf(node)) return false;
|
|
33017
33142
|
if (node.kind === "not") return hasEmptyContainer(node.child);
|
|
@@ -33070,6 +33195,11 @@ function validateWhenTree(when) {
|
|
|
33070
33195
|
if (depth > 4) return `the rules nest ${depth} levels deep — the limit is 4. "not (any of …)" is the same as "all of (not …)", which is one level shallower`;
|
|
33071
33196
|
const leaves = countWhenLeaves(when);
|
|
33072
33197
|
if (leaves > 32) return `the rules use ${leaves} rows — the limit is 32`;
|
|
33198
|
+
const seen = /* @__PURE__ */ new Set();
|
|
33199
|
+
for (const entry of identifiedEventLeaves(when)) {
|
|
33200
|
+
if (seen.has(entry.id)) return `two trigger rows share the id "${entry.id}" — an id names one row`;
|
|
33201
|
+
seen.add(entry.id);
|
|
33202
|
+
}
|
|
33073
33203
|
const need = eventNeed(when, "when", false);
|
|
33074
33204
|
if ("error" in need) return need.error;
|
|
33075
33205
|
const [first, second] = need.paths;
|
|
@@ -33405,7 +33535,18 @@ var GuardedCapStepSchema = AutomationCapStepBaseSchema.extend(stepGuardShape).re
|
|
|
33405
33535
|
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
33406
33536
|
path: ["actionId"]
|
|
33407
33537
|
}).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
33408
|
-
|
|
33538
|
+
/**
|
|
33539
|
+
* A step of a STANDALONE list (an action, a scheduler point, a preset): the
|
|
33540
|
+
* same two step kinds an automation runs, minus a guard that reads the
|
|
33541
|
+
* automation's trigger, which such a list does not have.
|
|
33542
|
+
*/
|
|
33543
|
+
var ActionStepSchema = zod.z.discriminatedUnion("kind", [GuardedWaitStepSchema, GuardedCapStepSchema]).superRefine((step, ctx) => {
|
|
33544
|
+
if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
|
|
33545
|
+
code: "custom",
|
|
33546
|
+
message: TRIGGERED_BY_NEEDS_AUTOMATION,
|
|
33547
|
+
path: ["if"]
|
|
33548
|
+
});
|
|
33549
|
+
});
|
|
33409
33550
|
var AutomationActionSchema = zod.z.discriminatedUnion("kind", [
|
|
33410
33551
|
GuardedWaitStepSchema,
|
|
33411
33552
|
GuardedCapStepSchema,
|
|
@@ -33501,7 +33642,104 @@ var MAX_CONDITION_LEAVES = 32;
|
|
|
33501
33642
|
*/
|
|
33502
33643
|
function validateRecipeBounds(recipe) {
|
|
33503
33644
|
if (recipe.actions.length === 0) return "an automation needs at least one action — a rule that does nothing is not a rule";
|
|
33504
|
-
|
|
33645
|
+
const tree = validateWhenTree(recipe.when);
|
|
33646
|
+
if (tree !== null) return tree;
|
|
33647
|
+
const ids = new Set(identifiedEventLeaves(recipe.when).map((entry) => entry.id));
|
|
33648
|
+
const inRules = triggeredByIssue(recipe.when, ids, "the rules");
|
|
33649
|
+
if (inRules !== null) return inRules;
|
|
33650
|
+
for (const [index, action] of recipe.actions.entries()) {
|
|
33651
|
+
if (action.kind !== "wait" && action.kind !== "cap" || action.if === void 0) continue;
|
|
33652
|
+
const issue = triggeredByIssue(action.if, ids, `step ${index + 1}`);
|
|
33653
|
+
if (issue !== null) return issue;
|
|
33654
|
+
}
|
|
33655
|
+
return null;
|
|
33656
|
+
}
|
|
33657
|
+
//#endregion
|
|
33658
|
+
//#region src/time/time-window.ts
|
|
33659
|
+
/**
|
|
33660
|
+
* A daily window as a STATE: is this instant inside it, and when does that
|
|
33661
|
+
* next change? Pure — the answer is built per local date from
|
|
33662
|
+
* {@link occurrenceOn}, so a DST change needs no special case.
|
|
33663
|
+
*
|
|
33664
|
+
* Rules:
|
|
33665
|
+
* - A window whose `to` is not after its `from` on the same local date WRAPS:
|
|
33666
|
+
* it runs from `from` on day D to `to` on D+1.
|
|
33667
|
+
* - `days` names the local day a window STARTS on. 22:00-06:00 on weekdays is
|
|
33668
|
+
* inside at 01:00 Saturday (it started Friday). With `days` and no
|
|
33669
|
+
* `between` the window is the whole local day.
|
|
33670
|
+
* - A sun event that does not happen on a day (polar day or night) gives that
|
|
33671
|
+
* day no window. A sun event on a site WITHOUT a location (or an unknown
|
|
33672
|
+
* zone) cannot be judged at all: the result is `unknown`, never a guess.
|
|
33673
|
+
*/
|
|
33674
|
+
var MIDNIGHT = {
|
|
33675
|
+
kind: "clock",
|
|
33676
|
+
hh: 0,
|
|
33677
|
+
mm: 0
|
|
33678
|
+
};
|
|
33679
|
+
/** Start dates looked at for a boundary: yesterday .. the day after tomorrow. */
|
|
33680
|
+
var LOOKAHEAD_DAYS = 2;
|
|
33681
|
+
function addDays(localDate, days) {
|
|
33682
|
+
const [y, m, d] = localDate.split("-").map(Number);
|
|
33683
|
+
return new Date(Date.UTC(y ?? 0, (m ?? 1) - 1, (d ?? 1) + days)).toISOString().slice(0, 10);
|
|
33684
|
+
}
|
|
33685
|
+
function unresolvable(window, site) {
|
|
33686
|
+
if (!isKnownTimeZone(site.timeZone)) return `the site time zone "${site.timeZone}" is not a known IANA zone`;
|
|
33687
|
+
if (window.between !== void 0 && (window.between.from.kind === "sun" || window.between.to.kind === "sun") && site.zoneOnly === true) return "a sun time needs the site location, and none is set";
|
|
33688
|
+
return null;
|
|
33689
|
+
}
|
|
33690
|
+
/** The interval that STARTS on local day `startDate`, or null when that day has none. */
|
|
33691
|
+
function intervalStartingOn(window, startDate, site) {
|
|
33692
|
+
if (window.days !== void 0 && !window.days.includes(weekdayOfLocalDate(startDate))) return null;
|
|
33693
|
+
if (window.between === void 0) {
|
|
33694
|
+
const start = occurrenceOn(MIDNIGHT, startDate, site);
|
|
33695
|
+
const end = occurrenceOn(MIDNIGHT, addDays(startDate, 1), site);
|
|
33696
|
+
return start === null || end === null ? null : {
|
|
33697
|
+
start,
|
|
33698
|
+
end
|
|
33699
|
+
};
|
|
33700
|
+
}
|
|
33701
|
+
const start = occurrenceOn(window.between.from, startDate, site);
|
|
33702
|
+
const sameDayEnd = occurrenceOn(window.between.to, startDate, site);
|
|
33703
|
+
if (start === null || sameDayEnd === null) return null;
|
|
33704
|
+
if (sameDayEnd > start) return {
|
|
33705
|
+
start,
|
|
33706
|
+
end: sameDayEnd
|
|
33707
|
+
};
|
|
33708
|
+
const end = occurrenceOn(window.between.to, addDays(startDate, 1), site);
|
|
33709
|
+
return end === null || end <= start ? null : {
|
|
33710
|
+
start,
|
|
33711
|
+
end
|
|
33712
|
+
};
|
|
33713
|
+
}
|
|
33714
|
+
function judgeTimeWindow(window, nowMs, site) {
|
|
33715
|
+
const blocked = unresolvable(window, site);
|
|
33716
|
+
if (blocked !== null) return {
|
|
33717
|
+
inside: false,
|
|
33718
|
+
unknown: true,
|
|
33719
|
+
nextChangeAtMs: null,
|
|
33720
|
+
why: `cannot be judged: ${blocked}`
|
|
33721
|
+
};
|
|
33722
|
+
const today = localDateOf(nowMs, site.timeZone);
|
|
33723
|
+
let inside = false;
|
|
33724
|
+
let next = null;
|
|
33725
|
+
for (let offset = -1; offset <= LOOKAHEAD_DAYS; offset += 1) {
|
|
33726
|
+
const interval = intervalStartingOn(window, addDays(today, offset), site);
|
|
33727
|
+
if (interval === null) continue;
|
|
33728
|
+
if (interval.start <= nowMs && nowMs < interval.end) inside = true;
|
|
33729
|
+
for (const boundary of [interval.start, interval.end]) if (boundary > nowMs && (next === null || boundary < next)) next = boundary;
|
|
33730
|
+
}
|
|
33731
|
+
if (window.between === void 0) {
|
|
33732
|
+
const midnight = occurrenceOn(MIDNIGHT, addDays(today, 1), site);
|
|
33733
|
+
if (midnight !== null && midnight > nowMs && (next === null || midnight < next)) next = midnight;
|
|
33734
|
+
}
|
|
33735
|
+
const days = window.days === void 0 ? "" : ` on ${window.days.join(", ")}`;
|
|
33736
|
+
const span = window.between === void 0 ? "the whole day" : "the window";
|
|
33737
|
+
return {
|
|
33738
|
+
inside,
|
|
33739
|
+
unknown: false,
|
|
33740
|
+
nextChangeAtMs: next,
|
|
33741
|
+
why: inside ? `inside ${span}${days}` : `outside ${span}${days}`
|
|
33742
|
+
};
|
|
33505
33743
|
}
|
|
33506
33744
|
//#endregion
|
|
33507
33745
|
//#region src/automation/condition-eval.ts
|
|
@@ -33577,6 +33815,8 @@ function collectInto(cond, out) {
|
|
|
33577
33815
|
...binding.addonId !== void 0 ? { addonId: binding.addonId } : {}
|
|
33578
33816
|
});
|
|
33579
33817
|
return;
|
|
33818
|
+
case "time-is": return;
|
|
33819
|
+
case "triggered-by": return;
|
|
33580
33820
|
default: return;
|
|
33581
33821
|
}
|
|
33582
33822
|
}
|
|
@@ -33593,6 +33833,32 @@ function collectWhenMirrorSources(cond) {
|
|
|
33593
33833
|
return true;
|
|
33594
33834
|
});
|
|
33595
33835
|
}
|
|
33836
|
+
/** Does the tree hold a `time-is` leaf? */
|
|
33837
|
+
function hasTimeLeaves(when) {
|
|
33838
|
+
let found = false;
|
|
33839
|
+
forEachLeaf(when, (leaf) => {
|
|
33840
|
+
if (leaf.kind === "time-is") found = true;
|
|
33841
|
+
});
|
|
33842
|
+
return found;
|
|
33843
|
+
}
|
|
33844
|
+
/**
|
|
33845
|
+
* The soonest ANY `time-is` leaf changes sides (ms from `now`), over every
|
|
33846
|
+
* leaf of the tree — a short-circuit that skipped a leaf in the last
|
|
33847
|
+
* evaluation must not hide its boundary. Undefined: no time leaf, no site, or
|
|
33848
|
+
* no boundary within reach.
|
|
33849
|
+
*/
|
|
33850
|
+
function nextTimeBoundaryInMs(when, now, site, rootPath = "when") {
|
|
33851
|
+
if (site === void 0) return void 0;
|
|
33852
|
+
let due;
|
|
33853
|
+
forEachLeaf(when, (leaf) => {
|
|
33854
|
+
if (leaf.kind !== "time-is") return;
|
|
33855
|
+
const next = judgeTimeWindow(leaf, now, site).nextChangeAtMs;
|
|
33856
|
+
if (next === null) return;
|
|
33857
|
+
const ms = Math.max(0, next - now);
|
|
33858
|
+
due = due === void 0 ? ms : Math.min(due, ms);
|
|
33859
|
+
}, rootPath);
|
|
33860
|
+
return due;
|
|
33861
|
+
}
|
|
33596
33862
|
/** Legacy name, for blocks generated before the single tree: an old condition tree. */
|
|
33597
33863
|
function collectMirrorSources(cond) {
|
|
33598
33864
|
return collectWhenMirrorSources(cond === void 0 ? void 0 : convertLegacyCondition(cond));
|
|
@@ -33928,6 +34194,53 @@ function evalNode(cond, path, reader, now, out, state) {
|
|
|
33928
34194
|
});
|
|
33929
34195
|
return ok;
|
|
33930
34196
|
}
|
|
34197
|
+
case "time-is": {
|
|
34198
|
+
if (state.site === void 0) {
|
|
34199
|
+
state.unknown = true;
|
|
34200
|
+
out.push({
|
|
34201
|
+
path,
|
|
34202
|
+
kind: cond.kind,
|
|
34203
|
+
outcome: "fail",
|
|
34204
|
+
reason: "the site clock is not known here → fail"
|
|
34205
|
+
});
|
|
34206
|
+
return false;
|
|
34207
|
+
}
|
|
34208
|
+
const verdict = judgeTimeWindow(cond, now, state.site);
|
|
34209
|
+
if (verdict.unknown) state.unknown = true;
|
|
34210
|
+
if (verdict.nextChangeAtMs !== null) {
|
|
34211
|
+
const due = Math.max(0, verdict.nextChangeAtMs - now);
|
|
34212
|
+
state.timeDueInMs = state.timeDueInMs === void 0 ? due : Math.min(state.timeDueInMs, due);
|
|
34213
|
+
}
|
|
34214
|
+
out.push({
|
|
34215
|
+
path,
|
|
34216
|
+
kind: cond.kind,
|
|
34217
|
+
outcome: verdict.inside ? "pass" : "fail",
|
|
34218
|
+
reason: `${verdict.why} → ${verdict.inside ? "pass" : "fail"}`
|
|
34219
|
+
});
|
|
34220
|
+
return verdict.inside;
|
|
34221
|
+
}
|
|
34222
|
+
case "triggered-by": {
|
|
34223
|
+
const named = cond.leafIds.map((id) => `"${id}"`).join(", ");
|
|
34224
|
+
if (state.trigger === "unknown") {
|
|
34225
|
+
state.unknown = true;
|
|
34226
|
+
out.push({
|
|
34227
|
+
path,
|
|
34228
|
+
kind: cond.kind,
|
|
34229
|
+
outcome: "fail",
|
|
34230
|
+
reason: `what started this run is not known here, so "triggered by ${named}" cannot be judged → fail`
|
|
34231
|
+
});
|
|
34232
|
+
return false;
|
|
34233
|
+
}
|
|
34234
|
+
const fired = state.trigger.leafId;
|
|
34235
|
+
const ok = fired !== null && cond.leafIds.includes(fired);
|
|
34236
|
+
out.push({
|
|
34237
|
+
path,
|
|
34238
|
+
kind: cond.kind,
|
|
34239
|
+
outcome: ok ? "pass" : "fail",
|
|
34240
|
+
reason: `${fired === null ? "no named trigger started this run" : `started by "${fired}"`}, wanted ${named} → ${ok ? "pass" : "fail"}`
|
|
34241
|
+
});
|
|
34242
|
+
return ok;
|
|
34243
|
+
}
|
|
33931
34244
|
case "not": {
|
|
33932
34245
|
const at = out.length;
|
|
33933
34246
|
out.push({
|
|
@@ -33986,13 +34299,17 @@ function evaluateWhenTree(when, reader, now, options = {}) {
|
|
|
33986
34299
|
firedPath: options.firedPath,
|
|
33987
34300
|
holds: options.holds,
|
|
33988
34301
|
unknown: false,
|
|
33989
|
-
holdDueInMs: void 0
|
|
34302
|
+
holdDueInMs: void 0,
|
|
34303
|
+
site: options.site,
|
|
34304
|
+
timeDueInMs: void 0,
|
|
34305
|
+
trigger: options.trigger ?? { leafId: options.firedPath === void 0 ? null : eventLeafIdAt(when, options.firedPath) }
|
|
33990
34306
|
};
|
|
33991
34307
|
return {
|
|
33992
34308
|
pass: evalNode(when, options.rootPath ?? "when", reader, now, nodes, state),
|
|
33993
34309
|
unknown: state.unknown,
|
|
33994
34310
|
nodes,
|
|
33995
|
-
...state.holdDueInMs === void 0 ? {} : { holdDueInMs: state.holdDueInMs }
|
|
34311
|
+
...state.holdDueInMs === void 0 ? {} : { holdDueInMs: state.holdDueInMs },
|
|
34312
|
+
...state.timeDueInMs === void 0 ? {} : { timeDueInMs: state.timeDueInMs }
|
|
33996
34313
|
};
|
|
33997
34314
|
}
|
|
33998
34315
|
/** Does any state leaf of the tree carry a `for`? */
|
|
@@ -34016,7 +34333,10 @@ function observeHoldLeaves(when, reader, now, holds, rootPath = "when") {
|
|
|
34016
34333
|
firedPath: void 0,
|
|
34017
34334
|
holds,
|
|
34018
34335
|
unknown: false,
|
|
34019
|
-
holdDueInMs: void 0
|
|
34336
|
+
holdDueInMs: void 0,
|
|
34337
|
+
site: void 0,
|
|
34338
|
+
timeDueInMs: void 0,
|
|
34339
|
+
trigger: "unknown"
|
|
34020
34340
|
};
|
|
34021
34341
|
evalNode(leaf, path, reader, now, [], state);
|
|
34022
34342
|
if (state.holdDueInMs !== void 0) due = due === void 0 ? state.holdDueInMs : Math.min(due, state.holdDueInMs);
|
|
@@ -34048,6 +34368,11 @@ var STATIONARY_DESCRIPTIONS = {
|
|
|
34048
34368
|
phase: "appeared or departed",
|
|
34049
34369
|
entryId: "the stopped object"
|
|
34050
34370
|
};
|
|
34371
|
+
var BECOMES_DESCRIPTIONS = {
|
|
34372
|
+
deviceId: "the device that changed",
|
|
34373
|
+
from: "the value before the change, empty when it is not known",
|
|
34374
|
+
to: "the value it changed to"
|
|
34375
|
+
};
|
|
34051
34376
|
function describe$1(descriptions) {
|
|
34052
34377
|
return Object.entries(descriptions).map(([name, description]) => ({
|
|
34053
34378
|
name,
|
|
@@ -34056,10 +34381,21 @@ function describe$1(descriptions) {
|
|
|
34056
34381
|
}
|
|
34057
34382
|
var DETECTION_VARIABLES = describe$1(DETECTION_DESCRIPTIONS);
|
|
34058
34383
|
var STATIONARY_VARIABLES = describe$1(STATIONARY_DESCRIPTIONS);
|
|
34384
|
+
var BECOMES_VARIABLES = describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
34385
|
+
...v,
|
|
34386
|
+
hintKey: "becomesDeviceId"
|
|
34387
|
+
} : v);
|
|
34388
|
+
/** A name two trigger kinds describe differently, said for both (a camera, or a device that changed). */
|
|
34389
|
+
var SHARED_VARIABLES = { deviceId: {
|
|
34390
|
+
name: "deviceId",
|
|
34391
|
+
description: "the device that started the run",
|
|
34392
|
+
hintKey: "triggerDeviceId"
|
|
34393
|
+
} };
|
|
34059
34394
|
/** What one event row kind provides; kinds that provide none are absent. */
|
|
34060
34395
|
function triggerLeafVariables(kind) {
|
|
34061
34396
|
if (kind === "detection") return DETECTION_VARIABLES;
|
|
34062
34397
|
if (kind === "stationary") return STATIONARY_VARIABLES;
|
|
34398
|
+
if (kind === "device-becomes") return BECOMES_VARIABLES;
|
|
34063
34399
|
return [];
|
|
34064
34400
|
}
|
|
34065
34401
|
/**
|
|
@@ -34074,7 +34410,9 @@ function triggerVariablesOf(when) {
|
|
|
34074
34410
|
});
|
|
34075
34411
|
const [first, ...rest] = perEvent;
|
|
34076
34412
|
if (first === void 0) return [];
|
|
34077
|
-
return first.filter((v) => rest.every((other) => other.some((o) => o.name === v.name)))
|
|
34413
|
+
return first.filter((v) => rest.every((other) => other.some((o) => o.name === v.name))).map((v) => {
|
|
34414
|
+
return rest.every((other) => other.some((o) => o.name === v.name && o.description === v.description)) ? v : SHARED_VARIABLES[v.name] ?? v;
|
|
34415
|
+
});
|
|
34078
34416
|
}
|
|
34079
34417
|
//#endregion
|
|
34080
34418
|
//#region src/automation/codegen.ts
|
|
@@ -34202,6 +34540,7 @@ function emitLeaf(trigger, path) {
|
|
|
34202
34540
|
cap: ${j(trigger.cap)},
|
|
34203
34541
|
field: ${j(trigger.fieldPath)},
|
|
34204
34542
|
to: toTraceScalar(effect.value),
|
|
34543
|
+
...(effect.kind === 'fire' ? { from: toTraceScalar(effect.from) } : {}),
|
|
34205
34544
|
...(effect.hold === undefined ? {} : { hold: effect.hold }),
|
|
34206
34545
|
}
|
|
34207
34546
|
if (effect.kind === 'fire') {
|
|
@@ -34325,7 +34664,7 @@ function emitGuard(action, index) {
|
|
|
34325
34664
|
const body = emitLeafBody(el);
|
|
34326
34665
|
return `{ meta: ${j(stepMetaOf(el))}, run: async (scope) => {\n${body ?? ""}\n } }`;
|
|
34327
34666
|
}).join(", ");
|
|
34328
|
-
return ` guard: () => evaluateCondition(${j(action.if)}, ${j(`actions.${index}.if`)}),${otherwise === "" ? "" : `\n otherwise: [${otherwise}],`}
|
|
34667
|
+
return ` guard: () => evaluateCondition(${j(action.if)}, ${j(`actions.${index}.if`)}, vars),${otherwise === "" ? "" : `\n otherwise: [${otherwise}],`}
|
|
34329
34668
|
`;
|
|
34330
34669
|
}
|
|
34331
34670
|
function emitAction(action, index) {
|
|
@@ -34375,6 +34714,7 @@ function generateAutomationBlock(input) {
|
|
|
34375
34714
|
path: `actions.${i}.if`,
|
|
34376
34715
|
when: a.if
|
|
34377
34716
|
}] : []);
|
|
34717
|
+
const hasTime = hasTimeLeaves(recipe.when) || recipe.actions.some((a) => (a.kind === "wait" || a.kind === "cap") && a.if !== void 0 && hasTimeLeaves(a.if));
|
|
34378
34718
|
const eventLeaves = [];
|
|
34379
34719
|
forEachLeaf(recipe.when, (leaf, path) => {
|
|
34380
34720
|
if (isEventLeaf(leaf)) eventLeaves.push({
|
|
@@ -34392,6 +34732,7 @@ function generateAutomationBlock(input) {
|
|
|
34392
34732
|
AutomationStepTrace,
|
|
34393
34733
|
RunnableStep,
|
|
34394
34734
|
StepScope,
|
|
34735
|
+
TimeSite,
|
|
34395
34736
|
TimeSpec,
|
|
34396
34737
|
WeekdayKey,
|
|
34397
34738
|
} from '@camstack/types'
|
|
@@ -34410,9 +34751,11 @@ import {
|
|
|
34410
34751
|
describeHold,
|
|
34411
34752
|
evaluateWhenTree,
|
|
34412
34753
|
evaluateStationaryTrigger,
|
|
34754
|
+
eventLeafIdAt,
|
|
34413
34755
|
isSkippedTrace,
|
|
34414
34756
|
mergeSkipTraces,
|
|
34415
34757
|
nextOccurrence,
|
|
34758
|
+
nextTimeBoundaryInMs,
|
|
34416
34759
|
observeHoldLeaves,
|
|
34417
34760
|
stableIdMapOf,
|
|
34418
34761
|
resolveStepArgs,
|
|
@@ -34420,6 +34763,7 @@ import {
|
|
|
34420
34763
|
runForDevices,
|
|
34421
34764
|
evaluateStepCondition,
|
|
34422
34765
|
runSteps,
|
|
34766
|
+
siteFor,
|
|
34423
34767
|
validateTimeSpecForSite,
|
|
34424
34768
|
zoneOnlySite,
|
|
34425
34769
|
} from '@camstack/types'
|
|
@@ -34461,6 +34805,9 @@ const HAS_DOMAIN_TARGET = ${hasDomainTarget}
|
|
|
34461
34805
|
/** A state leaf of the tree carries a \`for\`: its clock is fed on every mirror update, so it counts while nothing fires. */
|
|
34462
34806
|
const HAS_HOLD = ${hasHoldLeaves(recipe.when)}
|
|
34463
34807
|
|
|
34808
|
+
/** A \`time-is\` leaf (in the tree or a guard) reads the site clock: the site is kept in memory and a timer wakes the tree at each boundary. */
|
|
34809
|
+
const HAS_TIME = ${hasTime}
|
|
34810
|
+
|
|
34464
34811
|
/** Guards (a step's \`if\`) with a \`for\`: they keep their own mirror and clocks, fed the same way. */
|
|
34465
34812
|
const GUARD_HOLD_TREES: ReadonlyArray<{ path: string; when: AutomationWhen }> = ${j(guardHoldTrees)}
|
|
34466
34813
|
|
|
@@ -34526,7 +34873,9 @@ export default function block(ctx: AddonContext) {
|
|
|
34526
34873
|
)
|
|
34527
34874
|
const guardHolds = new HoldTracker()
|
|
34528
34875
|
let holdTimer: ReturnType<typeof setTimeout> | undefined
|
|
34529
|
-
|
|
34876
|
+
${hasTime ? ` /** The site clock a \`time-is\` leaf reads: memory only at evaluation time (D49), refreshed at start and on the reconcile. */
|
|
34877
|
+
let site: TimeSite | undefined
|
|
34878
|
+
` : ""} const BLOCK_ID = coreBlockIdFromAddonId(ctx.id)
|
|
34530
34879
|
/** The cooldown stamp: memory is the authority at fire time (D49); the hub ledger is read once at start. */
|
|
34531
34880
|
let lastRunStartedAt: number | null = null
|
|
34532
34881
|
/** True when the stamp could not be read at start — the first run is let through and says so. */
|
|
@@ -34623,7 +34972,19 @@ export default function block(ctx: AddonContext) {
|
|
|
34623
34972
|
void send({ trace })
|
|
34624
34973
|
}
|
|
34625
34974
|
|
|
34626
|
-
|
|
34975
|
+
${hasTime ? ` /** Read the site into memory. A failed read keeps the previous value (D49). */
|
|
34976
|
+
async function refreshSite(): Promise<void> {
|
|
34977
|
+
try {
|
|
34978
|
+
const reading = await ctx.api.system.getSiteLocation.query()
|
|
34979
|
+
site = siteFor(reading) ?? zoneOnlySite(reading.timeZone)
|
|
34980
|
+
} catch (error) {
|
|
34981
|
+
ctx.logger.warn('site clock not refreshed — keeping the previous one', {
|
|
34982
|
+
error: error instanceof Error ? error.message : String(error),
|
|
34983
|
+
})
|
|
34984
|
+
}
|
|
34985
|
+
}
|
|
34986
|
+
|
|
34987
|
+
` : ""} // ── the condition mirror (D49): memory only at fire time ──
|
|
34627
34988
|
async function refreshMirror(): Promise<void> {
|
|
34628
34989
|
const report = await mirror.refresh({
|
|
34629
34990
|
fetchSlice: (deviceId, cap) => ctx.api.deviceState.getCapSlice.query({ deviceId, capName: cap }),
|
|
@@ -34662,7 +35023,10 @@ export default function block(ctx: AddonContext) {
|
|
|
34662
35023
|
const due = observeHoldLeaves(tree.when, guardMirror, now, guardHolds, tree.path)
|
|
34663
35024
|
if (due !== undefined) dues.push(due)
|
|
34664
35025
|
}
|
|
34665
|
-
|
|
35026
|
+
${hasTime ? ` // a time-is leaf changes sides at a boundary with no device event: wake the tree there
|
|
35027
|
+
const timeDue = nextTimeBoundaryInMs(WHEN, now, site)
|
|
35028
|
+
if (timeDue !== undefined) dues.push(timeDue)
|
|
35029
|
+
` : ""} if (holdTimer !== undefined) clearTimeout(holdTimer)
|
|
34666
35030
|
holdTimer = undefined
|
|
34667
35031
|
if (dues.length === 0) return
|
|
34668
35032
|
holdTimer = setTimeout(() => {
|
|
@@ -34835,11 +35199,14 @@ export default function block(ctx: AddonContext) {
|
|
|
34835
35199
|
}
|
|
34836
35200
|
|
|
34837
35201
|
/** A step's \`if\` (#472), read on a mirror filled for exactly its leaves, NOW (D49: unread = unknown). */
|
|
34838
|
-
function evaluateCondition(when: AutomationWhen, path: string) {
|
|
35202
|
+
function evaluateCondition(when: AutomationWhen, path: string, vars: Record<string, unknown>) {
|
|
35203
|
+
// \`triggered-by\` reads the run: the id of the leaf that started it, by the path the trigger carries.
|
|
35204
|
+
const firedLeaf = vars['leaf']
|
|
35205
|
+
const trigger = { leafId: typeof firedLeaf === 'string' ? eventLeafIdAt(WHEN, firedLeaf) : null }
|
|
34839
35206
|
const history = GUARD_HOLD_TREES.some((t) => t.path === path)
|
|
34840
35207
|
? { mirror: guardMirror, holds: guardHolds, rootPath: path }
|
|
34841
35208
|
: undefined
|
|
34842
|
-
return evaluateStepCondition(when, mirrorFetchers(), Date.now, history)
|
|
35209
|
+
return evaluateStepCondition(when, mirrorFetchers(), Date.now, history, ${hasTime ? "site" : "undefined"}, trigger)
|
|
34843
35210
|
}
|
|
34844
35211
|
|
|
34845
35212
|
/** The THEN half, through the ONE shared step runner: stops at the first
|
|
@@ -34926,7 +35293,7 @@ ${recipe.actions.map((a, i) => emitAction(a, i)).join("\n")}
|
|
|
34926
35293
|
try {
|
|
34927
35294
|
const firedLeaf = trigger['leaf']
|
|
34928
35295
|
const evaluation = evaluateWhenTree(WHEN, mirror, Date.now(), {
|
|
34929
|
-
holds,
|
|
35296
|
+
holds,${hasTime ? "\n ...(site === undefined ? {} : { site })," : ""}
|
|
34930
35297
|
...(typeof firedLeaf === 'string' ? { firedPath: firedLeaf } : {}),
|
|
34931
35298
|
})
|
|
34932
35299
|
nodes = [...evaluation.nodes]
|
|
@@ -35040,7 +35407,7 @@ ${recipe.actions.map((a, i) => emitAction(a, i)).join("\n")}
|
|
|
35040
35407
|
|
|
35041
35408
|
const ready: Promise<void> = (async () => {
|
|
35042
35409
|
await loadState()
|
|
35043
|
-
await refreshMirror()
|
|
35410
|
+
${hasTime ? " await refreshSite()\n" : ""} await refreshMirror()
|
|
35044
35411
|
feedHolds()
|
|
35045
35412
|
stateWatching = true
|
|
35046
35413
|
evaluateStateTree()
|
|
@@ -35056,7 +35423,7 @@ ${recipe.actions.map((a, i) => emitAction(a, i)).join("\n")}
|
|
|
35056
35423
|
let stateWatching = false
|
|
35057
35424
|
function evaluateStateTree(): void {
|
|
35058
35425
|
if (!STATE_ONLY || !stateWatching || stopped) return
|
|
35059
|
-
const evaluation = evaluateWhenTree(WHEN, mirror, Date.now(), { holds })
|
|
35426
|
+
const evaluation = evaluateWhenTree(WHEN, mirror, Date.now(), { holds${hasTime ? ", ...(site === undefined ? {} : { site })" : ""} })
|
|
35060
35427
|
if (evaluation.unknown) return
|
|
35061
35428
|
const was = treeWasTrue
|
|
35062
35429
|
treeWasTrue = evaluation.pass
|
|
@@ -35065,7 +35432,7 @@ ${recipe.actions.map((a, i) => emitAction(a, i)).join("\n")}
|
|
|
35065
35432
|
}
|
|
35066
35433
|
}
|
|
35067
35434
|
|
|
35068
|
-
if (MIRROR_SOURCES.length > 0 || GUARD_HOLD_TREES.length > 0) {
|
|
35435
|
+
if (MIRROR_SOURCES.length > 0 || GUARD_HOLD_TREES.length > 0 || HAS_TIME) {
|
|
35069
35436
|
disposers.push(
|
|
35070
35437
|
ctx.eventBus.subscribe({ category: EventCategory.DeviceStateChanged }, (event) => {
|
|
35071
35438
|
const data = event.data
|
|
@@ -35080,7 +35447,7 @@ ${recipe.actions.map((a, i) => emitAction(a, i)).join("\n")}
|
|
|
35080
35447
|
}),
|
|
35081
35448
|
)
|
|
35082
35449
|
const mirrorReconcile = setInterval(() => {
|
|
35083
|
-
void refreshMirror().then(() => {
|
|
35450
|
+
void ${hasTime ? "Promise.all([refreshSite(), refreshMirror()])" : "refreshMirror()"}.then(() => {
|
|
35084
35451
|
feedHolds()
|
|
35085
35452
|
evaluateStateTree()
|
|
35086
35453
|
})
|
|
@@ -35411,6 +35778,40 @@ var RunGate = class {
|
|
|
35411
35778
|
}
|
|
35412
35779
|
};
|
|
35413
35780
|
//#endregion
|
|
35781
|
+
//#region src/automation/when-site.ts
|
|
35782
|
+
/**
|
|
35783
|
+
* Save-time check of a `when` tree against the SITE: a `time-is` window
|
|
35784
|
+
* bounded by a sun event needs the site location, and any window needs a known
|
|
35785
|
+
* time zone. Refused before the save with a typed reason — at run time the
|
|
35786
|
+
* same leaf can only read `unknown`, and a rule that never decides is a rule
|
|
35787
|
+
* the operator believes is working. Pure: the site reading is handed in.
|
|
35788
|
+
*/
|
|
35789
|
+
var WINDOW_ENDS = ["from", "to"];
|
|
35790
|
+
/** Every `time-is` window end of the tree this site cannot place. `rootPath` replaces the leading `when`. */
|
|
35791
|
+
function whenSiteIssues(when, reading, rootPath = "when") {
|
|
35792
|
+
const issues = [];
|
|
35793
|
+
forEachLeaf(when, (leaf, path) => {
|
|
35794
|
+
if (leaf.kind !== "time-is" || leaf.between === void 0) return;
|
|
35795
|
+
for (const end of WINDOW_ENDS) {
|
|
35796
|
+
const checked = validateTimeSpecForSite(leaf.between[end], reading);
|
|
35797
|
+
if (!checked.ok) issues.push({
|
|
35798
|
+
path: `${path}.between.${end}`,
|
|
35799
|
+
reason: checked.reason,
|
|
35800
|
+
message: checked.message
|
|
35801
|
+
});
|
|
35802
|
+
}
|
|
35803
|
+
}, rootPath);
|
|
35804
|
+
return issues;
|
|
35805
|
+
}
|
|
35806
|
+
/** The same check over the guard (`if`) of every step of a list, reported under `<rootPath>.<i>.if`. */
|
|
35807
|
+
function stepGuardSiteIssues(steps, reading, rootPath) {
|
|
35808
|
+
return steps.flatMap((step, i) => step.if === void 0 ? [] : whenSiteIssues(step.if, reading, `${rootPath}.${i}.if`));
|
|
35809
|
+
}
|
|
35810
|
+
/** The whole recipe: its `when` tree and every step guard. */
|
|
35811
|
+
function recipeSiteIssues(recipe, reading) {
|
|
35812
|
+
return [...whenSiteIssues(recipe.when, reading), ...stepGuardSiteIssues(recipe.actions, reading, "actions")];
|
|
35813
|
+
}
|
|
35814
|
+
//#endregion
|
|
35414
35815
|
//#region src/automation/scheduler.ts
|
|
35415
35816
|
/**
|
|
35416
35817
|
* Schedulers (D983) — an entity that performs actions over the day.
|
|
@@ -35435,6 +35836,13 @@ var SchedulerStateTreeSchema = AutomationWhenSchema.superRefine((when, ctx) => {
|
|
|
35435
35836
|
});
|
|
35436
35837
|
return;
|
|
35437
35838
|
}
|
|
35839
|
+
if (hasTriggeredByLeaves(when)) {
|
|
35840
|
+
ctx.addIssue({
|
|
35841
|
+
code: "custom",
|
|
35842
|
+
message: TRIGGERED_BY_NEEDS_AUTOMATION
|
|
35843
|
+
});
|
|
35844
|
+
return;
|
|
35845
|
+
}
|
|
35438
35846
|
const problem = validateWhenTree(when);
|
|
35439
35847
|
if (problem !== null) ctx.addIssue({
|
|
35440
35848
|
code: "custom",
|
|
@@ -35526,10 +35934,20 @@ function holdRefusalOf(step) {
|
|
|
35526
35934
|
*/
|
|
35527
35935
|
function validateSchedulerInput(input, reading) {
|
|
35528
35936
|
const issues = [];
|
|
35937
|
+
const siteIssues = (found) => {
|
|
35938
|
+
for (const issue of found) issues.push({
|
|
35939
|
+
path: issue.path,
|
|
35940
|
+
message: issue.message
|
|
35941
|
+
});
|
|
35942
|
+
};
|
|
35943
|
+
if (input.activeWhen !== void 0) siteIssues(whenSiteIssues(input.activeWhen, reading, "activeWhen"));
|
|
35529
35944
|
input.profiles.forEach((profile, pi) => {
|
|
35530
35945
|
const ids = /* @__PURE__ */ new Set();
|
|
35946
|
+
if (profile.activeWhen !== void 0) siteIssues(whenSiteIssues(profile.activeWhen, reading, `profiles.${pi}.activeWhen`));
|
|
35531
35947
|
profile.points.forEach((point, qi) => {
|
|
35532
35948
|
const base = `profiles.${pi}.points.${qi}`;
|
|
35949
|
+
if (point.conditions !== void 0) siteIssues(whenSiteIssues(point.conditions, reading, `${base}.conditions`));
|
|
35950
|
+
siteIssues(stepGuardSiteIssues(point.steps, reading, `${base}.steps`));
|
|
35533
35951
|
if (ids.has(point.id)) issues.push({
|
|
35534
35952
|
path: `${base}.id`,
|
|
35535
35953
|
message: `point id "${point.id}" is used twice`
|
|
@@ -35755,6 +36173,8 @@ var AutomationConditionTraceNodeSchema = zod.z.object({
|
|
|
35755
36173
|
"device-is",
|
|
35756
36174
|
"expression",
|
|
35757
36175
|
"stationary-present",
|
|
36176
|
+
"time-is",
|
|
36177
|
+
"triggered-by",
|
|
35758
36178
|
"device-becomes",
|
|
35759
36179
|
"device-event",
|
|
35760
36180
|
"schedule",
|
|
@@ -36217,21 +36637,18 @@ var ActionRunChangedSchema = zod.z.object({
|
|
|
36217
36637
|
});
|
|
36218
36638
|
//#endregion
|
|
36219
36639
|
//#region src/automation/step-condition.ts
|
|
36220
|
-
/**
|
|
36221
|
-
* The guard of a conditional step (#472): the step's `if` is the ONE `when`
|
|
36222
|
-
* tree (D980), read on a {@link ConditionMirror} filled for exactly the leaves
|
|
36223
|
-
* the tree names, at the moment the step is reached. A state that cannot be
|
|
36224
|
-
* read is UNKNOWN, and unknown runs neither side (D49: a failed read changes
|
|
36225
|
-
* nothing, and never decides a branch).
|
|
36226
|
-
*/
|
|
36227
36640
|
/** Fill a mirror for the tree's leaves from `fetchers` and judge it NOW. */
|
|
36228
|
-
async function evaluateStepCondition(when, fetchers, now = Date.now, history) {
|
|
36641
|
+
async function evaluateStepCondition(when, fetchers, now = Date.now, history, site, trigger) {
|
|
36229
36642
|
const mirror = history?.mirror ?? new ConditionMirror(collectWhenMirrorSources(when));
|
|
36230
36643
|
await mirror.refresh(fetchers);
|
|
36231
|
-
const evaluation = evaluateWhenTree(when, mirror, now(), {
|
|
36232
|
-
|
|
36233
|
-
|
|
36234
|
-
|
|
36644
|
+
const evaluation = evaluateWhenTree(when, mirror, now(), {
|
|
36645
|
+
...history === void 0 ? {} : {
|
|
36646
|
+
holds: history.holds,
|
|
36647
|
+
rootPath: history.rootPath
|
|
36648
|
+
},
|
|
36649
|
+
...site === void 0 ? {} : { site },
|
|
36650
|
+
trigger: trigger ?? "unknown"
|
|
36651
|
+
});
|
|
36235
36652
|
const first = evaluation.nodes.filter((n) => n.outcome !== "pass").map((n) => n.reason)[0];
|
|
36236
36653
|
if (evaluation.unknown) return {
|
|
36237
36654
|
result: "unknown",
|
|
@@ -37205,6 +37622,60 @@ var AUTOMATION_LEAF_CATALOG = {
|
|
|
37205
37622
|
deviceId: 0
|
|
37206
37623
|
})
|
|
37207
37624
|
},
|
|
37625
|
+
"time-is": {
|
|
37626
|
+
kind: "time-is",
|
|
37627
|
+
category: "time",
|
|
37628
|
+
role: "state",
|
|
37629
|
+
allowedIn: STATE_CONTEXTS,
|
|
37630
|
+
i18nKey: "automation.leafCatalog.time-is",
|
|
37631
|
+
keywords: [
|
|
37632
|
+
"time",
|
|
37633
|
+
"hour",
|
|
37634
|
+
"window",
|
|
37635
|
+
"between",
|
|
37636
|
+
"night",
|
|
37637
|
+
"day",
|
|
37638
|
+
"weekday",
|
|
37639
|
+
"sunset",
|
|
37640
|
+
"sunrise"
|
|
37641
|
+
],
|
|
37642
|
+
needsDeviceValue: false,
|
|
37643
|
+
seed: () => ({
|
|
37644
|
+
kind: "time-is",
|
|
37645
|
+
between: {
|
|
37646
|
+
from: {
|
|
37647
|
+
kind: "clock",
|
|
37648
|
+
hh: 22,
|
|
37649
|
+
mm: 0
|
|
37650
|
+
},
|
|
37651
|
+
to: {
|
|
37652
|
+
kind: "clock",
|
|
37653
|
+
hh: 6,
|
|
37654
|
+
mm: 0
|
|
37655
|
+
}
|
|
37656
|
+
}
|
|
37657
|
+
})
|
|
37658
|
+
},
|
|
37659
|
+
"triggered-by": {
|
|
37660
|
+
kind: "triggered-by",
|
|
37661
|
+
category: "logic",
|
|
37662
|
+
role: "state",
|
|
37663
|
+
allowedIn: STATE_CONTEXTS,
|
|
37664
|
+
i18nKey: "automation.leafCatalog.triggered-by",
|
|
37665
|
+
keywords: [
|
|
37666
|
+
"trigger",
|
|
37667
|
+
"triggered",
|
|
37668
|
+
"started",
|
|
37669
|
+
"which",
|
|
37670
|
+
"branch",
|
|
37671
|
+
"fired"
|
|
37672
|
+
],
|
|
37673
|
+
needsDeviceValue: false,
|
|
37674
|
+
seed: () => ({
|
|
37675
|
+
kind: "triggered-by",
|
|
37676
|
+
leafIds: []
|
|
37677
|
+
})
|
|
37678
|
+
},
|
|
37208
37679
|
expression: {
|
|
37209
37680
|
kind: "expression",
|
|
37210
37681
|
category: "logic",
|
|
@@ -37239,6 +37710,8 @@ var AUTOMATION_LEAF_KINDS = [
|
|
|
37239
37710
|
"manual",
|
|
37240
37711
|
"device-is",
|
|
37241
37712
|
"stationary-present",
|
|
37713
|
+
"time-is",
|
|
37714
|
+
"triggered-by",
|
|
37242
37715
|
"expression"
|
|
37243
37716
|
];
|
|
37244
37717
|
function leafCatalogEntry(kind) {
|
|
@@ -37483,7 +37956,7 @@ var accessoriesCapability = {
|
|
|
37483
37956
|
require_composed_stable_id.DeviceType.Switch,
|
|
37484
37957
|
require_composed_stable_id.DeviceType.Light,
|
|
37485
37958
|
require_composed_stable_id.DeviceType.Sensor,
|
|
37486
|
-
require_composed_stable_id.DeviceType.
|
|
37959
|
+
require_composed_stable_id.DeviceType.Climate,
|
|
37487
37960
|
require_composed_stable_id.DeviceType.Cover,
|
|
37488
37961
|
require_composed_stable_id.DeviceType.Lock,
|
|
37489
37962
|
require_composed_stable_id.DeviceType.Fan,
|
|
@@ -40612,7 +41085,7 @@ var BATTERY_DEVICE_TYPES = [
|
|
|
40612
41085
|
require_composed_stable_id.DeviceType.Switch,
|
|
40613
41086
|
require_composed_stable_id.DeviceType.PetFeeder,
|
|
40614
41087
|
require_composed_stable_id.DeviceType.Container,
|
|
40615
|
-
require_composed_stable_id.DeviceType.
|
|
41088
|
+
require_composed_stable_id.DeviceType.Climate,
|
|
40616
41089
|
require_composed_stable_id.DeviceType.EventEmitter
|
|
40617
41090
|
];
|
|
40618
41091
|
/** Generic Customize target for the percentage reading (D936). */
|
|
@@ -42883,7 +43356,14 @@ var climateControlCapability = {
|
|
|
42883
43356
|
scope: "device",
|
|
42884
43357
|
deviceNative: true,
|
|
42885
43358
|
mode: "singleton",
|
|
42886
|
-
deviceTypes: [require_composed_stable_id.DeviceType.
|
|
43359
|
+
deviceTypes: [require_composed_stable_id.DeviceType.Climate],
|
|
43360
|
+
power: {
|
|
43361
|
+
kind: "mode",
|
|
43362
|
+
field: "mode",
|
|
43363
|
+
offValue: "off",
|
|
43364
|
+
set: "setMode",
|
|
43365
|
+
lastField: "lastActiveMode"
|
|
43366
|
+
},
|
|
42887
43367
|
methods: {
|
|
42888
43368
|
setMode: require_sleep.method(zod.z.object({
|
|
42889
43369
|
deviceId: zod.z.number().int().nonnegative(),
|
|
@@ -43303,7 +43783,8 @@ function describeStateField(schema, path) {
|
|
|
43303
43783
|
kind: leaf.kind,
|
|
43304
43784
|
nullable: field.safeParse(null).success,
|
|
43305
43785
|
required: !field.safeParse(void 0).success,
|
|
43306
|
-
...leaf.enumValues === void 0 ? {} : { enumValues: leaf.enumValues }
|
|
43786
|
+
...leaf.enumValues === void 0 ? {} : { enumValues: leaf.enumValues },
|
|
43787
|
+
...leaf.unionMembers === void 0 ? {} : { unionMembers: leaf.unionMembers }
|
|
43307
43788
|
};
|
|
43308
43789
|
}
|
|
43309
43790
|
function describeTopLevelStateFields(schema) {
|
|
@@ -43426,6 +43907,7 @@ var CompositionProblemCodeSchema = zod.z.enum([
|
|
|
43426
43907
|
"nested-field",
|
|
43427
43908
|
"missing-field",
|
|
43428
43909
|
"kind-mismatch",
|
|
43910
|
+
"source-kind-mismatch",
|
|
43429
43911
|
"may-be-null",
|
|
43430
43912
|
"source-missing",
|
|
43431
43913
|
"source-unreadable",
|
|
@@ -43447,7 +43929,8 @@ var CompositionProblemCodeSchema = zod.z.enum([
|
|
|
43447
43929
|
"command-method-unknown",
|
|
43448
43930
|
"command-source-unknown",
|
|
43449
43931
|
"command-input-unknown",
|
|
43450
|
-
"command-input-missing"
|
|
43932
|
+
"command-input-missing",
|
|
43933
|
+
"power-source-is-actuator"
|
|
43451
43934
|
]);
|
|
43452
43935
|
/** One refusal, named (D391). `path` points into the composition, e.g. `features[0].fields.temperature`. */
|
|
43453
43936
|
var CompositionProblemSchema = zod.z.object({
|
|
@@ -44622,6 +45105,13 @@ var mediaPlayerCapability = {
|
|
|
44622
45105
|
deviceNative: true,
|
|
44623
45106
|
mode: "singleton",
|
|
44624
45107
|
deviceTypes: [require_composed_stable_id.DeviceType.MediaPlayer],
|
|
45108
|
+
power: {
|
|
45109
|
+
kind: "methods",
|
|
45110
|
+
field: "state",
|
|
45111
|
+
offValues: ["off", "standby"],
|
|
45112
|
+
on: "turnOn",
|
|
45113
|
+
off: "turnOff"
|
|
45114
|
+
},
|
|
44625
45115
|
methods: {
|
|
44626
45116
|
turnOn: require_sleep.optionalMethod(deviceOnly, zod.z.void(), {
|
|
44627
45117
|
kind: "mutation",
|
|
@@ -44756,7 +45246,7 @@ var mediaPlayerCapability = {
|
|
|
44756
45246
|
//#region src/generated/customize-catalog.ts
|
|
44757
45247
|
/**
|
|
44758
45248
|
* Customize catalog, projected from every `*.cap.ts` `customize` block.
|
|
44759
|
-
*
|
|
45249
|
+
* 11 caps. Field keys are `runtimeState` paths. No Zod.
|
|
44760
45250
|
*/
|
|
44761
45251
|
var CAP_CUSTOMIZE_CATALOG = {
|
|
44762
45252
|
"battery": {
|
|
@@ -44771,7 +45261,7 @@ var CAP_CUSTOMIZE_CATALOG = {
|
|
|
44771
45261
|
require_composed_stable_id.DeviceType.Switch,
|
|
44772
45262
|
require_composed_stable_id.DeviceType.PetFeeder,
|
|
44773
45263
|
require_composed_stable_id.DeviceType.Container,
|
|
44774
|
-
require_composed_stable_id.DeviceType.
|
|
45264
|
+
require_composed_stable_id.DeviceType.Climate,
|
|
44775
45265
|
require_composed_stable_id.DeviceType.EventEmitter
|
|
44776
45266
|
],
|
|
44777
45267
|
apply: "add",
|
|
@@ -44827,7 +45317,6 @@ var CAP_CUSTOMIZE_CATALOG = {
|
|
|
44827
45317
|
require_composed_stable_id.DeviceType.Siren,
|
|
44828
45318
|
require_composed_stable_id.DeviceType.Switch,
|
|
44829
45319
|
require_composed_stable_id.DeviceType.Sensor,
|
|
44830
|
-
require_composed_stable_id.DeviceType.Thermostat,
|
|
44831
45320
|
require_composed_stable_id.DeviceType.Climate,
|
|
44832
45321
|
require_composed_stable_id.DeviceType.Button,
|
|
44833
45322
|
require_composed_stable_id.DeviceType.EventEmitter,
|
|
@@ -44855,7 +45344,6 @@ var CAP_CUSTOMIZE_CATALOG = {
|
|
|
44855
45344
|
require_composed_stable_id.DeviceType.PetFountain,
|
|
44856
45345
|
require_composed_stable_id.DeviceType.Dishwasher,
|
|
44857
45346
|
require_composed_stable_id.DeviceType.Washer,
|
|
44858
|
-
require_composed_stable_id.DeviceType.Heater,
|
|
44859
45347
|
require_composed_stable_id.DeviceType.Dryer,
|
|
44860
45348
|
require_composed_stable_id.DeviceType.Gateway,
|
|
44861
45349
|
require_composed_stable_id.DeviceType.HeatPump
|
|
@@ -44989,6 +45477,247 @@ var CAP_CUSTOMIZE_CATALOG = {
|
|
|
44989
45477
|
debounceMs: 2e3
|
|
44990
45478
|
}]
|
|
44991
45479
|
},
|
|
45480
|
+
"fan-control": {
|
|
45481
|
+
version: 1,
|
|
45482
|
+
targets: [
|
|
45483
|
+
{
|
|
45484
|
+
id: "horizontal-oscillating",
|
|
45485
|
+
cardinality: "scalar",
|
|
45486
|
+
deviceTypes: [require_composed_stable_id.DeviceType.Fan],
|
|
45487
|
+
apply: "replace",
|
|
45488
|
+
vocabularyCap: "fan-control",
|
|
45489
|
+
vocabularyStateField: "oscillating",
|
|
45490
|
+
sources: [{
|
|
45491
|
+
kind: "switch",
|
|
45492
|
+
transformKinds: ["identity"],
|
|
45493
|
+
transforms: [{ kind: "identity" }]
|
|
45494
|
+
}],
|
|
45495
|
+
sourceReport: { status: "assignment-status" },
|
|
45496
|
+
advancedExpression: false,
|
|
45497
|
+
section: "oscillation-axes",
|
|
45498
|
+
path: "oscillationAxes.horizontal.oscillating",
|
|
45499
|
+
valueKind: "boolean",
|
|
45500
|
+
nullable: true
|
|
45501
|
+
},
|
|
45502
|
+
{
|
|
45503
|
+
id: "horizontal-angle",
|
|
45504
|
+
cardinality: "scalar",
|
|
45505
|
+
deviceTypes: [require_composed_stable_id.DeviceType.Fan],
|
|
45506
|
+
apply: "replace",
|
|
45507
|
+
vocabularyCap: "fan-control",
|
|
45508
|
+
sources: [{
|
|
45509
|
+
kind: "numeric",
|
|
45510
|
+
transformKinds: ["identity"],
|
|
45511
|
+
transforms: [{ kind: "identity" }]
|
|
45512
|
+
}],
|
|
45513
|
+
sourceReport: { status: "assignment-status" },
|
|
45514
|
+
advancedExpression: false,
|
|
45515
|
+
section: "oscillation-axes",
|
|
45516
|
+
path: "oscillationAxes.horizontal.angle",
|
|
45517
|
+
valueKind: "number",
|
|
45518
|
+
nullable: true,
|
|
45519
|
+
companions: [
|
|
45520
|
+
{
|
|
45521
|
+
kind: "source-field",
|
|
45522
|
+
path: "oscillationAxes.horizontal.min",
|
|
45523
|
+
field: "min"
|
|
45524
|
+
},
|
|
45525
|
+
{
|
|
45526
|
+
kind: "source-field",
|
|
45527
|
+
path: "oscillationAxes.horizontal.max",
|
|
45528
|
+
field: "max"
|
|
45529
|
+
},
|
|
45530
|
+
{
|
|
45531
|
+
kind: "source-field",
|
|
45532
|
+
path: "oscillationAxes.horizontal.step",
|
|
45533
|
+
field: "step"
|
|
45534
|
+
}
|
|
45535
|
+
]
|
|
45536
|
+
},
|
|
45537
|
+
{
|
|
45538
|
+
id: "horizontal-sweepFrom",
|
|
45539
|
+
cardinality: "scalar",
|
|
45540
|
+
deviceTypes: [require_composed_stable_id.DeviceType.Fan],
|
|
45541
|
+
apply: "replace",
|
|
45542
|
+
vocabularyCap: "fan-control",
|
|
45543
|
+
sources: [{
|
|
45544
|
+
kind: "numeric",
|
|
45545
|
+
transformKinds: ["identity"],
|
|
45546
|
+
transforms: [{ kind: "identity" }]
|
|
45547
|
+
}],
|
|
45548
|
+
sourceReport: { status: "assignment-status" },
|
|
45549
|
+
advancedExpression: false,
|
|
45550
|
+
section: "oscillation-axes",
|
|
45551
|
+
path: "oscillationAxes.horizontal.sweepFrom",
|
|
45552
|
+
valueKind: "number",
|
|
45553
|
+
nullable: true
|
|
45554
|
+
},
|
|
45555
|
+
{
|
|
45556
|
+
id: "horizontal-sweepTo",
|
|
45557
|
+
cardinality: "scalar",
|
|
45558
|
+
deviceTypes: [require_composed_stable_id.DeviceType.Fan],
|
|
45559
|
+
apply: "replace",
|
|
45560
|
+
vocabularyCap: "fan-control",
|
|
45561
|
+
sources: [{
|
|
45562
|
+
kind: "numeric",
|
|
45563
|
+
transformKinds: ["identity"],
|
|
45564
|
+
transforms: [{ kind: "identity" }]
|
|
45565
|
+
}],
|
|
45566
|
+
sourceReport: { status: "assignment-status" },
|
|
45567
|
+
advancedExpression: false,
|
|
45568
|
+
section: "oscillation-axes",
|
|
45569
|
+
path: "oscillationAxes.horizontal.sweepTo",
|
|
45570
|
+
valueKind: "number",
|
|
45571
|
+
nullable: true
|
|
45572
|
+
},
|
|
45573
|
+
{
|
|
45574
|
+
id: "vertical-oscillating",
|
|
45575
|
+
cardinality: "scalar",
|
|
45576
|
+
deviceTypes: [require_composed_stable_id.DeviceType.Fan],
|
|
45577
|
+
apply: "replace",
|
|
45578
|
+
vocabularyCap: "fan-control",
|
|
45579
|
+
vocabularyStateField: "oscillating",
|
|
45580
|
+
sources: [{
|
|
45581
|
+
kind: "switch",
|
|
45582
|
+
transformKinds: ["identity"],
|
|
45583
|
+
transforms: [{ kind: "identity" }]
|
|
45584
|
+
}],
|
|
45585
|
+
sourceReport: { status: "assignment-status" },
|
|
45586
|
+
advancedExpression: false,
|
|
45587
|
+
section: "oscillation-axes",
|
|
45588
|
+
path: "oscillationAxes.vertical.oscillating",
|
|
45589
|
+
valueKind: "boolean",
|
|
45590
|
+
nullable: true
|
|
45591
|
+
},
|
|
45592
|
+
{
|
|
45593
|
+
id: "vertical-angle",
|
|
45594
|
+
cardinality: "scalar",
|
|
45595
|
+
deviceTypes: [require_composed_stable_id.DeviceType.Fan],
|
|
45596
|
+
apply: "replace",
|
|
45597
|
+
vocabularyCap: "fan-control",
|
|
45598
|
+
sources: [{
|
|
45599
|
+
kind: "numeric",
|
|
45600
|
+
transformKinds: ["identity"],
|
|
45601
|
+
transforms: [{ kind: "identity" }]
|
|
45602
|
+
}],
|
|
45603
|
+
sourceReport: { status: "assignment-status" },
|
|
45604
|
+
advancedExpression: false,
|
|
45605
|
+
section: "oscillation-axes",
|
|
45606
|
+
path: "oscillationAxes.vertical.angle",
|
|
45607
|
+
valueKind: "number",
|
|
45608
|
+
nullable: true,
|
|
45609
|
+
companions: [
|
|
45610
|
+
{
|
|
45611
|
+
kind: "source-field",
|
|
45612
|
+
path: "oscillationAxes.vertical.min",
|
|
45613
|
+
field: "min"
|
|
45614
|
+
},
|
|
45615
|
+
{
|
|
45616
|
+
kind: "source-field",
|
|
45617
|
+
path: "oscillationAxes.vertical.max",
|
|
45618
|
+
field: "max"
|
|
45619
|
+
},
|
|
45620
|
+
{
|
|
45621
|
+
kind: "source-field",
|
|
45622
|
+
path: "oscillationAxes.vertical.step",
|
|
45623
|
+
field: "step"
|
|
45624
|
+
}
|
|
45625
|
+
]
|
|
45626
|
+
},
|
|
45627
|
+
{
|
|
45628
|
+
id: "vertical-sweepFrom",
|
|
45629
|
+
cardinality: "scalar",
|
|
45630
|
+
deviceTypes: [require_composed_stable_id.DeviceType.Fan],
|
|
45631
|
+
apply: "replace",
|
|
45632
|
+
vocabularyCap: "fan-control",
|
|
45633
|
+
sources: [{
|
|
45634
|
+
kind: "numeric",
|
|
45635
|
+
transformKinds: ["identity"],
|
|
45636
|
+
transforms: [{ kind: "identity" }]
|
|
45637
|
+
}],
|
|
45638
|
+
sourceReport: { status: "assignment-status" },
|
|
45639
|
+
advancedExpression: false,
|
|
45640
|
+
section: "oscillation-axes",
|
|
45641
|
+
path: "oscillationAxes.vertical.sweepFrom",
|
|
45642
|
+
valueKind: "number",
|
|
45643
|
+
nullable: true
|
|
45644
|
+
},
|
|
45645
|
+
{
|
|
45646
|
+
id: "vertical-sweepTo",
|
|
45647
|
+
cardinality: "scalar",
|
|
45648
|
+
deviceTypes: [require_composed_stable_id.DeviceType.Fan],
|
|
45649
|
+
apply: "replace",
|
|
45650
|
+
vocabularyCap: "fan-control",
|
|
45651
|
+
sources: [{
|
|
45652
|
+
kind: "numeric",
|
|
45653
|
+
transformKinds: ["identity"],
|
|
45654
|
+
transforms: [{ kind: "identity" }]
|
|
45655
|
+
}],
|
|
45656
|
+
sourceReport: { status: "assignment-status" },
|
|
45657
|
+
advancedExpression: false,
|
|
45658
|
+
section: "oscillation-axes",
|
|
45659
|
+
path: "oscillationAxes.vertical.sweepTo",
|
|
45660
|
+
valueKind: "number",
|
|
45661
|
+
nullable: true
|
|
45662
|
+
},
|
|
45663
|
+
{
|
|
45664
|
+
id: "preset",
|
|
45665
|
+
cardinality: "scalar",
|
|
45666
|
+
deviceTypes: [require_composed_stable_id.DeviceType.Fan],
|
|
45667
|
+
apply: "replace",
|
|
45668
|
+
vocabularyCap: "fan-control",
|
|
45669
|
+
sources: [{
|
|
45670
|
+
kind: "field",
|
|
45671
|
+
valueKinds: ["string"],
|
|
45672
|
+
transformKinds: ["identity"],
|
|
45673
|
+
transforms: [{ kind: "identity" }]
|
|
45674
|
+
}],
|
|
45675
|
+
sourceReport: { status: "assignment-status" },
|
|
45676
|
+
advancedExpression: false,
|
|
45677
|
+
path: "preset",
|
|
45678
|
+
valueKind: "string",
|
|
45679
|
+
nullable: false
|
|
45680
|
+
}
|
|
45681
|
+
],
|
|
45682
|
+
overridable: [
|
|
45683
|
+
{
|
|
45684
|
+
path: "oscillationAxes.horizontal.oscillating",
|
|
45685
|
+
by: "horizontal-oscillating"
|
|
45686
|
+
},
|
|
45687
|
+
{
|
|
45688
|
+
path: "oscillationAxes.horizontal.angle",
|
|
45689
|
+
by: "horizontal-angle"
|
|
45690
|
+
},
|
|
45691
|
+
{
|
|
45692
|
+
path: "oscillationAxes.horizontal.sweepFrom",
|
|
45693
|
+
by: "horizontal-sweepFrom"
|
|
45694
|
+
},
|
|
45695
|
+
{
|
|
45696
|
+
path: "oscillationAxes.horizontal.sweepTo",
|
|
45697
|
+
by: "horizontal-sweepTo"
|
|
45698
|
+
},
|
|
45699
|
+
{
|
|
45700
|
+
path: "oscillationAxes.vertical.oscillating",
|
|
45701
|
+
by: "vertical-oscillating"
|
|
45702
|
+
},
|
|
45703
|
+
{
|
|
45704
|
+
path: "oscillationAxes.vertical.angle",
|
|
45705
|
+
by: "vertical-angle"
|
|
45706
|
+
},
|
|
45707
|
+
{
|
|
45708
|
+
path: "oscillationAxes.vertical.sweepFrom",
|
|
45709
|
+
by: "vertical-sweepFrom"
|
|
45710
|
+
},
|
|
45711
|
+
{
|
|
45712
|
+
path: "oscillationAxes.vertical.sweepTo",
|
|
45713
|
+
by: "vertical-sweepTo"
|
|
45714
|
+
},
|
|
45715
|
+
{
|
|
45716
|
+
path: "preset",
|
|
45717
|
+
by: "preset"
|
|
45718
|
+
}
|
|
45719
|
+
]
|
|
45720
|
+
},
|
|
44992
45721
|
"fan-presets": {
|
|
44993
45722
|
version: 1,
|
|
44994
45723
|
targets: [{
|
|
@@ -45089,7 +45818,6 @@ var CAP_CUSTOMIZE_CATALOG = {
|
|
|
45089
45818
|
require_composed_stable_id.DeviceType.Light,
|
|
45090
45819
|
require_composed_stable_id.DeviceType.Fan,
|
|
45091
45820
|
require_composed_stable_id.DeviceType.Climate,
|
|
45092
|
-
require_composed_stable_id.DeviceType.Thermostat,
|
|
45093
45821
|
require_composed_stable_id.DeviceType.Humidifier,
|
|
45094
45822
|
require_composed_stable_id.DeviceType.WaterHeater,
|
|
45095
45823
|
require_composed_stable_id.DeviceType.MediaPlayer,
|
|
@@ -45098,8 +45826,7 @@ var CAP_CUSTOMIZE_CATALOG = {
|
|
|
45098
45826
|
require_composed_stable_id.DeviceType.Dishwasher,
|
|
45099
45827
|
require_composed_stable_id.DeviceType.Vacuum,
|
|
45100
45828
|
require_composed_stable_id.DeviceType.LawnMower,
|
|
45101
|
-
require_composed_stable_id.DeviceType.PetFeeder
|
|
45102
|
-
require_composed_stable_id.DeviceType.Heater
|
|
45829
|
+
require_composed_stable_id.DeviceType.PetFeeder
|
|
45103
45830
|
],
|
|
45104
45831
|
apply: "add",
|
|
45105
45832
|
vocabularyCap: "power-meter",
|
|
@@ -45129,7 +45856,6 @@ var CAP_CUSTOMIZE_CATALOG = {
|
|
|
45129
45856
|
require_composed_stable_id.DeviceType.Light,
|
|
45130
45857
|
require_composed_stable_id.DeviceType.Fan,
|
|
45131
45858
|
require_composed_stable_id.DeviceType.Climate,
|
|
45132
|
-
require_composed_stable_id.DeviceType.Thermostat,
|
|
45133
45859
|
require_composed_stable_id.DeviceType.Humidifier,
|
|
45134
45860
|
require_composed_stable_id.DeviceType.WaterHeater,
|
|
45135
45861
|
require_composed_stable_id.DeviceType.MediaPlayer,
|
|
@@ -45138,8 +45864,7 @@ var CAP_CUSTOMIZE_CATALOG = {
|
|
|
45138
45864
|
require_composed_stable_id.DeviceType.Dishwasher,
|
|
45139
45865
|
require_composed_stable_id.DeviceType.Vacuum,
|
|
45140
45866
|
require_composed_stable_id.DeviceType.LawnMower,
|
|
45141
|
-
require_composed_stable_id.DeviceType.PetFeeder
|
|
45142
|
-
require_composed_stable_id.DeviceType.Heater
|
|
45867
|
+
require_composed_stable_id.DeviceType.PetFeeder
|
|
45143
45868
|
],
|
|
45144
45869
|
apply: "add",
|
|
45145
45870
|
vocabularyCap: "power-meter",
|
|
@@ -45169,7 +45894,6 @@ var CAP_CUSTOMIZE_CATALOG = {
|
|
|
45169
45894
|
require_composed_stable_id.DeviceType.Light,
|
|
45170
45895
|
require_composed_stable_id.DeviceType.Fan,
|
|
45171
45896
|
require_composed_stable_id.DeviceType.Climate,
|
|
45172
|
-
require_composed_stable_id.DeviceType.Thermostat,
|
|
45173
45897
|
require_composed_stable_id.DeviceType.Humidifier,
|
|
45174
45898
|
require_composed_stable_id.DeviceType.WaterHeater,
|
|
45175
45899
|
require_composed_stable_id.DeviceType.MediaPlayer,
|
|
@@ -45178,8 +45902,7 @@ var CAP_CUSTOMIZE_CATALOG = {
|
|
|
45178
45902
|
require_composed_stable_id.DeviceType.Dishwasher,
|
|
45179
45903
|
require_composed_stable_id.DeviceType.Vacuum,
|
|
45180
45904
|
require_composed_stable_id.DeviceType.LawnMower,
|
|
45181
|
-
require_composed_stable_id.DeviceType.PetFeeder
|
|
45182
|
-
require_composed_stable_id.DeviceType.Heater
|
|
45905
|
+
require_composed_stable_id.DeviceType.PetFeeder
|
|
45183
45906
|
],
|
|
45184
45907
|
apply: "add",
|
|
45185
45908
|
vocabularyCap: "power-meter",
|
|
@@ -45209,7 +45932,6 @@ var CAP_CUSTOMIZE_CATALOG = {
|
|
|
45209
45932
|
require_composed_stable_id.DeviceType.Light,
|
|
45210
45933
|
require_composed_stable_id.DeviceType.Fan,
|
|
45211
45934
|
require_composed_stable_id.DeviceType.Climate,
|
|
45212
|
-
require_composed_stable_id.DeviceType.Thermostat,
|
|
45213
45935
|
require_composed_stable_id.DeviceType.Humidifier,
|
|
45214
45936
|
require_composed_stable_id.DeviceType.WaterHeater,
|
|
45215
45937
|
require_composed_stable_id.DeviceType.MediaPlayer,
|
|
@@ -45218,8 +45940,7 @@ var CAP_CUSTOMIZE_CATALOG = {
|
|
|
45218
45940
|
require_composed_stable_id.DeviceType.Dishwasher,
|
|
45219
45941
|
require_composed_stable_id.DeviceType.Vacuum,
|
|
45220
45942
|
require_composed_stable_id.DeviceType.LawnMower,
|
|
45221
|
-
require_composed_stable_id.DeviceType.PetFeeder
|
|
45222
|
-
require_composed_stable_id.DeviceType.Heater
|
|
45943
|
+
require_composed_stable_id.DeviceType.PetFeeder
|
|
45223
45944
|
],
|
|
45224
45945
|
apply: "add",
|
|
45225
45946
|
vocabularyCap: "power-meter",
|
|
@@ -45321,9 +46042,7 @@ var CAP_CUSTOMIZE_CATALOG = {
|
|
|
45321
46042
|
require_composed_stable_id.DeviceType.Humidifier,
|
|
45322
46043
|
require_composed_stable_id.DeviceType.Fan,
|
|
45323
46044
|
require_composed_stable_id.DeviceType.Climate,
|
|
45324
|
-
require_composed_stable_id.DeviceType.
|
|
45325
|
-
require_composed_stable_id.DeviceType.PetFeeder,
|
|
45326
|
-
require_composed_stable_id.DeviceType.Heater
|
|
46045
|
+
require_composed_stable_id.DeviceType.PetFeeder
|
|
45327
46046
|
],
|
|
45328
46047
|
apply: "add",
|
|
45329
46048
|
vocabularyCap: "running-state",
|
|
@@ -45642,12 +46361,37 @@ function readKinds(read, lookupCap) {
|
|
|
45642
46361
|
code: "source-field-unknown",
|
|
45643
46362
|
message: `\`${read.cap}\` has no field \`${read.fieldPath}\``
|
|
45644
46363
|
};
|
|
45645
|
-
const
|
|
46364
|
+
const bases = field.kind === "union" ? field.unionMembers ?? [] : [field.kind === "enum" ? "string" : field.kind];
|
|
45646
46365
|
return {
|
|
45647
46366
|
ok: true,
|
|
45648
|
-
kinds: new Set(field.nullable ? [
|
|
46367
|
+
kinds: new Set(field.nullable ? [...bases, "null"] : bases)
|
|
45649
46368
|
};
|
|
45650
46369
|
}
|
|
46370
|
+
/** A union field is read as a source (D1034), never written: no single kind to check a source against. */
|
|
46371
|
+
function unionTargetProblem(cap, path, at) {
|
|
46372
|
+
return problem("kind-mismatch", at, `\`${cap}.${path}\` is a union — it is read as a source, never written`);
|
|
46373
|
+
}
|
|
46374
|
+
/** The one value kind a target field accepts. */
|
|
46375
|
+
function acceptedKind(target) {
|
|
46376
|
+
if (target.kind === "union") return null;
|
|
46377
|
+
return target.kind === "enum" ? "string" : target.kind;
|
|
46378
|
+
}
|
|
46379
|
+
/**
|
|
46380
|
+
* A direct read of a UNION source field (D1034) is judged by the member that
|
|
46381
|
+
* fits the target: when one does, the read produces that kind only (a reading
|
|
46382
|
+
* of another kind is UNAVAILABLE at read time, never a coerced value); when
|
|
46383
|
+
* none does, the kinds stay as they are and `compatibility` names the mismatch.
|
|
46384
|
+
*/
|
|
46385
|
+
function narrowUnionRead(source, target, kinds, lookupCap) {
|
|
46386
|
+
if (source.kind !== "from") return kinds;
|
|
46387
|
+
const def = lookupCap(source.cap);
|
|
46388
|
+
const schema = def?.runtimeState ?? def?.status?.schema;
|
|
46389
|
+
if (schema === void 0) return kinds;
|
|
46390
|
+
const field = describeStateField(schema, source.fieldPath);
|
|
46391
|
+
const accepted = acceptedKind(target);
|
|
46392
|
+
if (field?.kind !== "union" || accepted === null || !kinds.has(accepted)) return kinds;
|
|
46393
|
+
return new Set(kinds.has("null") ? [accepted, "null"] : [accepted]);
|
|
46394
|
+
}
|
|
45651
46395
|
function sourceKinds(source, lookupCap) {
|
|
45652
46396
|
if (source.kind === "from") return readKinds(source, lookupCap);
|
|
45653
46397
|
if (source.kind === "code") return {
|
|
@@ -45684,7 +46428,8 @@ function sourceKinds(source, lookupCap) {
|
|
|
45684
46428
|
};
|
|
45685
46429
|
}
|
|
45686
46430
|
function compatibility(cap, target, kinds, at) {
|
|
45687
|
-
const allowed = target
|
|
46431
|
+
const allowed = acceptedKind(target);
|
|
46432
|
+
if (allowed === null) return [unionTargetProblem(cap, target.path, at)];
|
|
45688
46433
|
const offending = [...kinds].filter((k) => k !== "null" && k !== allowed);
|
|
45689
46434
|
const problems = [];
|
|
45690
46435
|
if (offending.length > 0) problems.push(problem("kind-mismatch", at, `\`${cap}.${target.path}\` is a ${target.kind}; this source can produce ${offending.join(" or ")}`));
|
|
@@ -45795,6 +46540,7 @@ function planItemField(ctx, leaf) {
|
|
|
45795
46540
|
if (ctx.reserved.has(path)) return refused(problem("item-field-reserved", at, `\`${capName}.${itemArray.path}[].${path}\` is set by the composer itself — it takes no source`));
|
|
45796
46541
|
const tf = describeStateField(itemArray.itemSchema, path);
|
|
45797
46542
|
if (tf === null) return refused(problem("unknown-field", at, `a \`${capName}\` item has no field \`${path}\``));
|
|
46543
|
+
if (tf.kind === "union") return refused(unionTargetProblem(capName, path, at));
|
|
45798
46544
|
const kinds = sourceKinds(source, lookupCap);
|
|
45799
46545
|
if (!kinds.ok) return refused(problem(kinds.code, at, kinds.message));
|
|
45800
46546
|
const role = roleOf(source);
|
|
@@ -45820,7 +46566,7 @@ function planItemField(ctx, leaf) {
|
|
|
45820
46566
|
};
|
|
45821
46567
|
const enumProblem = enumLiteralProblem(capName, tf, source, at);
|
|
45822
46568
|
return {
|
|
45823
|
-
problems: [...compatibility(capName, tf, kinds.kinds, at), ...enumProblem === null ? [] : [enumProblem]],
|
|
46569
|
+
problems: [...compatibility(capName, tf, narrowUnionRead(source, tf, kinds.kinds, lookupCap), at), ...enumProblem === null ? [] : [enumProblem]],
|
|
45824
46570
|
fields: [plan],
|
|
45825
46571
|
features: [],
|
|
45826
46572
|
events: []
|
|
@@ -46052,7 +46798,7 @@ function numeric(input) {
|
|
|
46052
46798
|
}, ...alsoFrom === void 0 ? [] : [alsoFrom.accept]]
|
|
46053
46799
|
};
|
|
46054
46800
|
}
|
|
46055
|
-
var CLIMATE_DEVICES = [require_composed_stable_id.DeviceType.
|
|
46801
|
+
var CLIMATE_DEVICES = [require_composed_stable_id.DeviceType.Climate];
|
|
46056
46802
|
function binary(input) {
|
|
46057
46803
|
return {
|
|
46058
46804
|
...input,
|
|
@@ -46374,8 +47120,8 @@ var GROUP_TEMPLATES = [
|
|
|
46374
47120
|
actuator({
|
|
46375
47121
|
id: "climate",
|
|
46376
47122
|
summary: "Running when at least one thermostat or air conditioner is not off, or only when all of them are. Target temperature and fan are offered only when every device has them. A device that reports nothing is left out, never read as off.",
|
|
46377
|
-
deviceType: require_composed_stable_id.DeviceType.
|
|
46378
|
-
memberDeviceTypes: [require_composed_stable_id.DeviceType.
|
|
47123
|
+
deviceType: require_composed_stable_id.DeviceType.Climate,
|
|
47124
|
+
memberDeviceTypes: [require_composed_stable_id.DeviceType.Climate],
|
|
46379
47125
|
outputCap: "group-active",
|
|
46380
47126
|
outputField: "active",
|
|
46381
47127
|
member: {
|
|
@@ -47839,6 +48585,233 @@ function findCandidateCycles(candidate, stored) {
|
|
|
47839
48585
|
});
|
|
47840
48586
|
}
|
|
47841
48587
|
//#endregion
|
|
48588
|
+
//#region src/capabilities/power-source.cap.ts
|
|
48589
|
+
/**
|
|
48590
|
+
* power-source — a device that hangs is powered by a smart switch, and the
|
|
48591
|
+
* operator picks that switch in the device's Customize. The device then offers
|
|
48592
|
+
* power on, power off and a forced restart (switch off, wait, switch on).
|
|
48593
|
+
*
|
|
48594
|
+
* Manual by default: nothing here restarts a device by itself. The one
|
|
48595
|
+
* exception (D997) is a device's OWN provider calling `forceRestart` for its own
|
|
48596
|
+
* device as a bounded self-recovery (unreachable for a long stretch, linked,
|
|
48597
|
+
* one attempt per cooldown, never with a live session); Velux is the first. It
|
|
48598
|
+
* is not the native `reboot` cap and never replaces or wraps it: `reboot` talks
|
|
48599
|
+
* to the device, this cuts the power of the device that no longer answers.
|
|
48600
|
+
*
|
|
48601
|
+
* The link is a Customize extension (`add`): one scalar target whose source is
|
|
48602
|
+
* the switch. The stored composition is the ONE copy of the link and of
|
|
48603
|
+
* `offSeconds` (`powerSourceLinkOfComposition`, D676); the composed slice only
|
|
48604
|
+
* mirrors the switch state for the UI. The methods are served by the
|
|
48605
|
+
* `core-blocks` system provider, so they are `systemMethod`s and carry a
|
|
48606
|
+
* top-level `deviceId`.
|
|
48607
|
+
*
|
|
48608
|
+
* Every action answers a typed result and never throws for an expected
|
|
48609
|
+
* refusal, so a caller tells "the switch is offline" from "a restart is
|
|
48610
|
+
* already running" without parsing text.
|
|
48611
|
+
*/
|
|
48612
|
+
/** Bounds of the off time of a forced restart, in seconds. */
|
|
48613
|
+
var POWER_SOURCE_OFF_SECONDS_MIN = 3;
|
|
48614
|
+
var POWER_SOURCE_OFF_SECONDS_MAX = 120;
|
|
48615
|
+
var POWER_SOURCE_OFF_SECONDS_DEFAULT = 10;
|
|
48616
|
+
var PowerSourceRefusalReasonSchema = zod.z.enum([
|
|
48617
|
+
"no-power-source",
|
|
48618
|
+
"switch-missing",
|
|
48619
|
+
"switch-offline",
|
|
48620
|
+
"switch-unknown",
|
|
48621
|
+
"restart-in-progress",
|
|
48622
|
+
"switch-call-failed",
|
|
48623
|
+
"switch-is-actuator"
|
|
48624
|
+
]);
|
|
48625
|
+
var PowerSourceActionResultSchema = zod.z.discriminatedUnion("accepted", [zod.z.object({ accepted: zod.z.literal(true) }), zod.z.object({
|
|
48626
|
+
accepted: zod.z.literal(false),
|
|
48627
|
+
reason: PowerSourceRefusalReasonSchema,
|
|
48628
|
+
/** One line for the operator, naming the switch. */
|
|
48629
|
+
message: zod.z.string()
|
|
48630
|
+
})]);
|
|
48631
|
+
var PowerSourceInfoSchema = zod.z.object({
|
|
48632
|
+
/** False when the device has no power source linked; the rest is then empty. */
|
|
48633
|
+
linked: zod.z.boolean(),
|
|
48634
|
+
switchDeviceId: zod.z.number().nullable(),
|
|
48635
|
+
switchName: zod.z.string().nullable(),
|
|
48636
|
+
/** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
|
|
48637
|
+
switchOn: zod.z.boolean().nullable(),
|
|
48638
|
+
switchOnline: zod.z.boolean().nullable(),
|
|
48639
|
+
restartInProgress: zod.z.boolean(),
|
|
48640
|
+
offSeconds: zod.z.number().int()
|
|
48641
|
+
});
|
|
48642
|
+
/** The composed slice: the switch state the link mirrors, plus the stored off time. */
|
|
48643
|
+
var PowerSourceStateSchema = zod.z.object({
|
|
48644
|
+
/** Null while the switch has not reported: unknown is never `false` (D393). */
|
|
48645
|
+
switchOn: zod.z.boolean().nullable(),
|
|
48646
|
+
offSeconds: zod.z.number().int(),
|
|
48647
|
+
lastFetchedAt: zod.z.number()
|
|
48648
|
+
});
|
|
48649
|
+
var POWER_SOURCE_DEVICE_TYPES = [
|
|
48650
|
+
require_composed_stable_id.DeviceType.Gateway,
|
|
48651
|
+
require_composed_stable_id.DeviceType.Camera,
|
|
48652
|
+
require_composed_stable_id.DeviceType.Sensor,
|
|
48653
|
+
require_composed_stable_id.DeviceType.MediaPlayer,
|
|
48654
|
+
require_composed_stable_id.DeviceType.Vacuum,
|
|
48655
|
+
require_composed_stable_id.DeviceType.Generic,
|
|
48656
|
+
require_composed_stable_id.DeviceType.Washer,
|
|
48657
|
+
require_composed_stable_id.DeviceType.Dryer,
|
|
48658
|
+
require_composed_stable_id.DeviceType.Dishwasher,
|
|
48659
|
+
require_composed_stable_id.DeviceType.PetFountain,
|
|
48660
|
+
require_composed_stable_id.DeviceType.Fan,
|
|
48661
|
+
require_composed_stable_id.DeviceType.Humidifier,
|
|
48662
|
+
require_composed_stable_id.DeviceType.Climate,
|
|
48663
|
+
require_composed_stable_id.DeviceType.WaterHeater
|
|
48664
|
+
];
|
|
48665
|
+
var powerSourceCustomize = {
|
|
48666
|
+
version: 1,
|
|
48667
|
+
targets: [{
|
|
48668
|
+
id: "switch",
|
|
48669
|
+
cardinality: "scalar",
|
|
48670
|
+
vocabulary: {
|
|
48671
|
+
cap: "power-source",
|
|
48672
|
+
stateField: "switchOn"
|
|
48673
|
+
},
|
|
48674
|
+
deviceTypes: POWER_SOURCE_DEVICE_TYPES,
|
|
48675
|
+
apply: "add",
|
|
48676
|
+
path: "switchOn",
|
|
48677
|
+
sources: [{
|
|
48678
|
+
kind: "switch",
|
|
48679
|
+
transforms: [{ kind: "identity" }]
|
|
48680
|
+
}],
|
|
48681
|
+
companions: [{
|
|
48682
|
+
kind: "constant",
|
|
48683
|
+
path: "offSeconds",
|
|
48684
|
+
value: 10,
|
|
48685
|
+
when: "add",
|
|
48686
|
+
formerValues: [0]
|
|
48687
|
+
}, {
|
|
48688
|
+
kind: "clock",
|
|
48689
|
+
path: "lastFetchedAt",
|
|
48690
|
+
when: "always"
|
|
48691
|
+
}],
|
|
48692
|
+
sourceReport: { status: "assignment-status" }
|
|
48693
|
+
}]
|
|
48694
|
+
};
|
|
48695
|
+
var deviceInput$2 = zod.z.object({ deviceId: zod.z.number().int().nonnegative() });
|
|
48696
|
+
var powerSourceCapability = {
|
|
48697
|
+
name: "power-source",
|
|
48698
|
+
scope: "device",
|
|
48699
|
+
mode: "singleton",
|
|
48700
|
+
deviceTypes: POWER_SOURCE_DEVICE_TYPES,
|
|
48701
|
+
methods: {
|
|
48702
|
+
getStatus: require_sleep.systemMethod(deviceInput$2, PowerSourceInfoSchema, { auth: "protected" }),
|
|
48703
|
+
powerOn: require_sleep.systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
|
|
48704
|
+
kind: "mutation",
|
|
48705
|
+
auth: "protected"
|
|
48706
|
+
}),
|
|
48707
|
+
powerOff: require_sleep.systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
|
|
48708
|
+
kind: "mutation",
|
|
48709
|
+
auth: "protected"
|
|
48710
|
+
}),
|
|
48711
|
+
forceRestart: require_sleep.systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
|
|
48712
|
+
kind: "mutation",
|
|
48713
|
+
auth: "protected"
|
|
48714
|
+
})
|
|
48715
|
+
},
|
|
48716
|
+
runtimeState: PowerSourceStateSchema,
|
|
48717
|
+
customize: powerSourceCustomize,
|
|
48718
|
+
/**
|
|
48719
|
+
* Runtime-state durability: **session** — mirrored from the linked switch on
|
|
48720
|
+
* its next report; a restored value would outlive the reading it names.
|
|
48721
|
+
*
|
|
48722
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
48723
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
48724
|
+
*/
|
|
48725
|
+
durability: "session",
|
|
48726
|
+
history: "none"
|
|
48727
|
+
};
|
|
48728
|
+
//#endregion
|
|
48729
|
+
//#region src/composition/power-source-link.ts
|
|
48730
|
+
/**
|
|
48731
|
+
* Which smart switch powers a device (the `power-source` Customize extension):
|
|
48732
|
+
* the source its stored `power-source.switchOn` field reads, and the off time of
|
|
48733
|
+
* a forced restart stored beside it. Read from the STORED composition, never kept
|
|
48734
|
+
* as a second copy (D676). Shared by the hub (which acts on the switch) and the
|
|
48735
|
+
* admin UI (which shows it).
|
|
48736
|
+
*/
|
|
48737
|
+
/**
|
|
48738
|
+
* The stored off time, or the default when none is stored. A stored number out
|
|
48739
|
+
* of range is CLAMPED to the bounds (a hand-written value never refuses the
|
|
48740
|
+
* link, it just cannot cut power for an absurd time); a non-integer is rounded.
|
|
48741
|
+
*/
|
|
48742
|
+
function normalizeOffSeconds(value) {
|
|
48743
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return 10;
|
|
48744
|
+
return Math.min(120, Math.max(3, Math.round(value)));
|
|
48745
|
+
}
|
|
48746
|
+
/** The constant a stored `offSeconds` field carries, or undefined when it is not a literal number. */
|
|
48747
|
+
function storedOffSeconds(composition) {
|
|
48748
|
+
const feature = composition.features.find((f) => f.cap === "power-source");
|
|
48749
|
+
if (feature === void 0 || feature.kind !== "fields") return void 0;
|
|
48750
|
+
const field = feature.fields["offSeconds"];
|
|
48751
|
+
if (field === void 0 || field.kind !== "expression") return void 0;
|
|
48752
|
+
const n = Number(field.expr);
|
|
48753
|
+
return field.expr.trim() === "" || !Number.isFinite(n) ? void 0 : n;
|
|
48754
|
+
}
|
|
48755
|
+
/**
|
|
48756
|
+
* The link a composition stores. An `existing` target names its own device; a
|
|
48757
|
+
* `new` target (a composed device) is the composer's own device, so the caller
|
|
48758
|
+
* passes the block id and a new-target composition without one has no link.
|
|
48759
|
+
*/
|
|
48760
|
+
function powerSourceLinkOfComposition(composition, blockId) {
|
|
48761
|
+
if (composition === null) return null;
|
|
48762
|
+
let device;
|
|
48763
|
+
if (composition.target.kind === "existing") device = composition.target.device;
|
|
48764
|
+
else if (blockId !== void 0) device = require_implemented_methods.composedDeviceRef(blockId);
|
|
48765
|
+
else return null;
|
|
48766
|
+
const feature = composition.features.find((f) => f.cap === "power-source");
|
|
48767
|
+
if (feature === void 0 || feature.kind !== "fields" || feature.enabled === false) return null;
|
|
48768
|
+
const field = feature.fields["switchOn"];
|
|
48769
|
+
if (field === void 0) return null;
|
|
48770
|
+
const read = require_implemented_methods.fieldReads(field).find((r) => r.cap === "switch");
|
|
48771
|
+
if (read === void 0) return null;
|
|
48772
|
+
return {
|
|
48773
|
+
device,
|
|
48774
|
+
switch: read.source,
|
|
48775
|
+
offSeconds: normalizeOffSeconds(storedOffSeconds(composition))
|
|
48776
|
+
};
|
|
48777
|
+
}
|
|
48778
|
+
var ACTUATOR_CAP = "switch";
|
|
48779
|
+
/**
|
|
48780
|
+
* The devices that ACT for this composition: the device itself when it is an
|
|
48781
|
+
* existing one, and every source its own `switch` feature reads or forwards a
|
|
48782
|
+
* command to (a heater's plug, every member of a switch group).
|
|
48783
|
+
*/
|
|
48784
|
+
function actuatorKeys(composition) {
|
|
48785
|
+
const keys = /* @__PURE__ */ new Set();
|
|
48786
|
+
if (composition.target.kind === "existing") keys.add(require_implemented_methods.compositionSourceKey(composition.target.device));
|
|
48787
|
+
composition.features.forEach((feature, index) => {
|
|
48788
|
+
if (feature.kind !== "fields" || feature.cap !== ACTUATOR_CAP) return;
|
|
48789
|
+
if (!require_implemented_methods.compositionFeatureEnabled(feature)) return;
|
|
48790
|
+
for (const source of require_implemented_methods.featureSources(feature)) for (const read of require_implemented_methods.fieldReads(source)) keys.add(require_implemented_methods.compositionSourceKey(read.source));
|
|
48791
|
+
for (const forward of featureForwards(feature, index)) keys.add(require_implemented_methods.compositionSourceKey(forward.command.source));
|
|
48792
|
+
});
|
|
48793
|
+
return keys;
|
|
48794
|
+
}
|
|
48795
|
+
/**
|
|
48796
|
+
* The supply plug is never one of the device's own actuators (#462): cutting
|
|
48797
|
+
* power through the switch that IS the device's on/off leaves nothing to
|
|
48798
|
+
* restart, and makes "power off" and "turn off" the same press. Refused at save
|
|
48799
|
+
* time (`power-source-is-actuator`) and again by the power-source provider for a
|
|
48800
|
+
* link stored before this check existed (`switch-is-actuator`).
|
|
48801
|
+
*/
|
|
48802
|
+
function powerSourceActuatorConflicts(composition) {
|
|
48803
|
+
const index = composition.features.findIndex((f) => f.cap === "power-source");
|
|
48804
|
+
const feature = composition.features[index];
|
|
48805
|
+
if (feature === void 0 || feature.kind !== "fields" || feature.enabled === false) return [];
|
|
48806
|
+
const field = feature.fields["switchOn"];
|
|
48807
|
+
if (field === void 0) return [];
|
|
48808
|
+
const actuators = actuatorKeys(composition);
|
|
48809
|
+
return require_implemented_methods.fieldReads(field).filter((read) => read.cap === ACTUATOR_CAP && actuators.has(require_implemented_methods.compositionSourceKey(read.source))).map((read) => ({
|
|
48810
|
+
path: `features[${index}].fields.switchOn`,
|
|
48811
|
+
switch: read.source
|
|
48812
|
+
}));
|
|
48813
|
+
}
|
|
48814
|
+
//#endregion
|
|
47842
48815
|
//#region src/composition/validate-composition.ts
|
|
47843
48816
|
function buildCapabilityLookup(defs) {
|
|
47844
48817
|
const byName = new Map(defs.map((d) => [d.name, d]));
|
|
@@ -47900,12 +48873,25 @@ function builtCapProblems({ def, state, fields: targetFields }, feature, at, dev
|
|
|
47900
48873
|
}
|
|
47901
48874
|
return problems;
|
|
47902
48875
|
}
|
|
47903
|
-
|
|
48876
|
+
/**
|
|
48877
|
+
* A dotted leaf is planned only on a `replace` (D1034): the feature already
|
|
48878
|
+
* passed `overridesOnlyDeclared`, so the leaf is one the cap lists in its
|
|
48879
|
+
* `overridable`, and the hub sets it into the native object. Anywhere else a
|
|
48880
|
+
* nested field is still refused.
|
|
48881
|
+
*/
|
|
48882
|
+
function stateFieldOf({ fields, state }, path, mode) {
|
|
48883
|
+
if (!path.includes(".")) return fields.get(path);
|
|
48884
|
+
if (mode !== "replace") return "nested";
|
|
48885
|
+
return describeStateField(state, path) ?? void 0;
|
|
48886
|
+
}
|
|
48887
|
+
function planTopLevelField(cap, field, mode, lookupCap) {
|
|
48888
|
+
const { def } = cap;
|
|
47904
48889
|
const { featureIndex, path, source } = field;
|
|
47905
48890
|
const fieldAt = `features[${featureIndex}].fields.${path}`;
|
|
47906
|
-
|
|
47907
|
-
|
|
48891
|
+
const tf = stateFieldOf(cap, path, mode);
|
|
48892
|
+
if (tf === "nested") return refused(problem("nested-field", fieldAt, `\`${path}\` is nested — a nested field is planned only on a declared replace (D1034)`));
|
|
47908
48893
|
if (tf === void 0) return refused(problem("unknown-field", fieldAt, `\`${def.name}\` has no field \`${path}\``));
|
|
48894
|
+
if (tf.kind === "union") return refused(unionTargetProblem(def.name, path, fieldAt));
|
|
47909
48895
|
const kinds = sourceKinds(source, lookupCap);
|
|
47910
48896
|
if (!kinds.ok) return refused(problem(kinds.code, fieldAt, kinds.message));
|
|
47911
48897
|
const role = roleOf(source);
|
|
@@ -47926,7 +48912,7 @@ function planTopLevelField({ def, fields }, field, mode, lookupCap) {
|
|
|
47926
48912
|
};
|
|
47927
48913
|
const enumProblem = enumLiteralProblem(def.name, tf, source, fieldAt);
|
|
47928
48914
|
return {
|
|
47929
|
-
problems: [...compatibility(def.name, tf, kinds.kinds, fieldAt), ...enumProblem === null ? [] : [enumProblem]],
|
|
48915
|
+
problems: [...compatibility(def.name, tf, narrowUnionRead(source, tf, kinds.kinds, lookupCap), fieldAt), ...enumProblem === null ? [] : [enumProblem]],
|
|
47930
48916
|
fields: [plan],
|
|
47931
48917
|
features: [],
|
|
47932
48918
|
events: []
|
|
@@ -48029,7 +49015,7 @@ var customizeCatalog = CAP_CUSTOMIZE_CATALOG;
|
|
|
48029
49015
|
function overridesOnlyDeclared(feature) {
|
|
48030
49016
|
const entry = customizeCatalog[feature.cap];
|
|
48031
49017
|
const allowed = new Set((entry?.overridable ?? []).flatMap((o) => {
|
|
48032
|
-
const companions = ((entry?.targets.find((t) => t.id === o.by && t.path === o.path))?.companions ?? []).filter((c) => c.kind === "transition-time" || c.when === "always");
|
|
49018
|
+
const companions = ((entry?.targets.find((t) => t.id === o.by && t.path === o.path))?.companions ?? []).filter((c) => c.kind === "transition-time" || c.kind === "source-field" || c.when === "always");
|
|
48033
49019
|
return [o.path, ...companions.map((c) => c.path)];
|
|
48034
49020
|
}));
|
|
48035
49021
|
const paths = Object.keys(feature.fields);
|
|
@@ -48100,6 +49086,20 @@ function compositionSourceRefs(composition) {
|
|
|
48100
49086
|
return [...new Map([...refs, ...forwardSourceRefs(composition)].map((r) => [require_implemented_methods.compositionSourceKey(r), r])).values()];
|
|
48101
49087
|
}
|
|
48102
49088
|
/**
|
|
49089
|
+
* Every DIRECT read (`from`) of a union source field (D1034): the reads whose
|
|
49090
|
+
* source's live kind a save looks up, so a numeric control is never linked to
|
|
49091
|
+
* a string field. A read inside an expression is judged by the expression.
|
|
49092
|
+
*/
|
|
49093
|
+
function compositionUnionReads(composition, lookupCap) {
|
|
49094
|
+
return composition.features.flatMap((f) => require_implemented_methods.compositionFeatureEnabled(f) && f.kind === "fields" ? require_implemented_methods.featureSources(f).flatMap((source) => {
|
|
49095
|
+
if (source.kind !== "from") return [];
|
|
49096
|
+
const def = lookupCap(source.cap);
|
|
49097
|
+
const schema = def?.runtimeState ?? def?.status?.schema;
|
|
49098
|
+
if (schema === void 0) return [];
|
|
49099
|
+
return describeStateField(schema, source.fieldPath)?.kind === "union" ? [source] : [];
|
|
49100
|
+
}) : []);
|
|
49101
|
+
}
|
|
49102
|
+
/**
|
|
48103
49103
|
* The candidate's device: the existing target itself, else `self`, else a
|
|
48104
49104
|
* placeholder that cannot collide with a stored target. An existing target is
|
|
48105
49105
|
* known even on create, so a second customization of it is refused on create too.
|
|
@@ -48133,6 +49133,18 @@ function selfReadProblems(read, at, fields, self) {
|
|
|
48133
49133
|
if (isNativeCap(self.native, read.cap)) return [];
|
|
48134
49134
|
return [problem("source-capability-missing", at, `the target device (device ${self.native.deviceId}) has no native \`${read.cap}\``)];
|
|
48135
49135
|
}
|
|
49136
|
+
/**
|
|
49137
|
+
* A direct read of a union field is judged by the source's LIVE kind when the
|
|
49138
|
+
* save knew it (D1034): a numeric control feeds only a number field, a select
|
|
49139
|
+
* only a string or enum one.
|
|
49140
|
+
*/
|
|
49141
|
+
function liveKindProblems(field, read, desc, at) {
|
|
49142
|
+
if (field.source.kind !== "from") return [];
|
|
49143
|
+
const live = desc.liveKinds?.get(`${read.cap}.${read.fieldPath}`);
|
|
49144
|
+
const accepted = field.kind === "enum" ? "string" : field.kind;
|
|
49145
|
+
if (live === void 0 || live === accepted) return [];
|
|
49146
|
+
return [problem("source-kind-mismatch", at, `\`${read.cap}.${read.fieldPath}\` of device ${desc.deviceId} reads a ${live} now; \`${field.cap}.${field.path}\` takes a ${accepted}`)];
|
|
49147
|
+
}
|
|
48136
49148
|
function sourceProblems(fields, ctx, self) {
|
|
48137
49149
|
const selfKey = require_implemented_methods.compositionSourceKey(self.ref);
|
|
48138
49150
|
return fields.flatMap((field) => field.reads.flatMap((read) => {
|
|
@@ -48143,7 +49155,7 @@ function sourceProblems(fields, ctx, self) {
|
|
|
48143
49155
|
if (desc === void 0 || desc.kind === "unreadable") return [problem("source-unreadable", at, `could not read source \`${key}\` (${desc === void 0 ? "it was not read" : desc.error}) — the save is refused rather than stored unchecked`)];
|
|
48144
49156
|
if (desc.kind === "absent") return [problem("source-missing", at, `source \`${key}\` does not exist`)];
|
|
48145
49157
|
if (!desc.caps.has(read.cap)) return [problem("source-capability-missing", at, `source \`${key}\` (device ${desc.deviceId}) has no \`${read.cap}\``)];
|
|
48146
|
-
return
|
|
49158
|
+
return liveKindProblems(field, read, desc, at);
|
|
48147
49159
|
}));
|
|
48148
49160
|
}
|
|
48149
49161
|
/**
|
|
@@ -48235,7 +49247,8 @@ function validateComposition(composition, ctx) {
|
|
|
48235
49247
|
...sourceProblems(plan.fields, ctx, self),
|
|
48236
49248
|
...forwardSourceProblems(composition, ctx.sources),
|
|
48237
49249
|
...cycles,
|
|
48238
|
-
...helperSaveProblems(composition, facts)
|
|
49250
|
+
...helperSaveProblems(composition, facts),
|
|
49251
|
+
...powerSourceActuatorConflicts(composition).map((c) => problem("power-source-is-actuator", c.path, `the power source \`${c.switch.stableId}\` is one of this device's own switches — pick the plug that feeds it`))
|
|
48239
49252
|
];
|
|
48240
49253
|
return {
|
|
48241
49254
|
ok: problems.length === 0,
|
|
@@ -48297,13 +49310,13 @@ function describeComposableCaps(defs, deviceType) {
|
|
|
48297
49310
|
const itemArray = def.status?.itemArray;
|
|
48298
49311
|
return {
|
|
48299
49312
|
cap: def.name,
|
|
48300
|
-
fields: fields.
|
|
49313
|
+
fields: fields.flatMap((f) => f.kind === "union" ? [] : [{
|
|
48301
49314
|
path: f.path,
|
|
48302
49315
|
kind: f.kind,
|
|
48303
49316
|
nullable: f.nullable,
|
|
48304
49317
|
required: f.required,
|
|
48305
49318
|
...f.enumValues === void 0 ? {} : { enumValues: [...f.enumValues] }
|
|
48306
|
-
})
|
|
49319
|
+
}]),
|
|
48307
49320
|
...itemArray === void 0 ? {} : { itemArray: {
|
|
48308
49321
|
path: itemArray.path,
|
|
48309
49322
|
keyField: itemArray.keyField
|
|
@@ -51902,8 +52915,14 @@ var deviceManagerCapability = {
|
|
|
51902
52915
|
"string",
|
|
51903
52916
|
"number",
|
|
51904
52917
|
"boolean",
|
|
51905
|
-
"enum"
|
|
52918
|
+
"enum",
|
|
52919
|
+
"union"
|
|
51906
52920
|
]),
|
|
52921
|
+
unionMembers: zod.z.array(zod.z.enum([
|
|
52922
|
+
"string",
|
|
52923
|
+
"number",
|
|
52924
|
+
"boolean"
|
|
52925
|
+
])).optional(),
|
|
51907
52926
|
enumValues: zod.z.array(zod.z.string()).optional(),
|
|
51908
52927
|
item: zod.z.boolean().optional(),
|
|
51909
52928
|
quantity: require_sleep.ReadingQuantitySchema.optional()
|
|
@@ -55930,8 +56949,88 @@ list: require_sleep.method(zod.z.void(), zod.z.array(FailureContributionSchema).
|
|
|
55930
56949
|
* - `FanPreset` — preset selector
|
|
55931
56950
|
* - `FanDirection` — direction toggle (ceiling fans)
|
|
55932
56951
|
* - `FanOscillating` — oscillation toggle
|
|
56952
|
+
*
|
|
56953
|
+
* Per-axis oscillation (`oscillationAxes`, `setOscillationAxis`, D1034): an air
|
|
56954
|
+
* circulator sweeps horizontally and vertically, each axis with its own
|
|
56955
|
+
* switch, fixed angle, sweep bounds and limits. A provider may report them
|
|
56956
|
+
* natively; otherwise the OPERATOR links sibling devices to each field in
|
|
56957
|
+
* Customize (a `replace` over the fields listed in `overridable` — nothing is
|
|
56958
|
+
* linked or inferred by itself), and a write to a linked field is forwarded to
|
|
56959
|
+
* its source. `oscillating` stays the single summary flag: when axes exist it
|
|
56960
|
+
* means "any axis oscillates" (`anyAxisOscillating`).
|
|
55933
56961
|
*/
|
|
55934
56962
|
var FanDirectionSchema = zod.z.enum(["forward", "reverse"]);
|
|
56963
|
+
var FAN_OSCILLATION_AXES = ["horizontal", "vertical"];
|
|
56964
|
+
var FanOscillationAxisNameSchema = zod.z.enum(FAN_OSCILLATION_AXES);
|
|
56965
|
+
/** The fields of one axis a caller may set. */
|
|
56966
|
+
var FAN_OSCILLATION_AXIS_SETTABLE = [
|
|
56967
|
+
"oscillating",
|
|
56968
|
+
"angle",
|
|
56969
|
+
"sweepFrom",
|
|
56970
|
+
"sweepTo"
|
|
56971
|
+
];
|
|
56972
|
+
var FanOscillationAxisFieldSchema = zod.z.enum(FAN_OSCILLATION_AXIS_SETTABLE);
|
|
56973
|
+
/** The limits of one axis, read from the source that serves its angle. */
|
|
56974
|
+
var FAN_OSCILLATION_AXIS_LIMITS = [
|
|
56975
|
+
"min",
|
|
56976
|
+
"max",
|
|
56977
|
+
"step"
|
|
56978
|
+
];
|
|
56979
|
+
/**
|
|
56980
|
+
* One oscillation axis. Every reading the device has not reported is `null`,
|
|
56981
|
+
* never `0` (D393): `0°` is a real position. Each leaf defaults to `null`, so
|
|
56982
|
+
* a slice that names only the leaves it knows (a Customize link of one field)
|
|
56983
|
+
* is still a whole axis.
|
|
56984
|
+
*/
|
|
56985
|
+
var FanOscillationAxisSchema = zod.z.object({
|
|
56986
|
+
/** Whether the axis sweeps. */
|
|
56987
|
+
oscillating: zod.z.boolean().nullable().default(null),
|
|
56988
|
+
/** The fixed position (degrees) the axis holds when it does not sweep. */
|
|
56989
|
+
angle: zod.z.number().nullable().default(null),
|
|
56990
|
+
/** The sweep bounds (degrees): left → right, bottom → top. */
|
|
56991
|
+
sweepFrom: zod.z.number().nullable().default(null),
|
|
56992
|
+
sweepTo: zod.z.number().nullable().default(null),
|
|
56993
|
+
/** The angles the axis accepts. Null when the device states none. */
|
|
56994
|
+
min: zod.z.number().nullable().default(null),
|
|
56995
|
+
max: zod.z.number().nullable().default(null),
|
|
56996
|
+
step: zod.z.number().nullable().default(null)
|
|
56997
|
+
});
|
|
56998
|
+
/** Both axes; an axis the device does not have is `null`. */
|
|
56999
|
+
var FanOscillationAxesSchema = zod.z.object({
|
|
57000
|
+
horizontal: FanOscillationAxisSchema.nullable().default(null),
|
|
57001
|
+
vertical: FanOscillationAxisSchema.nullable().default(null)
|
|
57002
|
+
});
|
|
57003
|
+
var FAN_OSCILLATION_AXIS_REFUSALS = [
|
|
57004
|
+
"nothing-to-set",
|
|
57005
|
+
"axis-not-linked",
|
|
57006
|
+
"out-of-range",
|
|
57007
|
+
"source-gone",
|
|
57008
|
+
"source-unknown",
|
|
57009
|
+
"source-call-failed"
|
|
57010
|
+
];
|
|
57011
|
+
var FanOscillationAxisRefusalSchema = zod.z.enum(FAN_OSCILLATION_AXIS_REFUSALS);
|
|
57012
|
+
var FanOscillationAxisResultSchema = zod.z.discriminatedUnion("status", [zod.z.object({ status: zod.z.literal("applied") }), zod.z.object({
|
|
57013
|
+
status: zod.z.literal("refused"),
|
|
57014
|
+
reason: FanOscillationAxisRefusalSchema,
|
|
57015
|
+
/** The field at fault, when one is. */
|
|
57016
|
+
field: FanOscillationAxisFieldSchema.optional(),
|
|
57017
|
+
/** One line for the operator, naming the axis, the field and the source. */
|
|
57018
|
+
detail: zod.z.string(),
|
|
57019
|
+
/** Fields that DID land before the refusal (writes run in order, stop at the first failure). */
|
|
57020
|
+
applied: zod.z.array(FanOscillationAxisFieldSchema)
|
|
57021
|
+
})]);
|
|
57022
|
+
var SetOscillationAxisInputSchema = zod.z.object({
|
|
57023
|
+
deviceId: zod.z.number().int().nonnegative(),
|
|
57024
|
+
axis: FanOscillationAxisNameSchema,
|
|
57025
|
+
oscillating: zod.z.boolean().optional(),
|
|
57026
|
+
angle: zod.z.number().optional(),
|
|
57027
|
+
sweepFrom: zod.z.number().optional(),
|
|
57028
|
+
sweepTo: zod.z.number().optional()
|
|
57029
|
+
});
|
|
57030
|
+
/** The state path of one axis field: `oscillationAxes.<axis>.<field>`. */
|
|
57031
|
+
function fanAxisPath(axis, field) {
|
|
57032
|
+
return `oscillationAxes.${axis}.${field}`;
|
|
57033
|
+
}
|
|
55935
57034
|
var FanControlStatusSchema = zod.z.object({
|
|
55936
57035
|
/** Active speed as 0..100 inclusive. Null when the device has no
|
|
55937
57036
|
* speed surface (single-speed fan). */
|
|
@@ -55950,9 +57049,116 @@ var FanControlStatusSchema = zod.z.object({
|
|
|
55950
57049
|
/** Oscillation toggle. Null when the device has no oscillation
|
|
55951
57050
|
* surface. */
|
|
55952
57051
|
oscillating: zod.z.boolean().nullable(),
|
|
57052
|
+
/**
|
|
57053
|
+
* Per-axis oscillation (air circulators). Absent when the device has no
|
|
57054
|
+
* per-axis surface and nothing is linked in Customize.
|
|
57055
|
+
*/
|
|
57056
|
+
oscillationAxes: FanOscillationAxesSchema.optional(),
|
|
55953
57057
|
/** Ms epoch when the slice was last updated. */
|
|
55954
57058
|
lastChangedAt: zod.z.number()
|
|
55955
57059
|
});
|
|
57060
|
+
/**
|
|
57061
|
+
* The summary flag: with axes, "any axis oscillates"; without an axis that
|
|
57062
|
+
* reports, the device's own `oscillating`.
|
|
57063
|
+
*/
|
|
57064
|
+
function anyAxisOscillating(status) {
|
|
57065
|
+
const axes = status.oscillationAxes;
|
|
57066
|
+
if (axes === void 0) return status.oscillating;
|
|
57067
|
+
const known = FAN_OSCILLATION_AXES.flatMap((axis) => {
|
|
57068
|
+
const value = axes[axis]?.oscillating;
|
|
57069
|
+
return value === null || value === void 0 ? [] : [value];
|
|
57070
|
+
});
|
|
57071
|
+
if (known.length === 0) return status.oscillating;
|
|
57072
|
+
return known.some(Boolean);
|
|
57073
|
+
}
|
|
57074
|
+
var FAN_CUSTOMIZE_DEVICE_TYPES = [require_composed_stable_id.DeviceType.Fan];
|
|
57075
|
+
/** The Customize section the axis targets are listed under. */
|
|
57076
|
+
var AXES_SECTION = "oscillation-axes";
|
|
57077
|
+
function axisOscillatingTarget(axis) {
|
|
57078
|
+
return {
|
|
57079
|
+
id: `${axis}-oscillating`,
|
|
57080
|
+
cardinality: "scalar",
|
|
57081
|
+
vocabulary: {
|
|
57082
|
+
cap: "fan-control",
|
|
57083
|
+
stateField: "oscillating"
|
|
57084
|
+
},
|
|
57085
|
+
deviceTypes: FAN_CUSTOMIZE_DEVICE_TYPES,
|
|
57086
|
+
apply: "replace",
|
|
57087
|
+
section: AXES_SECTION,
|
|
57088
|
+
path: fanAxisPath(axis, "oscillating"),
|
|
57089
|
+
sources: [{
|
|
57090
|
+
kind: "switch",
|
|
57091
|
+
transforms: [{ kind: "identity" }]
|
|
57092
|
+
}],
|
|
57093
|
+
sourceReport: { status: "assignment-status" }
|
|
57094
|
+
};
|
|
57095
|
+
}
|
|
57096
|
+
/**
|
|
57097
|
+
* A numeric axis field. The `angle` link also carries the axis limits, read
|
|
57098
|
+
* from the SAME linked control's own range (`min`/`max`/`step`), so the limits
|
|
57099
|
+
* are the source's, never guessed.
|
|
57100
|
+
*/
|
|
57101
|
+
function axisNumericTarget(axis, field) {
|
|
57102
|
+
const base = {
|
|
57103
|
+
id: `${axis}-${field}`,
|
|
57104
|
+
cardinality: "scalar",
|
|
57105
|
+
vocabulary: { cap: "fan-control" },
|
|
57106
|
+
deviceTypes: FAN_CUSTOMIZE_DEVICE_TYPES,
|
|
57107
|
+
apply: "replace",
|
|
57108
|
+
section: AXES_SECTION,
|
|
57109
|
+
path: fanAxisPath(axis, field),
|
|
57110
|
+
sources: [{
|
|
57111
|
+
kind: "numeric",
|
|
57112
|
+
transforms: [{ kind: "identity" }]
|
|
57113
|
+
}],
|
|
57114
|
+
sourceReport: { status: "assignment-status" }
|
|
57115
|
+
};
|
|
57116
|
+
if (field !== "angle") return base;
|
|
57117
|
+
return {
|
|
57118
|
+
...base,
|
|
57119
|
+
companions: FAN_OSCILLATION_AXIS_LIMITS.map((limit) => ({
|
|
57120
|
+
kind: "source-field",
|
|
57121
|
+
path: fanAxisPath(axis, limit),
|
|
57122
|
+
field: limit
|
|
57123
|
+
}))
|
|
57124
|
+
};
|
|
57125
|
+
}
|
|
57126
|
+
var AXIS_TARGETS = FAN_OSCILLATION_AXES.flatMap((axis) => [
|
|
57127
|
+
axisOscillatingTarget(axis),
|
|
57128
|
+
axisNumericTarget(axis, "angle"),
|
|
57129
|
+
axisNumericTarget(axis, "sweepFrom"),
|
|
57130
|
+
axisNumericTarget(axis, "sweepTo")
|
|
57131
|
+
]);
|
|
57132
|
+
/** A select (an enum control) the operator links to the fan's `preset`. */
|
|
57133
|
+
var PRESET_TARGET = {
|
|
57134
|
+
id: "preset",
|
|
57135
|
+
cardinality: "scalar",
|
|
57136
|
+
vocabulary: { cap: "fan-control" },
|
|
57137
|
+
deviceTypes: FAN_CUSTOMIZE_DEVICE_TYPES,
|
|
57138
|
+
apply: "replace",
|
|
57139
|
+
path: "preset",
|
|
57140
|
+
sources: [{
|
|
57141
|
+
kind: "field",
|
|
57142
|
+
valueKinds: ["string"],
|
|
57143
|
+
transforms: [{ kind: "identity" }]
|
|
57144
|
+
}],
|
|
57145
|
+
sourceReport: { status: "assignment-status" }
|
|
57146
|
+
};
|
|
57147
|
+
var FAN_CONTROL_TARGETS = [...AXIS_TARGETS, PRESET_TARGET];
|
|
57148
|
+
/**
|
|
57149
|
+
* Customize (D1034): the fan already serves `fan-control` natively, so every
|
|
57150
|
+
* target is a `replace` over a field listed in `overridable` — the axis leaves
|
|
57151
|
+
* and `preset`, nothing else. Nothing is pre-linked: the operator picks each
|
|
57152
|
+
* source (D356).
|
|
57153
|
+
*/
|
|
57154
|
+
var fanControlCustomize = {
|
|
57155
|
+
version: 1,
|
|
57156
|
+
overridable: FAN_CONTROL_TARGETS.map((target) => ({
|
|
57157
|
+
path: target.path,
|
|
57158
|
+
by: target.id
|
|
57159
|
+
})),
|
|
57160
|
+
targets: FAN_CONTROL_TARGETS
|
|
57161
|
+
};
|
|
55956
57162
|
var fanControlCapability = {
|
|
55957
57163
|
name: "fan-control",
|
|
55958
57164
|
scope: "device",
|
|
@@ -55987,6 +57193,18 @@ var fanControlCapability = {
|
|
|
55987
57193
|
}), zod.z.void(), {
|
|
55988
57194
|
kind: "mutation",
|
|
55989
57195
|
auth: "protected"
|
|
57196
|
+
}),
|
|
57197
|
+
/**
|
|
57198
|
+
* Sets one oscillation axis: its switch, fixed angle and/or sweep bounds.
|
|
57199
|
+
* Fields left out are untouched. A field linked in Customize is forwarded
|
|
57200
|
+
* to its linked source (D1034); otherwise the native provider serves it;
|
|
57201
|
+
* neither → `axis-not-linked`. Ranges are checked against the axis limits
|
|
57202
|
+
* before anything is written; writes run in order and stop at the first
|
|
57203
|
+
* failure, which the result names.
|
|
57204
|
+
*/
|
|
57205
|
+
setOscillationAxis: require_sleep.optionalMethod(SetOscillationAxisInputSchema, FanOscillationAxisResultSchema, {
|
|
57206
|
+
kind: "mutation",
|
|
57207
|
+
auth: "protected"
|
|
55990
57208
|
})
|
|
55991
57209
|
},
|
|
55992
57210
|
status: {
|
|
@@ -55998,6 +57216,7 @@ var fanControlCapability = {
|
|
|
55998
57216
|
* sliders read `speed` for live updates.
|
|
55999
57217
|
*/
|
|
56000
57218
|
runtimeState: FanControlStatusSchema,
|
|
57219
|
+
customize: fanControlCustomize,
|
|
56001
57220
|
/**
|
|
56002
57221
|
* Runtime-state durability: **session** — as `brightness`.
|
|
56003
57222
|
*
|
|
@@ -56020,12 +57239,15 @@ var fanControlCapability = {
|
|
|
56020
57239
|
//#endregion
|
|
56021
57240
|
//#region src/capabilities/fan-presets.cap.ts
|
|
56022
57241
|
/**
|
|
56023
|
-
* fan-presets — named settings the operator
|
|
56024
|
-
*
|
|
56025
|
-
*
|
|
56026
|
-
*
|
|
56027
|
-
*
|
|
56028
|
-
*
|
|
57242
|
+
* fan-presets — named settings the operator keeps for a fan ("Night": speed
|
|
57243
|
+
* 25 %, horizontal sweep off, angle 30°). A preset is a DESIRED fan-control
|
|
57244
|
+
* state (D1034): the fields it names, nothing else. Applying it calls the
|
|
57245
|
+
* fan's own `fan-control` methods — `setPreset`, `setPercentage`,
|
|
57246
|
+
* `setDirection`, `setOscillationAxis` — and an axis the operator linked in
|
|
57247
|
+
* Customize reaches its sibling device through that link, never through a
|
|
57248
|
+
* step the preset stores. Every field is reported (applied / failed / not-run
|
|
57249
|
+
* / refused), so a caller tells "applied" from "the speed was set but the
|
|
57250
|
+
* angle was refused" without parsing text.
|
|
56029
57251
|
*
|
|
56030
57252
|
* It is a Customize `config` extension of a fan: the presets are the
|
|
56031
57253
|
* operator's, stored per device (D865), and the editor is derived from the
|
|
@@ -56034,17 +57256,33 @@ var fanControlCapability = {
|
|
|
56034
57256
|
* (a scene, a switch, a button) offer it.
|
|
56035
57257
|
*/
|
|
56036
57258
|
var FAN_PRESETS_MAX = 12;
|
|
56037
|
-
|
|
57259
|
+
/** One axis as a preset wants it; an absent field is left as it is. */
|
|
57260
|
+
var FanPresetAxisSchema = zod.z.object({
|
|
57261
|
+
oscillating: zod.z.boolean().optional(),
|
|
57262
|
+
angle: zod.z.number().optional(),
|
|
57263
|
+
sweepFrom: zod.z.number().optional(),
|
|
57264
|
+
sweepTo: zod.z.number().optional()
|
|
57265
|
+
});
|
|
57266
|
+
/** The fan-control state a preset sets; an absent field is left as it is. */
|
|
57267
|
+
var FanPresetStateSchema = zod.z.object({
|
|
57268
|
+
speed: zod.z.number().min(0).max(100).optional(),
|
|
57269
|
+
/** The fan's own preset mode (or the linked select's option). */
|
|
57270
|
+
preset: zod.z.string().min(1).optional(),
|
|
57271
|
+
direction: FanDirectionSchema.optional(),
|
|
57272
|
+
oscillationAxes: zod.z.object({
|
|
57273
|
+
horizontal: FanPresetAxisSchema.optional(),
|
|
57274
|
+
vertical: FanPresetAxisSchema.optional()
|
|
57275
|
+
}).optional()
|
|
57276
|
+
});
|
|
56038
57277
|
var FanPresetSchema = zod.z.object({
|
|
56039
57278
|
/** Stable key; never reused after a delete within one device's list. */
|
|
56040
57279
|
id: zod.z.string().min(1).max(64),
|
|
56041
57280
|
/** What the operator and a voice assistant call it. */
|
|
56042
57281
|
name: zod.z.string().trim().min(1).max(40),
|
|
56043
|
-
|
|
57282
|
+
state: FanPresetStateSchema
|
|
56044
57283
|
});
|
|
56045
57284
|
var FAN_PRESETS_REFUSALS = [
|
|
56046
|
-
"
|
|
56047
|
-
"bad-target",
|
|
57285
|
+
"empty-state",
|
|
56048
57286
|
"duplicate-name",
|
|
56049
57287
|
"duplicate-id",
|
|
56050
57288
|
"too-many",
|
|
@@ -56057,66 +57295,50 @@ var FanPresetsSetResultSchema = zod.z.discriminatedUnion("status", [zod.z.object
|
|
|
56057
57295
|
}), zod.z.object({
|
|
56058
57296
|
status: zod.z.literal("refused"),
|
|
56059
57297
|
reason: FanPresetsRefusalSchema,
|
|
56060
|
-
/** Names the preset
|
|
57298
|
+
/** Names the preset at fault. */
|
|
56061
57299
|
detail: zod.z.string()
|
|
56062
57300
|
})]);
|
|
56063
|
-
var
|
|
56064
|
-
|
|
57301
|
+
var FanPresetFieldResultSchema = zod.z.object({
|
|
57302
|
+
/** The state path: `speed`, `preset`, `direction`, `oscillationAxes.horizontal.angle`. */
|
|
57303
|
+
field: zod.z.string(),
|
|
56065
57304
|
outcome: zod.z.enum([
|
|
56066
57305
|
"applied",
|
|
56067
57306
|
"failed",
|
|
56068
57307
|
"not-run",
|
|
56069
57308
|
"refused"
|
|
56070
57309
|
]),
|
|
56071
|
-
deviceId: zod.z.number().int().nonnegative().optional(),
|
|
56072
|
-
cap: zod.z.string().optional(),
|
|
56073
|
-
method: zod.z.string().optional(),
|
|
56074
57310
|
/** The cause, for every outcome but `applied`. */
|
|
56075
57311
|
message: zod.z.string().optional()
|
|
56076
57312
|
});
|
|
56077
57313
|
var FanPresetApplyResultSchema = zod.z.object({
|
|
56078
|
-
/** `applied`: every
|
|
57314
|
+
/** `applied`: every field landed. `partial`: some did, one did not. `refused`: nothing ran. */
|
|
56079
57315
|
status: zod.z.enum([
|
|
56080
57316
|
"applied",
|
|
56081
57317
|
"partial",
|
|
56082
57318
|
"refused"
|
|
56083
57319
|
]),
|
|
56084
|
-
|
|
57320
|
+
fields: zod.z.array(FanPresetFieldResultSchema)
|
|
56085
57321
|
});
|
|
56086
|
-
/** The fan
|
|
57322
|
+
/** The fan-control fields a capture may take. */
|
|
56087
57323
|
var FAN_CAPTURE_FIELDS = [
|
|
56088
57324
|
"speed",
|
|
56089
|
-
"oscillating",
|
|
56090
57325
|
"direction",
|
|
56091
|
-
"preset"
|
|
57326
|
+
"preset",
|
|
57327
|
+
"oscillationAxes"
|
|
56092
57328
|
];
|
|
56093
57329
|
var FanCaptureFieldSchema = zod.z.enum(FAN_CAPTURE_FIELDS);
|
|
56094
57330
|
var FanCaptureOmissionSchema = zod.z.object({
|
|
56095
|
-
/** A
|
|
57331
|
+
/** A state path (`speed`, `oscillationAxes.vertical.angle`). */
|
|
56096
57332
|
what: zod.z.string(),
|
|
56097
|
-
/** Why no value was taken: unknown reading
|
|
57333
|
+
/** Why no value was taken: an unknown reading is never stored as 0 (D393). */
|
|
56098
57334
|
reason: zod.z.string()
|
|
56099
57335
|
});
|
|
56100
|
-
/** Where a proposed step belongs in the review list. */
|
|
56101
|
-
var FAN_CAPTURE_GROUPS = [
|
|
56102
|
-
"fan",
|
|
56103
|
-
"oscillation",
|
|
56104
|
-
"angles"
|
|
56105
|
-
];
|
|
56106
|
-
var FanCaptureGroupSchema = zod.z.enum(FAN_CAPTURE_GROUPS);
|
|
56107
|
-
var FanCaptureItemSchema = zod.z.object({
|
|
56108
|
-
group: FanCaptureGroupSchema,
|
|
56109
|
-
/** What the step sets, in the operator's words (a device name, a fan field). */
|
|
56110
|
-
label: zod.z.string()
|
|
56111
|
-
});
|
|
56112
57336
|
var FanPresetCaptureResultSchema = zod.z.object({
|
|
56113
|
-
/** The
|
|
56114
|
-
|
|
56115
|
-
/** One entry per step, same order: its review group and label. */
|
|
56116
|
-
items: zod.z.array(FanCaptureItemSchema),
|
|
57337
|
+
/** The fan's CURRENT fan-control state, as a preset; NOT saved. */
|
|
57338
|
+
state: FanPresetStateSchema,
|
|
56117
57339
|
omitted: zod.z.array(FanCaptureOmissionSchema)
|
|
56118
57340
|
});
|
|
56119
|
-
var deviceInput$
|
|
57341
|
+
var deviceInput$1 = zod.z.object({ deviceId: zod.z.number().int().nonnegative() });
|
|
56120
57342
|
var fanPresetsCustomize = {
|
|
56121
57343
|
version: 1,
|
|
56122
57344
|
targets: [{
|
|
@@ -56134,28 +57356,22 @@ var fanPresetsCapability = {
|
|
|
56134
57356
|
scope: "system",
|
|
56135
57357
|
mode: "singleton",
|
|
56136
57358
|
methods: {
|
|
56137
|
-
getPresets: require_sleep.method(deviceInput$
|
|
56138
|
-
setPresets: require_sleep.method(deviceInput$
|
|
57359
|
+
getPresets: require_sleep.method(deviceInput$1, zod.z.array(FanPresetSchema), { auth: "protected" }),
|
|
57360
|
+
setPresets: require_sleep.method(deviceInput$1.extend({ presets: zod.z.array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
|
|
56139
57361
|
kind: "mutation",
|
|
56140
57362
|
auth: "admin"
|
|
56141
57363
|
}),
|
|
56142
|
-
applyPreset: require_sleep.method(deviceInput$
|
|
57364
|
+
applyPreset: require_sleep.method(deviceInput$1.extend({ presetId: zod.z.string().min(1) }), FanPresetApplyResultSchema, {
|
|
56143
57365
|
kind: "mutation",
|
|
56144
57366
|
auth: "protected"
|
|
56145
57367
|
}),
|
|
56146
57368
|
/**
|
|
56147
|
-
*
|
|
56148
|
-
* `fields` (all when absent)
|
|
56149
|
-
*
|
|
56150
|
-
*
|
|
56151
|
-
* oscillation, fixed angles, fan fields, speed last. A reading that is
|
|
56152
|
-
* unknown is left out and named in `omitted`, never captured as 0. Nothing
|
|
56153
|
-
* is saved.
|
|
57369
|
+
* The fan's CURRENT fan-control state as a preset: the fields named in
|
|
57370
|
+
* `fields` (all when absent), read from its merged slice — a field linked
|
|
57371
|
+
* in Customize reads its link. A reading that is unknown is left out and
|
|
57372
|
+
* named in `omitted`, never captured as 0. Nothing is saved.
|
|
56154
57373
|
*/
|
|
56155
|
-
capturePreset: require_sleep.method(deviceInput$
|
|
56156
|
-
fields: zod.z.array(FanCaptureFieldSchema).optional(),
|
|
56157
|
-
steps: zod.z.array(ActionStepSchema).max(20).default([])
|
|
56158
|
-
}), FanPresetCaptureResultSchema, { auth: "protected" })
|
|
57374
|
+
capturePreset: require_sleep.method(deviceInput$1.extend({ fields: zod.z.array(FanCaptureFieldSchema).optional() }), FanPresetCaptureResultSchema, { auth: "protected" })
|
|
56159
57375
|
},
|
|
56160
57376
|
customize: fanPresetsCustomize
|
|
56161
57377
|
};
|
|
@@ -56393,8 +57609,7 @@ var groupActiveCapability = {
|
|
|
56393
57609
|
require_composed_stable_id.DeviceType.Valve,
|
|
56394
57610
|
require_composed_stable_id.DeviceType.Lock,
|
|
56395
57611
|
require_composed_stable_id.DeviceType.MediaPlayer,
|
|
56396
|
-
require_composed_stable_id.DeviceType.Climate
|
|
56397
|
-
require_composed_stable_id.DeviceType.Thermostat
|
|
57612
|
+
require_composed_stable_id.DeviceType.Climate
|
|
56398
57613
|
],
|
|
56399
57614
|
methods: {},
|
|
56400
57615
|
status: {
|
|
@@ -56445,7 +57660,6 @@ var groupCommandsCapability = {
|
|
|
56445
57660
|
require_composed_stable_id.DeviceType.Valve,
|
|
56446
57661
|
require_composed_stable_id.DeviceType.Lock,
|
|
56447
57662
|
require_composed_stable_id.DeviceType.MediaPlayer,
|
|
56448
|
-
require_composed_stable_id.DeviceType.Thermostat,
|
|
56449
57663
|
require_composed_stable_id.DeviceType.Climate
|
|
56450
57664
|
],
|
|
56451
57665
|
methods: {},
|
|
@@ -56503,7 +57717,6 @@ var groupStatusCapability = {
|
|
|
56503
57717
|
require_composed_stable_id.DeviceType.Valve,
|
|
56504
57718
|
require_composed_stable_id.DeviceType.Lock,
|
|
56505
57719
|
require_composed_stable_id.DeviceType.MediaPlayer,
|
|
56506
|
-
require_composed_stable_id.DeviceType.Thermostat,
|
|
56507
57720
|
require_composed_stable_id.DeviceType.Climate
|
|
56508
57721
|
],
|
|
56509
57722
|
methods: {},
|
|
@@ -56879,7 +58092,7 @@ var heatingValveCapability = {
|
|
|
56879
58092
|
scope: "device",
|
|
56880
58093
|
deviceNative: true,
|
|
56881
58094
|
mode: "singleton",
|
|
56882
|
-
deviceTypes: [require_composed_stable_id.DeviceType.
|
|
58095
|
+
deviceTypes: [require_composed_stable_id.DeviceType.Climate],
|
|
56883
58096
|
methods: {},
|
|
56884
58097
|
status: {
|
|
56885
58098
|
schema: HeatingValveStatusSchema,
|
|
@@ -56911,30 +58124,42 @@ var heatingValveCapability = {
|
|
|
56911
58124
|
* retried in a loop - D49); a future one is re-armed.
|
|
56912
58125
|
*
|
|
56913
58126
|
* What a device may be run for, and for how long at most, is per device type
|
|
56914
|
-
* ({@link
|
|
58127
|
+
* and role ({@link timedRunLimitOf}): the maximum is a safety bound, not a preference,
|
|
56915
58128
|
* so a request above it is REFUSED with a typed reason, never clamped.
|
|
56916
58129
|
*/
|
|
56917
58130
|
var TimedRunUnitSchema = zod.z.enum(["s", "min"]);
|
|
56918
58131
|
/** What a timed run switches: the `switch` cap's `setState` or the fountain's `setPump`. */
|
|
56919
58132
|
var TimedRunActuatorSchema = zod.z.enum(["switch", "pet-fountain"]);
|
|
56920
|
-
/**
|
|
56921
|
-
var
|
|
56922
|
-
|
|
56923
|
-
|
|
56924
|
-
|
|
56925
|
-
|
|
56926
|
-
quickRunDefault: 30
|
|
56927
|
-
},
|
|
56928
|
-
[require_composed_stable_id.DeviceType.PetFountain]: {
|
|
56929
|
-
actuator: "pet-fountain",
|
|
56930
|
-
maxSeconds: 300,
|
|
56931
|
-
unit: "s",
|
|
56932
|
-
quickRunDefault: 60
|
|
56933
|
-
}
|
|
58133
|
+
/** A plug-in heater (switch + `switch-heater`): up to 3 h, in minutes. */
|
|
58134
|
+
var TIMED_RUN_HEATER_LIMIT = {
|
|
58135
|
+
actuator: "switch",
|
|
58136
|
+
maxSeconds: 10800,
|
|
58137
|
+
unit: "min",
|
|
58138
|
+
quickRunDefault: 30
|
|
56934
58139
|
};
|
|
56935
|
-
|
|
56936
|
-
|
|
56937
|
-
|
|
58140
|
+
/** A pet fountain's pump: up to 5 min, in seconds. */
|
|
58141
|
+
var TIMED_RUN_PET_FOUNTAIN_LIMIT = {
|
|
58142
|
+
actuator: "pet-fountain",
|
|
58143
|
+
maxSeconds: 300,
|
|
58144
|
+
unit: "s",
|
|
58145
|
+
quickRunDefault: 60
|
|
58146
|
+
};
|
|
58147
|
+
/**
|
|
58148
|
+
* The device types `timed-run` may be offered on. A `switch` is narrowed by
|
|
58149
|
+
* role ({@link TIMED_RUN_DEVICE_ROLES}): only a plug-in heater runs on a timer.
|
|
58150
|
+
*/
|
|
58151
|
+
var TIMED_RUN_DEVICE_TYPES = [require_composed_stable_id.DeviceType.Switch, require_composed_stable_id.DeviceType.PetFountain];
|
|
58152
|
+
/** The roles that make a device of these types timed-run-able (D1033). */
|
|
58153
|
+
var TIMED_RUN_DEVICE_ROLES = { [require_composed_stable_id.DeviceType.Switch]: [require_composed_stable_id.DeviceRole.SwitchHeater] };
|
|
58154
|
+
/**
|
|
58155
|
+
* The longest run of a device, by its type AND role (D1033): a `switch` is a
|
|
58156
|
+
* heater only with role `switch-heater`, a pet fountain always is what it is.
|
|
58157
|
+
* `null` - the device is not offered `timed-run`.
|
|
58158
|
+
*/
|
|
58159
|
+
function timedRunLimitOf(deviceType, role) {
|
|
58160
|
+
if (deviceType === require_composed_stable_id.DeviceType.PetFountain) return TIMED_RUN_PET_FOUNTAIN_LIMIT;
|
|
58161
|
+
if (deviceType === require_composed_stable_id.DeviceType.Switch && role === require_composed_stable_id.DeviceRole.SwitchHeater) return TIMED_RUN_HEATER_LIMIT;
|
|
58162
|
+
return null;
|
|
56938
58163
|
}
|
|
56939
58164
|
var MS_PER_SECOND = 1e3;
|
|
56940
58165
|
var MS_PER_MINUTE = 6e4;
|
|
@@ -57016,6 +58241,7 @@ var timedRunCapability = {
|
|
|
57016
58241
|
kind: "wrapper",
|
|
57017
58242
|
defaultActive: true,
|
|
57018
58243
|
deviceTypes: TIMED_RUN_DEVICE_TYPES,
|
|
58244
|
+
deviceRoles: TIMED_RUN_DEVICE_ROLES,
|
|
57019
58245
|
deviceConfig: { ui: {
|
|
57020
58246
|
kind: "derived-form",
|
|
57021
58247
|
builderId: "timed-run",
|
|
@@ -57207,8 +58433,7 @@ var HERO_SCENE_BY_TYPE = {
|
|
|
57207
58433
|
[require_composed_stable_id.DeviceType.Siren]: "siren",
|
|
57208
58434
|
[require_composed_stable_id.DeviceType.Switch]: "plug",
|
|
57209
58435
|
[require_composed_stable_id.DeviceType.Sensor]: "sensor-sparkline",
|
|
57210
|
-
[require_composed_stable_id.DeviceType.
|
|
57211
|
-
[require_composed_stable_id.DeviceType.Climate]: "ac",
|
|
58436
|
+
[require_composed_stable_id.DeviceType.Climate]: "thermostat",
|
|
57212
58437
|
[require_composed_stable_id.DeviceType.Button]: "button",
|
|
57213
58438
|
[require_composed_stable_id.DeviceType.EventEmitter]: "event-stream",
|
|
57214
58439
|
[require_composed_stable_id.DeviceType.Update]: "update",
|
|
@@ -57236,7 +58461,6 @@ var HERO_SCENE_BY_TYPE = {
|
|
|
57236
58461
|
[require_composed_stable_id.DeviceType.PetFountain]: "pet-fountain",
|
|
57237
58462
|
[require_composed_stable_id.DeviceType.Dishwasher]: "dishwasher",
|
|
57238
58463
|
[require_composed_stable_id.DeviceType.Washer]: "washer",
|
|
57239
|
-
[require_composed_stable_id.DeviceType.Heater]: "heater",
|
|
57240
58464
|
[require_composed_stable_id.DeviceType.Dryer]: "dryer",
|
|
57241
58465
|
[require_composed_stable_id.DeviceType.Gateway]: "gateway"
|
|
57242
58466
|
};
|
|
@@ -57261,6 +58485,14 @@ var HERO_SCENE_BY_ROLE = {
|
|
|
57261
58485
|
[require_composed_stable_id.DeviceRole.CoverWindow]: "inherit",
|
|
57262
58486
|
[require_composed_stable_id.DeviceRole.BinaryHelper]: "inherit",
|
|
57263
58487
|
[require_composed_stable_id.DeviceRole.Outlet]: "plug",
|
|
58488
|
+
[require_composed_stable_id.DeviceRole.SwitchHeater]: "heater",
|
|
58489
|
+
[require_composed_stable_id.DeviceRole.SwitchFan]: "fan",
|
|
58490
|
+
[require_composed_stable_id.DeviceRole.ClimateAc]: "ac",
|
|
58491
|
+
[require_composed_stable_id.DeviceRole.ClimateThermostat]: "inherit",
|
|
58492
|
+
[require_composed_stable_id.DeviceRole.ClimateFloor]: "inherit",
|
|
58493
|
+
[require_composed_stable_id.DeviceRole.ClimateRadiator]: "inherit",
|
|
58494
|
+
[require_composed_stable_id.DeviceRole.ClimateHeater]: "inherit",
|
|
58495
|
+
[require_composed_stable_id.DeviceRole.ClimateHeatPumpCircuit]: "inherit",
|
|
57264
58496
|
[require_composed_stable_id.DeviceRole.MotionSensor]: "presence",
|
|
57265
58497
|
[require_composed_stable_id.DeviceRole.ContactSensor]: "contact",
|
|
57266
58498
|
[require_composed_stable_id.DeviceRole.LeakSensor]: "inherit",
|
|
@@ -57824,10 +59056,7 @@ function trailingOf(facts) {
|
|
|
57824
59056
|
* A type whose primary is a named control, not its power: a climate row is the mode
|
|
57825
59057
|
* (which carries "off") and the setpoint, with no power toggle.
|
|
57826
59058
|
*/
|
|
57827
|
-
var ROW_PRIMARY_BY_TYPE = {
|
|
57828
|
-
[require_composed_stable_id.DeviceType.Climate]: "climate.mode",
|
|
57829
|
-
[require_composed_stable_id.DeviceType.Thermostat]: "climate.mode"
|
|
57830
|
-
};
|
|
59059
|
+
var ROW_PRIMARY_BY_TYPE = { [require_composed_stable_id.DeviceType.Climate]: "climate.mode" };
|
|
57831
59060
|
function primaryOf(model) {
|
|
57832
59061
|
const named = ROW_PRIMARY_BY_TYPE[model.type];
|
|
57833
59062
|
if (named !== void 0) {
|
|
@@ -57860,7 +59089,6 @@ function primaryOf(model) {
|
|
|
57860
59089
|
*/
|
|
57861
59090
|
var ROW_EXTRAS_BY_TYPE = {
|
|
57862
59091
|
[require_composed_stable_id.DeviceType.Climate]: ["climate.target"],
|
|
57863
|
-
[require_composed_stable_id.DeviceType.Thermostat]: ["climate.target"],
|
|
57864
59092
|
[require_composed_stable_id.DeviceType.Vacuum]: ["vacuum.base"],
|
|
57865
59093
|
[require_composed_stable_id.DeviceType.LawnMower]: ["mower.dock"],
|
|
57866
59094
|
[require_composed_stable_id.DeviceType.MediaPlayer]: ["volume.level", REMOTE_OPEN_ACTION_ID]
|
|
@@ -57983,7 +59211,11 @@ var heroLayoutCapability = {
|
|
|
57983
59211
|
auth: "protected",
|
|
57984
59212
|
role: "viewer"
|
|
57985
59213
|
}),
|
|
57986
|
-
|
|
59214
|
+
/** The fixed rows of a kind: the type, refined by the role (D1033 — a heater is a switch). */
|
|
59215
|
+
getLayout: require_sleep.method(zod.z.object({
|
|
59216
|
+
deviceType: zod.z.string(),
|
|
59217
|
+
role: zod.z.string().nullable().optional()
|
|
59218
|
+
}), HeroLayoutRowsSchema, {
|
|
57987
59219
|
auth: "protected",
|
|
57988
59220
|
role: "viewer"
|
|
57989
59221
|
})
|
|
@@ -58034,6 +59266,11 @@ var humidifierCapability = {
|
|
|
58034
59266
|
deviceNative: true,
|
|
58035
59267
|
mode: "singleton",
|
|
58036
59268
|
deviceTypes: [require_composed_stable_id.DeviceType.Humidifier],
|
|
59269
|
+
power: {
|
|
59270
|
+
kind: "field",
|
|
59271
|
+
field: "on",
|
|
59272
|
+
set: "setOn"
|
|
59273
|
+
},
|
|
58037
59274
|
methods: {
|
|
58038
59275
|
setOn: require_sleep.method(zod.z.object({
|
|
58039
59276
|
deviceId: zod.z.number().int().nonnegative(),
|
|
@@ -58109,7 +59346,7 @@ var humiditySensorCapability = {
|
|
|
58109
59346
|
scope: "device",
|
|
58110
59347
|
deviceNative: true,
|
|
58111
59348
|
mode: "singleton",
|
|
58112
|
-
deviceTypes: [require_composed_stable_id.DeviceType.Sensor, require_composed_stable_id.DeviceType.
|
|
59349
|
+
deviceTypes: [require_composed_stable_id.DeviceType.Sensor, require_composed_stable_id.DeviceType.Climate],
|
|
58113
59350
|
methods: {},
|
|
58114
59351
|
status: {
|
|
58115
59352
|
schema: HumiditySensorStatusSchema,
|
|
@@ -76679,6 +77916,11 @@ var petFountainCapability = {
|
|
|
76679
77916
|
deviceNative: true,
|
|
76680
77917
|
mode: "singleton",
|
|
76681
77918
|
deviceTypes: [require_composed_stable_id.DeviceType.PetFountain],
|
|
77919
|
+
power: {
|
|
77920
|
+
kind: "field",
|
|
77921
|
+
field: "pumpRunning",
|
|
77922
|
+
set: "setPump"
|
|
77923
|
+
},
|
|
76682
77924
|
methods: {
|
|
76683
77925
|
/** Start or stop the pump. */
|
|
76684
77926
|
setPump: require_sleep.method(zod.z.object({
|
|
@@ -79593,7 +80835,6 @@ var POWER_METER_DEVICE_TYPES = [
|
|
|
79593
80835
|
require_composed_stable_id.DeviceType.Light,
|
|
79594
80836
|
require_composed_stable_id.DeviceType.Fan,
|
|
79595
80837
|
require_composed_stable_id.DeviceType.Climate,
|
|
79596
|
-
require_composed_stable_id.DeviceType.Thermostat,
|
|
79597
80838
|
require_composed_stable_id.DeviceType.Humidifier,
|
|
79598
80839
|
require_composed_stable_id.DeviceType.WaterHeater,
|
|
79599
80840
|
require_composed_stable_id.DeviceType.MediaPlayer,
|
|
@@ -79602,8 +80843,7 @@ var POWER_METER_DEVICE_TYPES = [
|
|
|
79602
80843
|
require_composed_stable_id.DeviceType.Dishwasher,
|
|
79603
80844
|
require_composed_stable_id.DeviceType.Vacuum,
|
|
79604
80845
|
require_composed_stable_id.DeviceType.LawnMower,
|
|
79605
|
-
require_composed_stable_id.DeviceType.PetFeeder
|
|
79606
|
-
require_composed_stable_id.DeviceType.Heater
|
|
80846
|
+
require_composed_stable_id.DeviceType.PetFeeder
|
|
79607
80847
|
];
|
|
79608
80848
|
/** Everything but a bare `Sensor`: a sensor that takes its reading from another sensor adds nothing. */
|
|
79609
80849
|
var POWER_METER_CUSTOMIZE_DEVICE_TYPES = POWER_METER_DEVICE_TYPES.filter((type) => type !== require_composed_stable_id.DeviceType.Sensor);
|
|
@@ -79717,146 +80957,6 @@ var powerMeterCapability = {
|
|
|
79717
80957
|
customize: powerMeterCustomize
|
|
79718
80958
|
};
|
|
79719
80959
|
//#endregion
|
|
79720
|
-
//#region src/capabilities/power-source.cap.ts
|
|
79721
|
-
/**
|
|
79722
|
-
* power-source — a device that hangs is powered by a smart switch, and the
|
|
79723
|
-
* operator picks that switch in the device's Customize. The device then offers
|
|
79724
|
-
* power on, power off and a forced restart (switch off, wait, switch on).
|
|
79725
|
-
*
|
|
79726
|
-
* Manual by default: nothing here restarts a device by itself. The one
|
|
79727
|
-
* exception (D997) is a device's OWN provider calling `forceRestart` for its own
|
|
79728
|
-
* device as a bounded self-recovery (unreachable for a long stretch, linked,
|
|
79729
|
-
* one attempt per cooldown, never with a live session); Velux is the first. It
|
|
79730
|
-
* is not the native `reboot` cap and never replaces or wraps it: `reboot` talks
|
|
79731
|
-
* to the device, this cuts the power of the device that no longer answers.
|
|
79732
|
-
*
|
|
79733
|
-
* The link is a Customize extension (`add`): one scalar target whose source is
|
|
79734
|
-
* the switch. The stored composition is the ONE copy of the link and of
|
|
79735
|
-
* `offSeconds` (`powerSourceLinkOfComposition`, D676); the composed slice only
|
|
79736
|
-
* mirrors the switch state for the UI. The methods are served by the
|
|
79737
|
-
* `core-blocks` system provider, so they are `systemMethod`s and carry a
|
|
79738
|
-
* top-level `deviceId`.
|
|
79739
|
-
*
|
|
79740
|
-
* Every action answers a typed result and never throws for an expected
|
|
79741
|
-
* refusal, so a caller tells "the switch is offline" from "a restart is
|
|
79742
|
-
* already running" without parsing text.
|
|
79743
|
-
*/
|
|
79744
|
-
/** Bounds of the off time of a forced restart, in seconds. */
|
|
79745
|
-
var POWER_SOURCE_OFF_SECONDS_MIN = 3;
|
|
79746
|
-
var POWER_SOURCE_OFF_SECONDS_MAX = 120;
|
|
79747
|
-
var POWER_SOURCE_OFF_SECONDS_DEFAULT = 10;
|
|
79748
|
-
var PowerSourceRefusalReasonSchema = zod.z.enum([
|
|
79749
|
-
"no-power-source",
|
|
79750
|
-
"switch-missing",
|
|
79751
|
-
"switch-offline",
|
|
79752
|
-
"switch-unknown",
|
|
79753
|
-
"restart-in-progress",
|
|
79754
|
-
"switch-call-failed"
|
|
79755
|
-
]);
|
|
79756
|
-
var PowerSourceActionResultSchema = zod.z.discriminatedUnion("accepted", [zod.z.object({ accepted: zod.z.literal(true) }), zod.z.object({
|
|
79757
|
-
accepted: zod.z.literal(false),
|
|
79758
|
-
reason: PowerSourceRefusalReasonSchema,
|
|
79759
|
-
/** One line for the operator, naming the switch. */
|
|
79760
|
-
message: zod.z.string()
|
|
79761
|
-
})]);
|
|
79762
|
-
var PowerSourceInfoSchema = zod.z.object({
|
|
79763
|
-
/** False when the device has no power source linked; the rest is then empty. */
|
|
79764
|
-
linked: zod.z.boolean(),
|
|
79765
|
-
switchDeviceId: zod.z.number().nullable(),
|
|
79766
|
-
switchName: zod.z.string().nullable(),
|
|
79767
|
-
/** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
|
|
79768
|
-
switchOn: zod.z.boolean().nullable(),
|
|
79769
|
-
switchOnline: zod.z.boolean().nullable(),
|
|
79770
|
-
restartInProgress: zod.z.boolean(),
|
|
79771
|
-
offSeconds: zod.z.number().int()
|
|
79772
|
-
});
|
|
79773
|
-
/** The composed slice: the switch state the link mirrors, plus the stored off time. */
|
|
79774
|
-
var PowerSourceStateSchema = zod.z.object({
|
|
79775
|
-
/** Null while the switch has not reported: unknown is never `false` (D393). */
|
|
79776
|
-
switchOn: zod.z.boolean().nullable(),
|
|
79777
|
-
offSeconds: zod.z.number().int(),
|
|
79778
|
-
lastFetchedAt: zod.z.number()
|
|
79779
|
-
});
|
|
79780
|
-
var POWER_SOURCE_DEVICE_TYPES = [
|
|
79781
|
-
require_composed_stable_id.DeviceType.Gateway,
|
|
79782
|
-
require_composed_stable_id.DeviceType.Camera,
|
|
79783
|
-
require_composed_stable_id.DeviceType.Sensor,
|
|
79784
|
-
require_composed_stable_id.DeviceType.MediaPlayer,
|
|
79785
|
-
require_composed_stable_id.DeviceType.Vacuum,
|
|
79786
|
-
require_composed_stable_id.DeviceType.Generic,
|
|
79787
|
-
require_composed_stable_id.DeviceType.Washer,
|
|
79788
|
-
require_composed_stable_id.DeviceType.Dryer,
|
|
79789
|
-
require_composed_stable_id.DeviceType.Dishwasher,
|
|
79790
|
-
require_composed_stable_id.DeviceType.PetFountain,
|
|
79791
|
-
require_composed_stable_id.DeviceType.Fan,
|
|
79792
|
-
require_composed_stable_id.DeviceType.Humidifier,
|
|
79793
|
-
require_composed_stable_id.DeviceType.Climate,
|
|
79794
|
-
require_composed_stable_id.DeviceType.WaterHeater
|
|
79795
|
-
];
|
|
79796
|
-
var powerSourceCustomize = {
|
|
79797
|
-
version: 1,
|
|
79798
|
-
targets: [{
|
|
79799
|
-
id: "switch",
|
|
79800
|
-
cardinality: "scalar",
|
|
79801
|
-
vocabulary: {
|
|
79802
|
-
cap: "power-source",
|
|
79803
|
-
stateField: "switchOn"
|
|
79804
|
-
},
|
|
79805
|
-
deviceTypes: POWER_SOURCE_DEVICE_TYPES,
|
|
79806
|
-
apply: "add",
|
|
79807
|
-
path: "switchOn",
|
|
79808
|
-
sources: [{
|
|
79809
|
-
kind: "switch",
|
|
79810
|
-
transforms: [{ kind: "identity" }]
|
|
79811
|
-
}],
|
|
79812
|
-
companions: [{
|
|
79813
|
-
kind: "constant",
|
|
79814
|
-
path: "offSeconds",
|
|
79815
|
-
value: 10,
|
|
79816
|
-
when: "add",
|
|
79817
|
-
formerValues: [0]
|
|
79818
|
-
}, {
|
|
79819
|
-
kind: "clock",
|
|
79820
|
-
path: "lastFetchedAt",
|
|
79821
|
-
when: "always"
|
|
79822
|
-
}],
|
|
79823
|
-
sourceReport: { status: "assignment-status" }
|
|
79824
|
-
}]
|
|
79825
|
-
};
|
|
79826
|
-
var deviceInput$1 = zod.z.object({ deviceId: zod.z.number().int().nonnegative() });
|
|
79827
|
-
var powerSourceCapability = {
|
|
79828
|
-
name: "power-source",
|
|
79829
|
-
scope: "device",
|
|
79830
|
-
mode: "singleton",
|
|
79831
|
-
deviceTypes: POWER_SOURCE_DEVICE_TYPES,
|
|
79832
|
-
methods: {
|
|
79833
|
-
getStatus: require_sleep.systemMethod(deviceInput$1, PowerSourceInfoSchema, { auth: "protected" }),
|
|
79834
|
-
powerOn: require_sleep.systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
|
|
79835
|
-
kind: "mutation",
|
|
79836
|
-
auth: "protected"
|
|
79837
|
-
}),
|
|
79838
|
-
powerOff: require_sleep.systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
|
|
79839
|
-
kind: "mutation",
|
|
79840
|
-
auth: "protected"
|
|
79841
|
-
}),
|
|
79842
|
-
forceRestart: require_sleep.systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
|
|
79843
|
-
kind: "mutation",
|
|
79844
|
-
auth: "protected"
|
|
79845
|
-
})
|
|
79846
|
-
},
|
|
79847
|
-
runtimeState: PowerSourceStateSchema,
|
|
79848
|
-
customize: powerSourceCustomize,
|
|
79849
|
-
/**
|
|
79850
|
-
* Runtime-state durability: **session** — mirrored from the linked switch on
|
|
79851
|
-
* its next report; a restored value would outlive the reading it names.
|
|
79852
|
-
*
|
|
79853
|
-
* See `RuntimeStateDurability`. Enforced by
|
|
79854
|
-
* `scripts/check-runtime-state-durability.ts`.
|
|
79855
|
-
*/
|
|
79856
|
-
durability: "session",
|
|
79857
|
-
history: "none"
|
|
79858
|
-
};
|
|
79859
|
-
//#endregion
|
|
79860
80960
|
//#region src/capabilities/presence.cap.ts
|
|
79861
80961
|
/**
|
|
79862
80962
|
* Presence cap. Models HA `person.*` and `device_tracker.*` entities
|
|
@@ -84824,9 +85924,7 @@ var RUNNING_CUSTOMIZE_DEVICE_TYPES = [
|
|
|
84824
85924
|
require_composed_stable_id.DeviceType.Humidifier,
|
|
84825
85925
|
require_composed_stable_id.DeviceType.Fan,
|
|
84826
85926
|
require_composed_stable_id.DeviceType.Climate,
|
|
84827
|
-
require_composed_stable_id.DeviceType.
|
|
84828
|
-
require_composed_stable_id.DeviceType.PetFeeder,
|
|
84829
|
-
require_composed_stable_id.DeviceType.Heater
|
|
85927
|
+
require_composed_stable_id.DeviceType.PetFeeder
|
|
84830
85928
|
];
|
|
84831
85929
|
var runningStateCapability = {
|
|
84832
85930
|
name: "running-state",
|
|
@@ -87514,8 +88612,7 @@ var switchCapability = {
|
|
|
87514
88612
|
require_composed_stable_id.DeviceType.Switch,
|
|
87515
88613
|
require_composed_stable_id.DeviceType.Siren,
|
|
87516
88614
|
require_composed_stable_id.DeviceType.Light,
|
|
87517
|
-
require_composed_stable_id.DeviceType.Fan
|
|
87518
|
-
require_composed_stable_id.DeviceType.Heater
|
|
88615
|
+
require_composed_stable_id.DeviceType.Fan
|
|
87519
88616
|
],
|
|
87520
88617
|
methods: { setState: require_sleep.method(zod.z.object({
|
|
87521
88618
|
deviceId: zod.z.number(),
|
|
@@ -88379,7 +89476,7 @@ var temperatureSensorCapability = {
|
|
|
88379
89476
|
scope: "device",
|
|
88380
89477
|
deviceNative: true,
|
|
88381
89478
|
mode: "singleton",
|
|
88382
|
-
deviceTypes: [require_composed_stable_id.DeviceType.Sensor, require_composed_stable_id.DeviceType.
|
|
89479
|
+
deviceTypes: [require_composed_stable_id.DeviceType.Sensor, require_composed_stable_id.DeviceType.Climate],
|
|
88383
89480
|
methods: {},
|
|
88384
89481
|
status: {
|
|
88385
89482
|
schema: TemperatureSensorStatusSchema,
|
|
@@ -90411,6 +91508,13 @@ var waterHeaterCapability = {
|
|
|
90411
91508
|
deviceNative: true,
|
|
90412
91509
|
mode: "singleton",
|
|
90413
91510
|
deviceTypes: [require_composed_stable_id.DeviceType.WaterHeater],
|
|
91511
|
+
power: {
|
|
91512
|
+
kind: "mode",
|
|
91513
|
+
field: "operationMode",
|
|
91514
|
+
offValue: "off",
|
|
91515
|
+
set: "setOperationMode",
|
|
91516
|
+
lastField: "lastActiveMode"
|
|
91517
|
+
},
|
|
90414
91518
|
methods: {
|
|
90415
91519
|
setTargetTemp: require_sleep.method(zod.z.object({
|
|
90416
91520
|
deviceId: zod.z.number().int().nonnegative(),
|
|
@@ -93972,6 +95076,13 @@ function describeTarget(site, ref) {
|
|
|
93972
95076
|
nativeCaps: new Map(device.caps.map((c) => [c, device.addonId]))
|
|
93973
95077
|
};
|
|
93974
95078
|
}
|
|
95079
|
+
/** The site as the time checks read it. */
|
|
95080
|
+
function readingOf$1(site) {
|
|
95081
|
+
return {
|
|
95082
|
+
location: site.location,
|
|
95083
|
+
timeZone: site.timeZone
|
|
95084
|
+
};
|
|
95085
|
+
}
|
|
93975
95086
|
function validateAutomation(site, json) {
|
|
93976
95087
|
const parsed = CurrentAutomationRecipeSchema.safeParse(json);
|
|
93977
95088
|
if (!parsed.success) return {
|
|
@@ -93983,7 +95094,8 @@ function validateAutomation(site, json) {
|
|
|
93983
95094
|
const issues = [
|
|
93984
95095
|
...bounds === null ? [] : [`when: ${bounds}`],
|
|
93985
95096
|
...leafIssues(site, recipe.when, "when"),
|
|
93986
|
-
...recipe.actions.flatMap((a, i) => stepIssues(site, a, `actions.${i}`))
|
|
95097
|
+
...recipe.actions.flatMap((a, i) => stepIssues(site, a, `actions.${i}`)),
|
|
95098
|
+
...recipeSiteIssues(recipe, readingOf$1(site)).map((i) => `${i.path}: ${i.message}`)
|
|
93987
95099
|
];
|
|
93988
95100
|
if (issues.length > 0) return {
|
|
93989
95101
|
ok: false,
|
|
@@ -94004,7 +95116,7 @@ function validateAction(site, json) {
|
|
|
94004
95116
|
ok: false,
|
|
94005
95117
|
issues: zodIssues(parsed.error)
|
|
94006
95118
|
};
|
|
94007
|
-
const issues = parsed.data.steps.flatMap((s, i) => stepIssues(site, s, `steps.${i}`));
|
|
95119
|
+
const issues = [...parsed.data.steps.flatMap((s, i) => stepIssues(site, s, `steps.${i}`)), ...stepGuardSiteIssues(parsed.data.steps, readingOf$1(site), "steps").map((i) => `${i.path}: ${i.message}`)];
|
|
94008
95120
|
return issues.length > 0 ? {
|
|
94009
95121
|
ok: false,
|
|
94010
95122
|
issues
|
|
@@ -94020,10 +95132,7 @@ function validateScheduler(site, json) {
|
|
|
94020
95132
|
issues: zodIssues(parsed.error)
|
|
94021
95133
|
};
|
|
94022
95134
|
const input = parsed.data;
|
|
94023
|
-
const verdict = validateSchedulerInput(input,
|
|
94024
|
-
location: site.location,
|
|
94025
|
-
timeZone: site.timeZone
|
|
94026
|
-
});
|
|
95135
|
+
const verdict = validateSchedulerInput(input, readingOf$1(site));
|
|
94027
95136
|
const issues = [
|
|
94028
95137
|
...verdict.ok ? [] : verdict.issues.map((i) => `${i.path}: ${i.message}`),
|
|
94029
95138
|
...input.activeWhen === void 0 ? [] : leafIssues(site, input.activeWhen, "activeWhen"),
|
|
@@ -97011,11 +98120,6 @@ function evaluateAggregate(input) {
|
|
|
97011
98120
|
}
|
|
97012
98121
|
//#endregion
|
|
97013
98122
|
//#region src/composition/helpers/source-pick.ts
|
|
97014
|
-
/**
|
|
97015
|
-
* The request the common source selector (#236) accepts for a helper (D944 §5).
|
|
97016
|
-
* The selector's layout is not specified here. Groups ask for one device type
|
|
97017
|
-
* and the catalog field; they do not opt into incompatible fields.
|
|
97018
|
-
*/
|
|
97019
98123
|
/** What the member step asks the selector for this template. */
|
|
97020
98124
|
function sourcePickForTemplate(template) {
|
|
97021
98125
|
const valueKind = template.family === "numeric" ? "number" : template.activeWhen === void 0 ? "boolean" : "state";
|
|
@@ -97097,30 +98201,6 @@ function sourcePickForMath(kind) {
|
|
|
97097
98201
|
function numericAccept() {
|
|
97098
98202
|
return historyAccept("statistic").filter((field) => field.valueKind === "number");
|
|
97099
98203
|
}
|
|
97100
|
-
/**
|
|
97101
|
-
* The one thing a naked heater needs at creation (D1004 point 5): the plug it
|
|
97102
|
-
* switches. On and off forward to that plug; no other facet is attached.
|
|
97103
|
-
*/
|
|
97104
|
-
function sourcePickForHeaterPlug() {
|
|
97105
|
-
return {
|
|
97106
|
-
fieldChoice: "operator",
|
|
97107
|
-
purpose: "member",
|
|
97108
|
-
multiple: false,
|
|
97109
|
-
max: 1,
|
|
97110
|
-
deviceTypes: [require_composed_stable_id.DeviceType.Switch],
|
|
97111
|
-
accept: [{
|
|
97112
|
-
cap: "switch",
|
|
97113
|
-
fieldPath: "on",
|
|
97114
|
-
valueKind: "boolean"
|
|
97115
|
-
}],
|
|
97116
|
-
history: {
|
|
97117
|
-
required: false,
|
|
97118
|
-
minRetentionMs: null
|
|
97119
|
-
},
|
|
97120
|
-
mustBindCaps: ["switch"],
|
|
97121
|
-
exclude: []
|
|
97122
|
-
};
|
|
97123
|
-
}
|
|
97124
98204
|
//#endregion
|
|
97125
98205
|
//#region src/composition/customize/field-source.ts
|
|
97126
98206
|
function fromRead(source, cap, fieldPath) {
|
|
@@ -97216,7 +98296,7 @@ function compileValue$1(input) {
|
|
|
97216
98296
|
const transform = input.draft.transform;
|
|
97217
98297
|
if (transform.kind === "identity" || transform.kind === "number") return {
|
|
97218
98298
|
ok: true,
|
|
97219
|
-
value: identityValue(read, input.sourceValueKind)
|
|
98299
|
+
value: identityValue(read, input.sourceValueKind, targetValueKind(input))
|
|
97220
98300
|
};
|
|
97221
98301
|
if (transform.kind === "invert") {
|
|
97222
98302
|
if (input.sourceValueKind !== "boolean") return fail$2("source-kind");
|
|
@@ -97229,8 +98309,16 @@ function compileValue$1(input) {
|
|
|
97229
98309
|
if (transform.kind === "linear") return linearValue$1(transform, read, input.sourceValueKind);
|
|
97230
98310
|
return fail$2("transform");
|
|
97231
98311
|
}
|
|
97232
|
-
|
|
97233
|
-
|
|
98312
|
+
/** The kind of the field a draft writes, from the catalog. */
|
|
98313
|
+
function targetValueKind(input) {
|
|
98314
|
+
return catalogTarget$4(input.draft.cap, input.draft.targetId)?.valueKind;
|
|
98315
|
+
}
|
|
98316
|
+
/**
|
|
98317
|
+
* A string reading feeds a NUMBER field through `number(x)`; a string field
|
|
98318
|
+
* (a fan `preset` linked to a select, D1034) takes the string as it is.
|
|
98319
|
+
*/
|
|
98320
|
+
function identityValue(read, valueKind, targetKind) {
|
|
98321
|
+
if (valueKind === "string" && targetKind !== "string" && targetKind !== "enum") return expression("number(x)", { x: read });
|
|
97234
98322
|
return read;
|
|
97235
98323
|
}
|
|
97236
98324
|
/**
|
|
@@ -97312,7 +98400,7 @@ function compileCompanions$1(input, target, value) {
|
|
|
97312
98400
|
});
|
|
97313
98401
|
}
|
|
97314
98402
|
function companionIncluded$1(companion, apply) {
|
|
97315
|
-
if (companion.kind === "transition-time") return true;
|
|
98403
|
+
if (companion.kind === "transition-time" || companion.kind === "source-field") return true;
|
|
97316
98404
|
return companion.when === "always" || apply === "add";
|
|
97317
98405
|
}
|
|
97318
98406
|
function companionField(input, path, companion, value) {
|
|
@@ -97328,6 +98416,10 @@ function companionField(input, path, companion, value) {
|
|
|
97328
98416
|
ok: true,
|
|
97329
98417
|
value: literal("now")
|
|
97330
98418
|
};
|
|
98419
|
+
if (companion.kind === "source-field") return {
|
|
98420
|
+
ok: true,
|
|
98421
|
+
value: fromRead(refOf$1(input.draft), input.draft.source.cap, companion.field)
|
|
98422
|
+
};
|
|
97331
98423
|
return transitionField(input, path, companion.sourceChangedAt, value);
|
|
97332
98424
|
}
|
|
97333
98425
|
function transitionField(input, path, sourceChangedAt, value) {
|
|
@@ -97521,7 +98613,12 @@ function describeRead(read) {
|
|
|
97521
98613
|
function isConfirmed(reading) {
|
|
97522
98614
|
return reading.fatal || reading.confirmed === true;
|
|
97523
98615
|
}
|
|
97524
|
-
|
|
98616
|
+
/** Whether a non-null value is of the kind a field of `kind` holds. */
|
|
98617
|
+
function valueFitsKind(value, kind) {
|
|
98618
|
+
if (value === null) return true;
|
|
98619
|
+
return typeof value === (kind === "enum" ? "string" : kind);
|
|
98620
|
+
}
|
|
98621
|
+
function fromReading(reading, read, targetKind) {
|
|
97525
98622
|
if (reading.state === "unavailable") return {
|
|
97526
98623
|
state: "unavailable",
|
|
97527
98624
|
value: null,
|
|
@@ -97529,6 +98626,13 @@ function fromReading(reading, read) {
|
|
|
97529
98626
|
fatal: reading.fatal,
|
|
97530
98627
|
confirmed: isConfirmed(reading)
|
|
97531
98628
|
};
|
|
98629
|
+
if (targetKind !== void 0 && !valueFitsKind(reading.value, targetKind)) return {
|
|
98630
|
+
state: "unavailable",
|
|
98631
|
+
value: null,
|
|
98632
|
+
reason: `${describeRead(read)}: source-kind-mismatch, it reads a ${typeof reading.value} and the field takes a ${targetKind}`,
|
|
98633
|
+
fatal: false,
|
|
98634
|
+
confirmed: true
|
|
98635
|
+
};
|
|
97532
98636
|
return {
|
|
97533
98637
|
state: reading.state,
|
|
97534
98638
|
value: reading.value,
|
|
@@ -97652,7 +98756,7 @@ function aggregateField(source, read) {
|
|
|
97652
98756
|
function evaluateCompositionField(input) {
|
|
97653
98757
|
const { source } = input;
|
|
97654
98758
|
switch (source.kind) {
|
|
97655
|
-
case "from": return fromReading(input.read(source), source);
|
|
98759
|
+
case "from": return fromReading(input.read(source), source, input.targetKind);
|
|
97656
98760
|
case "expression": return expressionOutcome(source, input.read, input.now, input.stateful);
|
|
97657
98761
|
case "aggregate": return aggregateField(source, input.read);
|
|
97658
98762
|
case "series": return {
|
|
@@ -97888,56 +98992,6 @@ function lockDoorLinkOfComposition(composition) {
|
|
|
97888
98992
|
};
|
|
97889
98993
|
}
|
|
97890
98994
|
//#endregion
|
|
97891
|
-
//#region src/composition/power-source-link.ts
|
|
97892
|
-
/**
|
|
97893
|
-
* Which smart switch powers a device (the `power-source` Customize extension):
|
|
97894
|
-
* the source its stored `power-source.switchOn` field reads, and the off time of
|
|
97895
|
-
* a forced restart stored beside it. Read from the STORED composition, never kept
|
|
97896
|
-
* as a second copy (D676). Shared by the hub (which acts on the switch) and the
|
|
97897
|
-
* admin UI (which shows it).
|
|
97898
|
-
*/
|
|
97899
|
-
/**
|
|
97900
|
-
* The stored off time, or the default when none is stored. A stored number out
|
|
97901
|
-
* of range is CLAMPED to the bounds (a hand-written value never refuses the
|
|
97902
|
-
* link, it just cannot cut power for an absurd time); a non-integer is rounded.
|
|
97903
|
-
*/
|
|
97904
|
-
function normalizeOffSeconds(value) {
|
|
97905
|
-
if (typeof value !== "number" || !Number.isFinite(value)) return 10;
|
|
97906
|
-
return Math.min(120, Math.max(3, Math.round(value)));
|
|
97907
|
-
}
|
|
97908
|
-
/** The constant a stored `offSeconds` field carries, or undefined when it is not a literal number. */
|
|
97909
|
-
function storedOffSeconds(composition) {
|
|
97910
|
-
const feature = composition.features.find((f) => f.cap === "power-source");
|
|
97911
|
-
if (feature === void 0 || feature.kind !== "fields") return void 0;
|
|
97912
|
-
const field = feature.fields["offSeconds"];
|
|
97913
|
-
if (field === void 0 || field.kind !== "expression") return void 0;
|
|
97914
|
-
const n = Number(field.expr);
|
|
97915
|
-
return field.expr.trim() === "" || !Number.isFinite(n) ? void 0 : n;
|
|
97916
|
-
}
|
|
97917
|
-
/**
|
|
97918
|
-
* The link a composition stores. An `existing` target names its own device; a
|
|
97919
|
-
* `new` target (a composed device) is the composer's own device, so the caller
|
|
97920
|
-
* passes the block id and a new-target composition without one has no link.
|
|
97921
|
-
*/
|
|
97922
|
-
function powerSourceLinkOfComposition(composition, blockId) {
|
|
97923
|
-
if (composition === null) return null;
|
|
97924
|
-
let device;
|
|
97925
|
-
if (composition.target.kind === "existing") device = composition.target.device;
|
|
97926
|
-
else if (blockId !== void 0) device = require_implemented_methods.composedDeviceRef(blockId);
|
|
97927
|
-
else return null;
|
|
97928
|
-
const feature = composition.features.find((f) => f.cap === "power-source");
|
|
97929
|
-
if (feature === void 0 || feature.kind !== "fields" || feature.enabled === false) return null;
|
|
97930
|
-
const field = feature.fields["switchOn"];
|
|
97931
|
-
if (field === void 0) return null;
|
|
97932
|
-
const read = require_implemented_methods.fieldReads(field).find((r) => r.cap === "switch");
|
|
97933
|
-
if (read === void 0) return null;
|
|
97934
|
-
return {
|
|
97935
|
-
device,
|
|
97936
|
-
switch: read.source,
|
|
97937
|
-
offSeconds: normalizeOffSeconds(storedOffSeconds(composition))
|
|
97938
|
-
};
|
|
97939
|
-
}
|
|
97940
|
-
//#endregion
|
|
97941
98995
|
//#region src/composition/presets/numeric-transforms.ts
|
|
97942
98996
|
/**
|
|
97943
98997
|
* Self-only invert / unit-convert composition features (D663, D939).
|
|
@@ -98765,7 +99819,7 @@ function drafted(field, transform, sourceValueKind, cap, targetId) {
|
|
|
98765
99819
|
};
|
|
98766
99820
|
}
|
|
98767
99821
|
function inferApply$1(target, fields) {
|
|
98768
|
-
const addPaths = (target.companions ?? []).flatMap((companion) => companion.kind
|
|
99822
|
+
const addPaths = (target.companions ?? []).flatMap((companion) => (companion.kind === "constant" || companion.kind === "clock") && companion.when === "add" ? [companion.path] : []);
|
|
98769
99823
|
if (addPaths.length === 0) return "replace";
|
|
98770
99824
|
const present = addPaths.filter((path) => fields[path] !== void 0);
|
|
98771
99825
|
if (present.length === addPaths.length) return "add";
|
|
@@ -99110,7 +100164,7 @@ function compileCompanions(target, apply) {
|
|
|
99110
100164
|
});
|
|
99111
100165
|
}
|
|
99112
100166
|
function companionIncluded(companion, apply) {
|
|
99113
|
-
if (companion.kind === "transition-time") return false;
|
|
100167
|
+
if (companion.kind === "transition-time" || companion.kind === "source-field") return false;
|
|
99114
100168
|
return companion.when === "always" || apply === "add";
|
|
99115
100169
|
}
|
|
99116
100170
|
function refOf(draft) {
|
|
@@ -99289,7 +100343,7 @@ function isConstant(source) {
|
|
|
99289
100343
|
return source?.kind === "expression" && Object.keys(source.bindings).length === 0;
|
|
99290
100344
|
}
|
|
99291
100345
|
function inferApply(target, fields) {
|
|
99292
|
-
const addPaths = (target.companions ?? []).flatMap((companion) => companion.kind
|
|
100346
|
+
const addPaths = (target.companions ?? []).flatMap((companion) => (companion.kind === "constant" || companion.kind === "clock") && companion.when === "add" ? [companion.path] : []);
|
|
99293
100347
|
if (addPaths.length === 0) return "replace";
|
|
99294
100348
|
const present = addPaths.filter((path) => fields[path] !== void 0);
|
|
99295
100349
|
if (present.length === addPaths.length) return "add";
|
|
@@ -99298,7 +100352,7 @@ function inferApply(target, fields) {
|
|
|
99298
100352
|
}
|
|
99299
100353
|
function companionsMatch(target, fields, apply) {
|
|
99300
100354
|
const expected = (target.companions ?? []).flatMap((companion) => {
|
|
99301
|
-
if (companion.kind === "transition-time") return [];
|
|
100355
|
+
if (companion.kind === "transition-time" || companion.kind === "source-field") return [];
|
|
99302
100356
|
if (companion.when === "always" || apply === "add") return [companion.path];
|
|
99303
100357
|
return [];
|
|
99304
100358
|
});
|
|
@@ -101362,15 +102416,16 @@ var BaseDeviceProvider = class extends require_sleep.BaseAddon {
|
|
|
101362
102416
|
});
|
|
101363
102417
|
const meta = await this.ctx.api.deviceManager.loadMeta.query({ deviceId: id });
|
|
101364
102418
|
if (meta === null) throw new Error(`${this.providerName}: no persisted meta for "${stableId}" (id ${id}) — cannot reload`);
|
|
101365
|
-
const
|
|
101366
|
-
|
|
102419
|
+
const Class = this.deviceClassForRow({
|
|
102420
|
+
type: meta.type,
|
|
102421
|
+
stableId
|
|
102422
|
+
});
|
|
101367
102423
|
if (!Class) throw new Error(`${this.providerName}: no device class for type "${meta.type}" — "${stableId}" is an accessory child; reload its parent instead`);
|
|
101368
102424
|
await devices.create(stableId, Class, {}, meta.parentDeviceId ?? null);
|
|
101369
102425
|
const rows = await this.ctx.api.deviceManager.listPersistedByAddon.query({ addonId: this.addonId });
|
|
101370
102426
|
for (const row of rows) {
|
|
101371
102427
|
if (row.parentDeviceId !== id) continue;
|
|
101372
|
-
const
|
|
101373
|
-
const ChildClass = childType !== void 0 ? this.deviceClasses[childType] : void 0;
|
|
102428
|
+
const ChildClass = this.deviceClassForRow(row);
|
|
101374
102429
|
if (!ChildClass) continue;
|
|
101375
102430
|
try {
|
|
101376
102431
|
await devices.create(row.stableId, ChildClass, {}, id);
|
|
@@ -101397,6 +102452,16 @@ var BaseDeviceProvider = class extends require_sleep.BaseAddon {
|
|
|
101397
102452
|
return { deviceId: id };
|
|
101398
102453
|
}
|
|
101399
102454
|
/**
|
|
102455
|
+
* The class a PERSISTED row is rebuilt with. Default: by type, from
|
|
102456
|
+
* `deviceClasses`. A provider whose distinct devices share one type (D1033:
|
|
102457
|
+
* a radiator valve and a room climate are both `climate`) overrides this
|
|
102458
|
+
* and tells them apart by the row's stable id or config.
|
|
102459
|
+
*/
|
|
102460
|
+
deviceClassForRow(row) {
|
|
102461
|
+
const type = Object.values(require_composed_stable_id.DeviceType).find((t) => t === row.type);
|
|
102462
|
+
return type !== void 0 ? this.deviceClasses[type] : void 0;
|
|
102463
|
+
}
|
|
102464
|
+
/**
|
|
101400
102465
|
* Restore devices from persisted state. Two-pass:
|
|
101401
102466
|
*
|
|
101402
102467
|
* 1. **Top-level pass** — invokes `kernel.devices.create()` for every
|
|
@@ -101457,7 +102522,7 @@ var BaseDeviceProvider = class extends require_sleep.BaseAddon {
|
|
|
101457
102522
|
restored.add(saved.id);
|
|
101458
102523
|
return;
|
|
101459
102524
|
}
|
|
101460
|
-
const Class = this.
|
|
102525
|
+
const Class = this.deviceClassForRow(saved);
|
|
101461
102526
|
if (!Class) throw new Error(`no device class registered for type "${saved.type}"`);
|
|
101462
102527
|
if (saved.parentDeviceId !== null && !restored.has(saved.parentDeviceId)) throw new Error(`parent device ${saved.parentDeviceId} not restored`);
|
|
101463
102528
|
await this.healSavedConfig(saved, savedDevices);
|
|
@@ -101474,7 +102539,7 @@ var BaseDeviceProvider = class extends require_sleep.BaseAddon {
|
|
|
101474
102539
|
};
|
|
101475
102540
|
const topLevel = savedDevices.filter((saved) => saved.parentDeviceId === null);
|
|
101476
102541
|
const restoreOne = async (saved) => {
|
|
101477
|
-
if (!this.
|
|
102542
|
+
if (!this.deviceClassForRow(saved)) {
|
|
101478
102543
|
this.ctx.logger.warn("No device class registered for restored type — skipping", {
|
|
101479
102544
|
tags: {
|
|
101480
102545
|
deviceId: saved.id,
|
|
@@ -101513,7 +102578,7 @@ var BaseDeviceProvider = class extends require_sleep.BaseAddon {
|
|
|
101513
102578
|
const failedTopLevelIds = new Set(failures.map((failure) => failure.saved.id));
|
|
101514
102579
|
const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
|
|
101515
102580
|
for (const saved of childRows) {
|
|
101516
|
-
if (!this.
|
|
102581
|
+
if (!this.deviceClassForRow(saved)) continue;
|
|
101517
102582
|
if (saved.parentDeviceId === null) continue;
|
|
101518
102583
|
if (restored.has(saved.parentDeviceId)) {
|
|
101519
102584
|
try {
|
|
@@ -101704,7 +102769,6 @@ function applyPrimaryChildRule(rule, children) {
|
|
|
101704
102769
|
var CONTAINER_CHILD_PRIORITY = [
|
|
101705
102770
|
"media-player",
|
|
101706
102771
|
"alarm-panel",
|
|
101707
|
-
"thermostat",
|
|
101708
102772
|
"climate",
|
|
101709
102773
|
"humidifier",
|
|
101710
102774
|
"water-heater",
|
|
@@ -102324,6 +103388,73 @@ function widenDeviceConstructor(ctor) {
|
|
|
102324
103388
|
return ctor;
|
|
102325
103389
|
}
|
|
102326
103390
|
//#endregion
|
|
103391
|
+
//#region src/device/device-kind.ts
|
|
103392
|
+
/**
|
|
103393
|
+
* A device's KIND is its type plus its role (D1033): the type is the set of
|
|
103394
|
+
* controls it has, the role says which thing it is among the devices that
|
|
103395
|
+
* share those controls. A plug-in heater is a `switch` with role
|
|
103396
|
+
* `switch-heater`; an air conditioner and a radiator valve are both `climate`,
|
|
103397
|
+
* told apart by their `climate-*` role.
|
|
103398
|
+
*/
|
|
103399
|
+
/**
|
|
103400
|
+
* Type values a persisted row may still carry after the type was retired, and
|
|
103401
|
+
* the type each one is read as. The row is rewritten by the next registration
|
|
103402
|
+
* of the device (its provider stamps the live type), so this is a read alias,
|
|
103403
|
+
* not a migration.
|
|
103404
|
+
*
|
|
103405
|
+
* `heater` is deliberately absent: the only heaters were composed devices the
|
|
103406
|
+
* operator deletes. Such a row stays an unknown type, which every reader
|
|
103407
|
+
* treats as a generic device.
|
|
103408
|
+
*/
|
|
103409
|
+
var RETIRED_DEVICE_TYPES = { thermostat: require_composed_stable_id.DeviceType.Climate };
|
|
103410
|
+
/** The live type a stored `type` value stands for (itself unless retired). */
|
|
103411
|
+
function canonicalStoredDeviceType(stored) {
|
|
103412
|
+
return RETIRED_DEVICE_TYPES[stored] ?? stored;
|
|
103413
|
+
}
|
|
103414
|
+
/** The `climate-*` roles, in the order the role picker lists them. */
|
|
103415
|
+
var CLIMATE_ROLES = [
|
|
103416
|
+
require_composed_stable_id.DeviceRole.ClimateThermostat,
|
|
103417
|
+
require_composed_stable_id.DeviceRole.ClimateAc,
|
|
103418
|
+
require_composed_stable_id.DeviceRole.ClimateRadiator,
|
|
103419
|
+
require_composed_stable_id.DeviceRole.ClimateFloor,
|
|
103420
|
+
require_composed_stable_id.DeviceRole.ClimateHeater,
|
|
103421
|
+
require_composed_stable_id.DeviceRole.ClimateHeatPumpCircuit
|
|
103422
|
+
];
|
|
103423
|
+
function isClimateRole(role) {
|
|
103424
|
+
return CLIMATE_ROLES.some((candidate) => candidate === role);
|
|
103425
|
+
}
|
|
103426
|
+
/**
|
|
103427
|
+
* Which climate device this is. A climate device with no role, or a role that
|
|
103428
|
+
* is not a climate one, is a room thermostat: that is what most of them are,
|
|
103429
|
+
* and it is the presentation a thermostat had before the types were folded.
|
|
103430
|
+
*/
|
|
103431
|
+
function climateRoleOf(role) {
|
|
103432
|
+
return role !== null && role !== void 0 && isClimateRole(role) ? role : require_composed_stable_id.DeviceRole.ClimateThermostat;
|
|
103433
|
+
}
|
|
103434
|
+
/** An air conditioner: exports present it as an AC unit, not a thermostat. */
|
|
103435
|
+
function isAirConditioner(type, role) {
|
|
103436
|
+
return type === require_composed_stable_id.DeviceType.Climate && climateRoleOf(role) === require_composed_stable_id.DeviceRole.ClimateAc;
|
|
103437
|
+
}
|
|
103438
|
+
/**
|
|
103439
|
+
* Is a capability offered on a device of this type and role?
|
|
103440
|
+
*
|
|
103441
|
+
* Fails open where the old type-only gate did: no `deviceTypes` (or an empty
|
|
103442
|
+
* list) applies to every device, and an unknown type never filters (a failed
|
|
103443
|
+
* meta read must not destroy work, D49). A type the cap's `deviceRoles` names
|
|
103444
|
+
* is offered only to the roles listed there; an unknown role is NOT one of
|
|
103445
|
+
* them, so a `switch` whose role could not be read is not a heater.
|
|
103446
|
+
*/
|
|
103447
|
+
function capAppliesToDeviceKind(gate, deviceType, role) {
|
|
103448
|
+
if (deviceType === void 0) return true;
|
|
103449
|
+
const types = gate?.deviceTypes;
|
|
103450
|
+
if (!types || types.length === 0) return true;
|
|
103451
|
+
const type = types.find((candidate) => candidate === deviceType);
|
|
103452
|
+
if (type === void 0) return false;
|
|
103453
|
+
const roles = gate?.deviceRoles?.[type];
|
|
103454
|
+
if (roles === void 0) return true;
|
|
103455
|
+
return role !== null && role !== void 0 && roles.some((candidate) => candidate === role);
|
|
103456
|
+
}
|
|
103457
|
+
//#endregion
|
|
102327
103458
|
//#region src/device/device-control-resolution.ts
|
|
102328
103459
|
/**
|
|
102329
103460
|
* Device-control RESOLUTION LOGIC — the single, presentation-free source of
|
|
@@ -102376,8 +103507,7 @@ var DEVICE_TYPE_CONTROL_KIND = {
|
|
|
102376
103507
|
[require_composed_stable_id.DeviceType.Light]: "light",
|
|
102377
103508
|
[require_composed_stable_id.DeviceType.Fan]: "fan",
|
|
102378
103509
|
[require_composed_stable_id.DeviceType.Sensor]: "sensor",
|
|
102379
|
-
[require_composed_stable_id.DeviceType.
|
|
102380
|
-
[require_composed_stable_id.DeviceType.Climate]: "climate",
|
|
103510
|
+
[require_composed_stable_id.DeviceType.Climate]: "thermostat",
|
|
102381
103511
|
[require_composed_stable_id.DeviceType.Button]: "button",
|
|
102382
103512
|
[require_composed_stable_id.DeviceType.EventEmitter]: "dummy",
|
|
102383
103513
|
[require_composed_stable_id.DeviceType.Update]: "update",
|
|
@@ -102397,7 +103527,6 @@ var DEVICE_TYPE_CONTROL_KIND = {
|
|
|
102397
103527
|
[require_composed_stable_id.DeviceType.Image]: "image",
|
|
102398
103528
|
[require_composed_stable_id.DeviceType.PetFeeder]: "pet-feeder",
|
|
102399
103529
|
[require_composed_stable_id.DeviceType.PetFountain]: "pet-fountain",
|
|
102400
|
-
[require_composed_stable_id.DeviceType.Heater]: "heater",
|
|
102401
103530
|
[require_composed_stable_id.DeviceType.Dishwasher]: "dishwasher",
|
|
102402
103531
|
[require_composed_stable_id.DeviceType.Washer]: "appliance",
|
|
102403
103532
|
[require_composed_stable_id.DeviceType.Dryer]: "appliance",
|
|
@@ -102411,8 +103540,11 @@ var DEVICE_TYPE_VALUES = new Set(Object.values(require_composed_stable_id.Device
|
|
|
102411
103540
|
* narrows the string to a `DeviceType` before indexing (documented enum-string
|
|
102412
103541
|
* boundary).
|
|
102413
103542
|
*/
|
|
102414
|
-
function resolveDeviceControlKind(type) {
|
|
102415
|
-
|
|
103543
|
+
function resolveDeviceControlKind(type, role) {
|
|
103544
|
+
if (!DEVICE_TYPE_VALUES.has(type)) return null;
|
|
103545
|
+
if (isAirConditioner(type, role)) return "climate";
|
|
103546
|
+
if (type === require_composed_stable_id.DeviceType.Switch && role === require_composed_stable_id.DeviceRole.SwitchHeater) return "heater";
|
|
103547
|
+
return DEVICE_TYPE_CONTROL_KIND[type];
|
|
102416
103548
|
}
|
|
102417
103549
|
/** Kebab feature flag advertised by an accessory that auto-activates when its
|
|
102418
103550
|
* parent camera detects motion. The cap's kebab name is `motion-trigger` (see
|
|
@@ -104734,9 +105866,6 @@ function durationText(seconds) {
|
|
|
104734
105866
|
const text = `${Math.floor(m / 60)} h ${String(m % 60).padStart(2, "0")}`;
|
|
104735
105867
|
return require_sleep.t(text, text);
|
|
104736
105868
|
}
|
|
104737
|
-
function deviceTypeOf(type) {
|
|
104738
|
-
return Object.values(require_composed_stable_id.DeviceType).find((t) => t === type);
|
|
104739
|
-
}
|
|
104740
105869
|
var switchContribution = contribution("switch", SwitchStatusSchema, (slice) => {
|
|
104741
105870
|
const on = slice?.on ?? null;
|
|
104742
105871
|
return {
|
|
@@ -104917,8 +106046,7 @@ function remainingWords(amount, unit) {
|
|
|
104917
106046
|
return require_sleep.t(`${amount} ${word}`, `${amount} ${word}`);
|
|
104918
106047
|
}
|
|
104919
106048
|
var timedRunContribution = contribution("timed-run", TimedRunStatusSchema, (slice, ctx) => {
|
|
104920
|
-
const
|
|
104921
|
-
const limit = type === void 0 ? null : timedRunLimitOf(type);
|
|
106049
|
+
const limit = timedRunLimitOf(ctx.type, ctx.role);
|
|
104922
106050
|
if (limit === null) return {};
|
|
104923
106051
|
const quickRun = slice?.quickRun ?? timedRunQuickRun(limit, null);
|
|
104924
106052
|
const activeUntil = slice?.activeUntil != null && slice.activeUntil > ctx.now ? slice.activeUntil : null;
|
|
@@ -105359,7 +106487,6 @@ var HERO_LAYOUT_BY_TYPE = {
|
|
|
105359
106487
|
[require_composed_stable_id.DeviceType.Siren]: HERO_LAYOUT_DEFAULT,
|
|
105360
106488
|
[require_composed_stable_id.DeviceType.Switch]: SWITCH_LAYOUT,
|
|
105361
106489
|
[require_composed_stable_id.DeviceType.Sensor]: HERO_LAYOUT_DEFAULT,
|
|
105362
|
-
[require_composed_stable_id.DeviceType.Thermostat]: CLIMATE_LAYOUT,
|
|
105363
106490
|
[require_composed_stable_id.DeviceType.Climate]: CLIMATE_LAYOUT,
|
|
105364
106491
|
[require_composed_stable_id.DeviceType.Button]: BUTTON_LAYOUT,
|
|
105365
106492
|
[require_composed_stable_id.DeviceType.EventEmitter]: HERO_LAYOUT_DEFAULT,
|
|
@@ -105388,7 +106515,6 @@ var HERO_LAYOUT_BY_TYPE = {
|
|
|
105388
106515
|
[require_composed_stable_id.DeviceType.PetFountain]: FOUNTAIN_LAYOUT,
|
|
105389
106516
|
[require_composed_stable_id.DeviceType.Dishwasher]: DISHWASHER_LAYOUT,
|
|
105390
106517
|
[require_composed_stable_id.DeviceType.Washer]: APPLIANCE_LAYOUT,
|
|
105391
|
-
[require_composed_stable_id.DeviceType.Heater]: HEATER_LAYOUT,
|
|
105392
106518
|
[require_composed_stable_id.DeviceType.Dryer]: APPLIANCE_LAYOUT,
|
|
105393
106519
|
[require_composed_stable_id.DeviceType.Gateway]: HERO_LAYOUT_DEFAULT
|
|
105394
106520
|
};
|
|
@@ -105396,7 +106522,8 @@ function isDeviceType$1(type) {
|
|
|
105396
106522
|
return Object.values(require_composed_stable_id.DeviceType).includes(type);
|
|
105397
106523
|
}
|
|
105398
106524
|
/** The layout of a type; a type this build does not know gets the default. */
|
|
105399
|
-
function resolveHeroLayout(type) {
|
|
106525
|
+
function resolveHeroLayout(type, role = null) {
|
|
106526
|
+
if (type === require_composed_stable_id.DeviceType.Switch && role === require_composed_stable_id.DeviceRole.SwitchHeater) return HEATER_LAYOUT;
|
|
105400
106527
|
return isDeviceType$1(type) ? HERO_LAYOUT_BY_TYPE[type] : HERO_LAYOUT_DEFAULT;
|
|
105401
106528
|
}
|
|
105402
106529
|
//#endregion
|
|
@@ -106077,7 +107204,7 @@ var HERO_MODE_LOOK = {
|
|
|
106077
107204
|
open: null,
|
|
106078
107205
|
closed: null
|
|
106079
107206
|
};
|
|
106080
|
-
var MODE_LOOK_TYPES = [require_composed_stable_id.DeviceType.Climate
|
|
107207
|
+
var MODE_LOOK_TYPES = [require_composed_stable_id.DeviceType.Climate];
|
|
106081
107208
|
var HERO_LOOK_BY_TYPE = {
|
|
106082
107209
|
[require_composed_stable_id.DeviceType.Camera]: CAMERA_LOOK,
|
|
106083
107210
|
[require_composed_stable_id.DeviceType.Hub]: HERO_LOOK_DEFAULT,
|
|
@@ -106085,8 +107212,7 @@ var HERO_LOOK_BY_TYPE = {
|
|
|
106085
107212
|
[require_composed_stable_id.DeviceType.Siren]: HERO_LOOK_DEFAULT,
|
|
106086
107213
|
[require_composed_stable_id.DeviceType.Switch]: SWITCH_LOOK,
|
|
106087
107214
|
[require_composed_stable_id.DeviceType.Sensor]: READING_SENSOR_LOOK,
|
|
106088
|
-
[require_composed_stable_id.DeviceType.
|
|
106089
|
-
[require_composed_stable_id.DeviceType.Climate]: CLIMATE_LOOK,
|
|
107215
|
+
[require_composed_stable_id.DeviceType.Climate]: THERMOSTAT_LOOK,
|
|
106090
107216
|
[require_composed_stable_id.DeviceType.Button]: BUTTON_LOOK,
|
|
106091
107217
|
[require_composed_stable_id.DeviceType.EventEmitter]: EVENT_EMITTER_LOOK,
|
|
106092
107218
|
[require_composed_stable_id.DeviceType.Update]: UPDATE_LOOK,
|
|
@@ -106114,7 +107240,6 @@ var HERO_LOOK_BY_TYPE = {
|
|
|
106114
107240
|
[require_composed_stable_id.DeviceType.PetFountain]: FOUNTAIN_LOOK,
|
|
106115
107241
|
[require_composed_stable_id.DeviceType.Dishwasher]: DISHWASHER_LOOK,
|
|
106116
107242
|
[require_composed_stable_id.DeviceType.Washer]: WASHER_LOOK,
|
|
106117
|
-
[require_composed_stable_id.DeviceType.Heater]: HEATER_LOOK,
|
|
106118
107243
|
[require_composed_stable_id.DeviceType.Dryer]: DRYER_LOOK,
|
|
106119
107244
|
[require_composed_stable_id.DeviceType.Gateway]: HERO_LOOK_DEFAULT
|
|
106120
107245
|
};
|
|
@@ -106139,6 +107264,14 @@ var HERO_LOOK_BY_ROLE = {
|
|
|
106139
107264
|
[require_composed_stable_id.DeviceRole.CoverWindow]: "inherit",
|
|
106140
107265
|
[require_composed_stable_id.DeviceRole.BinaryHelper]: "inherit",
|
|
106141
107266
|
[require_composed_stable_id.DeviceRole.Outlet]: "inherit",
|
|
107267
|
+
[require_composed_stable_id.DeviceRole.SwitchHeater]: HEATER_LOOK,
|
|
107268
|
+
[require_composed_stable_id.DeviceRole.SwitchFan]: FAN_LOOK,
|
|
107269
|
+
[require_composed_stable_id.DeviceRole.ClimateAc]: "inherit",
|
|
107270
|
+
[require_composed_stable_id.DeviceRole.ClimateThermostat]: "inherit",
|
|
107271
|
+
[require_composed_stable_id.DeviceRole.ClimateFloor]: "inherit",
|
|
107272
|
+
[require_composed_stable_id.DeviceRole.ClimateRadiator]: "inherit",
|
|
107273
|
+
[require_composed_stable_id.DeviceRole.ClimateHeater]: "inherit",
|
|
107274
|
+
[require_composed_stable_id.DeviceRole.ClimateHeatPumpCircuit]: "inherit",
|
|
106142
107275
|
[require_composed_stable_id.DeviceRole.MotionSensor]: MOTION_LOOK,
|
|
106143
107276
|
[require_composed_stable_id.DeviceRole.ContactSensor]: "inherit",
|
|
106144
107277
|
[require_composed_stable_id.DeviceRole.LeakSensor]: LEAK_LOOK,
|
|
@@ -106196,6 +107329,7 @@ function resolveHeroLook(role, type, state, mode = null) {
|
|
|
106196
107329
|
const byMode = HERO_MODE_LOOK[mode];
|
|
106197
107330
|
if (byMode !== null) return byMode;
|
|
106198
107331
|
}
|
|
107332
|
+
if (isAirConditioner(type, role)) return CLIMATE_LOOK[state];
|
|
106199
107333
|
return ((isDeviceType(type) ? HERO_LOOK_BY_TYPE[type] : void 0) ?? HERO_LOOK_DEFAULT)[state];
|
|
106200
107334
|
}
|
|
106201
107335
|
/** Every look the model declares, for the exhaustiveness guard and its spec. */
|
|
@@ -106378,6 +107512,7 @@ function buildHeroModel(input) {
|
|
|
106378
107512
|
const ctx = {
|
|
106379
107513
|
deviceId: device.id,
|
|
106380
107514
|
type: device.type,
|
|
107515
|
+
role: device.role,
|
|
106381
107516
|
features: input.features,
|
|
106382
107517
|
now: input.now,
|
|
106383
107518
|
running: runningOf(input),
|
|
@@ -106406,7 +107541,7 @@ function buildHeroModel(input) {
|
|
|
106406
107541
|
}
|
|
106407
107542
|
};
|
|
106408
107543
|
const allRows = fragments.flatMap((f) => f.rows ?? []);
|
|
106409
|
-
const rows = resolveHeroLayout(device.type).rows.flatMap((id) => {
|
|
107544
|
+
const rows = resolveHeroLayout(device.type, device.role).rows.flatMap((id) => {
|
|
106410
107545
|
return allRows.filter((r) => r.id === id).map((r) => HERO_SCENE_ROW_IDS.has(r.id) ? {
|
|
106411
107546
|
...r,
|
|
106412
107547
|
placement: "scene"
|
|
@@ -109983,6 +111118,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
109983
111118
|
access: "create",
|
|
109984
111119
|
role: "viewer"
|
|
109985
111120
|
},
|
|
111121
|
+
"fanControl.setOscillationAxis": {
|
|
111122
|
+
capName: "fan-control",
|
|
111123
|
+
capScope: "device",
|
|
111124
|
+
addonId: null,
|
|
111125
|
+
access: "create",
|
|
111126
|
+
role: "viewer"
|
|
111127
|
+
},
|
|
109986
111128
|
"fanControl.setPercentage": {
|
|
109987
111129
|
capName: "fan-control",
|
|
109988
111130
|
capScope: "device",
|
|
@@ -117502,7 +118644,6 @@ var DEVICE_TYPE_DO_CAPS = {
|
|
|
117502
118644
|
[require_composed_stable_id.DeviceType.Siren]: ["switch", "motion-trigger"],
|
|
117503
118645
|
[require_composed_stable_id.DeviceType.Switch]: ["switch", "motion-trigger"],
|
|
117504
118646
|
[require_composed_stable_id.DeviceType.Sensor]: [],
|
|
117505
|
-
[require_composed_stable_id.DeviceType.Thermostat]: ["climate-control"],
|
|
117506
118647
|
[require_composed_stable_id.DeviceType.Climate]: ["climate-control"],
|
|
117507
118648
|
[require_composed_stable_id.DeviceType.Button]: ["button"],
|
|
117508
118649
|
[require_composed_stable_id.DeviceType.EventEmitter]: [],
|
|
@@ -117529,7 +118670,6 @@ var DEVICE_TYPE_DO_CAPS = {
|
|
|
117529
118670
|
[require_composed_stable_id.DeviceType.Image]: [],
|
|
117530
118671
|
[require_composed_stable_id.DeviceType.PetFeeder]: ["pet-feeder"],
|
|
117531
118672
|
[require_composed_stable_id.DeviceType.PetFountain]: ["pet-fountain", "timed-run"],
|
|
117532
|
-
[require_composed_stable_id.DeviceType.Heater]: ["switch", "timed-run"],
|
|
117533
118673
|
[require_composed_stable_id.DeviceType.Dishwasher]: ["dishwasher"],
|
|
117534
118674
|
[require_composed_stable_id.DeviceType.Washer]: [],
|
|
117535
118675
|
[require_composed_stable_id.DeviceType.Dryer]: [],
|
|
@@ -117554,7 +118694,6 @@ function isDoPickerDeviceType(type) {
|
|
|
117554
118694
|
function deviceDoFamily(type) {
|
|
117555
118695
|
switch (type) {
|
|
117556
118696
|
case require_composed_stable_id.DeviceType.Climate:
|
|
117557
|
-
case require_composed_stable_id.DeviceType.Thermostat:
|
|
117558
118697
|
case require_composed_stable_id.DeviceType.Humidifier:
|
|
117559
118698
|
case require_composed_stable_id.DeviceType.WaterHeater:
|
|
117560
118699
|
case require_composed_stable_id.DeviceType.HeatPump: return "climate-family";
|
|
@@ -118477,6 +119616,151 @@ function createRuntimeStateBridge(params) {
|
|
|
118477
119616
|
};
|
|
118478
119617
|
}
|
|
118479
119618
|
//#endregion
|
|
119619
|
+
//#region src/device/power-switch.ts
|
|
119620
|
+
var PowerSwitchRefusedError = class extends Error {
|
|
119621
|
+
reason;
|
|
119622
|
+
constructor(reason, message) {
|
|
119623
|
+
super(message);
|
|
119624
|
+
this.name = "PowerSwitchRefusedError";
|
|
119625
|
+
this.reason = reason;
|
|
119626
|
+
}
|
|
119627
|
+
};
|
|
119628
|
+
/** `true` / `false` from the owner slice, `null` when the hinted field is
|
|
119629
|
+
* absent or not of the hinted shape. */
|
|
119630
|
+
function powerOnFromSlice(hint, slice) {
|
|
119631
|
+
const value = slice?.[hint.field];
|
|
119632
|
+
switch (hint.kind) {
|
|
119633
|
+
case "field": return typeof value === "boolean" ? value : null;
|
|
119634
|
+
case "methods": return typeof value === "string" ? !hint.offValues.includes(value) : null;
|
|
119635
|
+
case "mode": return typeof value === "string" ? value !== hint.offValue : null;
|
|
119636
|
+
}
|
|
119637
|
+
}
|
|
119638
|
+
function ownerMethod(owner, name, capName) {
|
|
119639
|
+
const fn = Reflect.get(owner, name);
|
|
119640
|
+
if (typeof fn !== "function") throw new PowerSwitchRefusedError("owner-method-missing", `${capName} provider does not serve '${name}', which its power hint names`);
|
|
119641
|
+
return async (input) => fn.call(owner, input);
|
|
119642
|
+
}
|
|
119643
|
+
async function lastNonOffMode(host, capName, hint) {
|
|
119644
|
+
const isMode = (v) => typeof v === "string" && v.length > 0 && v !== hint.offValue;
|
|
119645
|
+
const fromHub = (await host.readHubSlice(capName).catch(() => null))?.[hint.lastField];
|
|
119646
|
+
if (isMode(fromHub)) return fromHub;
|
|
119647
|
+
const local = host.runtimeState.getCapState(capName)?.[hint.lastField];
|
|
119648
|
+
return isMode(local) ? local : null;
|
|
119649
|
+
}
|
|
119650
|
+
async function applyPower(host, capName, hint, owner, on) {
|
|
119651
|
+
const deviceId = host.deviceId;
|
|
119652
|
+
switch (hint.kind) {
|
|
119653
|
+
case "field":
|
|
119654
|
+
await ownerMethod(owner, hint.set, capName)({
|
|
119655
|
+
deviceId,
|
|
119656
|
+
on
|
|
119657
|
+
});
|
|
119658
|
+
return;
|
|
119659
|
+
case "methods":
|
|
119660
|
+
await ownerMethod(owner, on ? hint.on : hint.off, capName)({ deviceId });
|
|
119661
|
+
return;
|
|
119662
|
+
case "mode": {
|
|
119663
|
+
const set = ownerMethod(owner, hint.set, capName);
|
|
119664
|
+
if (!on) {
|
|
119665
|
+
await set({
|
|
119666
|
+
deviceId,
|
|
119667
|
+
mode: hint.offValue
|
|
119668
|
+
});
|
|
119669
|
+
return;
|
|
119670
|
+
}
|
|
119671
|
+
const mode = await lastNonOffMode(host, capName, hint);
|
|
119672
|
+
if (mode === null) throw new PowerSwitchRefusedError("no-last-mode", `device ${deviceId}: ${capName} has no last non-off mode to restore; pick a mode instead`);
|
|
119673
|
+
await set({
|
|
119674
|
+
deviceId,
|
|
119675
|
+
mode
|
|
119676
|
+
});
|
|
119677
|
+
return;
|
|
119678
|
+
}
|
|
119679
|
+
}
|
|
119680
|
+
}
|
|
119681
|
+
function hintedMethods(hint) {
|
|
119682
|
+
return hint.kind === "methods" ? [hint.on, hint.off] : [hint.set];
|
|
119683
|
+
}
|
|
119684
|
+
/** Whether `owner` serves every method its cap's power hint names. A media
|
|
119685
|
+
* player whose `turnOn` / `turnOff` are not served has no power, so no switch. */
|
|
119686
|
+
function powerServedBy(hint, owner) {
|
|
119687
|
+
if (hint === void 0) return false;
|
|
119688
|
+
return hintedMethods(hint).every((name) => typeof Reflect.get(owner, name) === "function");
|
|
119689
|
+
}
|
|
119690
|
+
/** Builds the `switch` provider and starts the slice projection. Exported
|
|
119691
|
+
* for the specs; providers call `registerPowerSwitch`. */
|
|
119692
|
+
function buildPowerSwitch(host, cap, owner) {
|
|
119693
|
+
const hint = cap.power;
|
|
119694
|
+
if (hint === void 0) throw new Error(`capability '${cap.name}' has no power hint: it has no switch to project`);
|
|
119695
|
+
const read = () => powerOnFromSlice(hint, host.runtimeState.getCapState(cap.name));
|
|
119696
|
+
const project = () => {
|
|
119697
|
+
const on = read();
|
|
119698
|
+
const current = host.runtimeState.getCapState(switchCapability.name);
|
|
119699
|
+
if (current !== void 0 && current["on"] === on) return;
|
|
119700
|
+
const next = {
|
|
119701
|
+
on,
|
|
119702
|
+
lastChangedAt: Date.now()
|
|
119703
|
+
};
|
|
119704
|
+
host.runtimeState.setCapState(switchCapability.name, next);
|
|
119705
|
+
};
|
|
119706
|
+
const stop = host.runtimeState.subscribeCap(cap.name, project);
|
|
119707
|
+
if (host.runtimeState.getCapState(cap.name) !== void 0) project();
|
|
119708
|
+
return {
|
|
119709
|
+
provider: {
|
|
119710
|
+
getStatus: async () => {
|
|
119711
|
+
const current = host.runtimeState.getCapState(switchCapability.name);
|
|
119712
|
+
const lastChangedAt = typeof current?.["lastChangedAt"] === "number" ? current["lastChangedAt"] : 0;
|
|
119713
|
+
return {
|
|
119714
|
+
on: read(),
|
|
119715
|
+
lastChangedAt
|
|
119716
|
+
};
|
|
119717
|
+
},
|
|
119718
|
+
setState: async ({ on }) => applyPower(host, cap.name, hint, owner, on)
|
|
119719
|
+
},
|
|
119720
|
+
dispose: stop
|
|
119721
|
+
};
|
|
119722
|
+
}
|
|
119723
|
+
/**
|
|
119724
|
+
* Registers `switch` for a device whose `cap` carries a `power` hint, built
|
|
119725
|
+
* from `owner` (the provider the device registered for `cap`). Call it right
|
|
119726
|
+
* after `registerNativeCap(cap, owner)`.
|
|
119727
|
+
*/
|
|
119728
|
+
function registerPowerSwitch(device, cap, owner) {
|
|
119729
|
+
const deviceId = device.ctx.id;
|
|
119730
|
+
if (cap.power !== void 0 && !powerServedBy(cap.power, owner)) {
|
|
119731
|
+
device.ctx.logger.debug("power switch: owner serves no power control, no switch registered", {
|
|
119732
|
+
tags: { deviceId },
|
|
119733
|
+
meta: { capName: cap.name }
|
|
119734
|
+
});
|
|
119735
|
+
return () => {};
|
|
119736
|
+
}
|
|
119737
|
+
const host = {
|
|
119738
|
+
deviceId,
|
|
119739
|
+
runtimeState: device.runtimeState,
|
|
119740
|
+
registerNativeCap: (c, p) => device.ctx.registerNativeCap(c, p),
|
|
119741
|
+
readHubSlice: async (capName) => {
|
|
119742
|
+
try {
|
|
119743
|
+
return await device.ctx.api.deviceState.getCapSlice.query({
|
|
119744
|
+
deviceId,
|
|
119745
|
+
capName
|
|
119746
|
+
});
|
|
119747
|
+
} catch (err) {
|
|
119748
|
+
device.ctx.logger.warn("power switch: hub slice read failed", {
|
|
119749
|
+
tags: { deviceId },
|
|
119750
|
+
meta: {
|
|
119751
|
+
capName,
|
|
119752
|
+
error: err instanceof Error ? err.message : String(err)
|
|
119753
|
+
}
|
|
119754
|
+
});
|
|
119755
|
+
return null;
|
|
119756
|
+
}
|
|
119757
|
+
}
|
|
119758
|
+
};
|
|
119759
|
+
const built = buildPowerSwitch(host, cap, owner);
|
|
119760
|
+
host.registerNativeCap(switchCapability, built.provider);
|
|
119761
|
+
return built.dispose;
|
|
119762
|
+
}
|
|
119763
|
+
//#endregion
|
|
118480
119764
|
//#region src/device/system-mirror.ts
|
|
118481
119765
|
var STATE_CHANGED_CATEGORY = "device.state-changed";
|
|
118482
119766
|
var BINDING_CHANGED_CATEGORY = "capability.binding-changed";
|
|
@@ -120350,6 +121634,11 @@ var METHOD_DEVICE_SELECTORS = Object.freeze({
|
|
|
120350
121634
|
form: "single",
|
|
120351
121635
|
optional: false
|
|
120352
121636
|
}],
|
|
121637
|
+
"fanControl.setOscillationAxis": [{
|
|
121638
|
+
name: "deviceId",
|
|
121639
|
+
form: "single",
|
|
121640
|
+
optional: false
|
|
121641
|
+
}],
|
|
120353
121642
|
"fanControl.setPercentage": [{
|
|
120354
121643
|
name: "deviceId",
|
|
120355
121644
|
form: "single",
|
|
@@ -123205,6 +124494,12 @@ var CUSTOMIZE_CARDINALITIES = [
|
|
|
123205
124494
|
var CUSTOMIZE_EVENT_SHAPES = ["pulse", "span"];
|
|
123206
124495
|
/** Who applies a stored event or scalar assignment; the table branches on it. */
|
|
123207
124496
|
var CUSTOMIZE_APPLY_AUTHORITY_KINDS = ["composition-claim", "camera-sensors"];
|
|
124497
|
+
/**
|
|
124498
|
+
* A named group a cap may file its targets under in the Customize table
|
|
124499
|
+
* (D1034). Admin-ui keys a section title off this list; a target without one
|
|
124500
|
+
* lands in the section its cardinality implies.
|
|
124501
|
+
*/
|
|
124502
|
+
var CUSTOMIZE_TARGET_SECTIONS = ["oscillation-axes"];
|
|
123208
124503
|
//#endregion
|
|
123209
124504
|
//#region src/composition/customize/scalar-status.ts
|
|
123210
124505
|
function projectScalarAssignment(input) {
|
|
@@ -136492,6 +137787,7 @@ exports.CAP_VOCABULARY_BY_NAME = require_sleep.CAP_VOCABULARY_BY_NAME;
|
|
|
136492
137787
|
exports.CATALOG_LANGS = CATALOG_LANGS;
|
|
136493
137788
|
exports.CIVIL_TWILIGHT_ALTITUDE_DEG = CIVIL_TWILIGHT_ALTITUDE_DEG;
|
|
136494
137789
|
exports.CLASS_MAP_MACRO_TARGETS = CLASS_MAP_MACRO_TARGETS;
|
|
137790
|
+
exports.CLIMATE_ROLES = CLIMATE_ROLES;
|
|
136495
137791
|
exports.CLIP_BROKER_PACED_RATES = CLIP_BROKER_PACED_RATES;
|
|
136496
137792
|
exports.CLIP_LABEL_EVENT_FETCH_LIMIT = CLIP_LABEL_EVENT_FETCH_LIMIT;
|
|
136497
137793
|
exports.CLIP_PLAYBACK_OPTIONS = CLIP_PLAYBACK_OPTIONS;
|
|
@@ -136537,6 +137833,7 @@ exports.CUSTOMIZATION_BLOCK_NAME_PREFIX = require_implemented_methods.CUSTOMIZAT
|
|
|
136537
137833
|
exports.CUSTOMIZE_APPLY_AUTHORITY_KINDS = CUSTOMIZE_APPLY_AUTHORITY_KINDS;
|
|
136538
137834
|
exports.CUSTOMIZE_CARDINALITIES = CUSTOMIZE_CARDINALITIES;
|
|
136539
137835
|
exports.CUSTOMIZE_EVENT_SHAPES = CUSTOMIZE_EVENT_SHAPES;
|
|
137836
|
+
exports.CUSTOMIZE_TARGET_SECTIONS = CUSTOMIZE_TARGET_SECTIONS;
|
|
136540
137837
|
exports.CalendarColorSchema = CalendarColorSchema;
|
|
136541
137838
|
exports.CalendarEntrySchema = CalendarEntrySchema;
|
|
136542
137839
|
exports.CalendarEventSchema = CalendarEventSchema;
|
|
@@ -136986,6 +138283,7 @@ exports.EVENT_DENSITY_BATCH_MAX = EVENT_DENSITY_BATCH_MAX;
|
|
|
136986
138283
|
exports.EVENT_KIND_BY_CAP = EVENT_KIND_BY_CAP;
|
|
136987
138284
|
exports.EVENT_KIND_LABELS = EVENT_KIND_LABELS;
|
|
136988
138285
|
exports.EVENT_KIND_LABEL_KEYS = EVENT_KIND_LABEL_KEYS;
|
|
138286
|
+
exports.EVENT_LEAF_ID_RE = EVENT_LEAF_ID_RE;
|
|
136989
138287
|
exports.EVENT_OWNER_TYPES = EVENT_OWNER_TYPES;
|
|
136990
138288
|
exports.EVENT_PAD_MS = EVENT_PAD_MS;
|
|
136991
138289
|
exports.EVENT_TAXONOMY = EVENT_TAXONOMY;
|
|
@@ -137095,11 +138393,13 @@ exports.FACE_RESCORE_INTERVAL_KEY = FACE_RESCORE_INTERVAL_KEY;
|
|
|
137095
138393
|
exports.FACE_RESCORE_INTERVAL_MIN_RUNNING = FACE_RESCORE_INTERVAL_MIN_RUNNING;
|
|
137096
138394
|
exports.FACE_RESCORE_SECTION_ID = FACE_RESCORE_SECTION_ID;
|
|
137097
138395
|
exports.FAN_CAPTURE_FIELDS = FAN_CAPTURE_FIELDS;
|
|
137098
|
-
exports.
|
|
138396
|
+
exports.FAN_OSCILLATION_AXES = FAN_OSCILLATION_AXES;
|
|
138397
|
+
exports.FAN_OSCILLATION_AXIS_LIMITS = FAN_OSCILLATION_AXIS_LIMITS;
|
|
138398
|
+
exports.FAN_OSCILLATION_AXIS_REFUSALS = FAN_OSCILLATION_AXIS_REFUSALS;
|
|
138399
|
+
exports.FAN_OSCILLATION_AXIS_SETTABLE = FAN_OSCILLATION_AXIS_SETTABLE;
|
|
137099
138400
|
exports.FAN_OUT_CONCURRENCY = FAN_OUT_CONCURRENCY;
|
|
137100
138401
|
exports.FAN_PRESETS_MAX = FAN_PRESETS_MAX;
|
|
137101
138402
|
exports.FAN_PRESETS_REFUSALS = FAN_PRESETS_REFUSALS;
|
|
137102
|
-
exports.FAN_PRESET_STEPS_MAX = FAN_PRESET_STEPS_MAX;
|
|
137103
138403
|
exports.FEEDER_EXAMPLE_ADDON_ID = FEEDER_EXAMPLE_ADDON_ID;
|
|
137104
138404
|
exports.FEEDER_EXAMPLE_HA_DEVICE_ID = FEEDER_EXAMPLE_HA_DEVICE_ID;
|
|
137105
138405
|
exports.FEW_SHOT_COUNT = FEW_SHOT_COUNT;
|
|
@@ -137112,15 +138412,21 @@ exports.FailureContributionSchema = FailureContributionSchema;
|
|
|
137112
138412
|
exports.FailureCounters = FailureCounters;
|
|
137113
138413
|
exports.FailureReasonCountSchema = FailureReasonCountSchema;
|
|
137114
138414
|
exports.FanCaptureFieldSchema = FanCaptureFieldSchema;
|
|
137115
|
-
exports.FanCaptureGroupSchema = FanCaptureGroupSchema;
|
|
137116
|
-
exports.FanCaptureItemSchema = FanCaptureItemSchema;
|
|
137117
138415
|
exports.FanCaptureOmissionSchema = FanCaptureOmissionSchema;
|
|
137118
138416
|
exports.FanControlStatusSchema = FanControlStatusSchema;
|
|
137119
138417
|
exports.FanDirectionSchema = FanDirectionSchema;
|
|
138418
|
+
exports.FanOscillationAxesSchema = FanOscillationAxesSchema;
|
|
138419
|
+
exports.FanOscillationAxisFieldSchema = FanOscillationAxisFieldSchema;
|
|
138420
|
+
exports.FanOscillationAxisNameSchema = FanOscillationAxisNameSchema;
|
|
138421
|
+
exports.FanOscillationAxisRefusalSchema = FanOscillationAxisRefusalSchema;
|
|
138422
|
+
exports.FanOscillationAxisResultSchema = FanOscillationAxisResultSchema;
|
|
138423
|
+
exports.FanOscillationAxisSchema = FanOscillationAxisSchema;
|
|
137120
138424
|
exports.FanPresetApplyResultSchema = FanPresetApplyResultSchema;
|
|
138425
|
+
exports.FanPresetAxisSchema = FanPresetAxisSchema;
|
|
137121
138426
|
exports.FanPresetCaptureResultSchema = FanPresetCaptureResultSchema;
|
|
138427
|
+
exports.FanPresetFieldResultSchema = FanPresetFieldResultSchema;
|
|
137122
138428
|
exports.FanPresetSchema = FanPresetSchema;
|
|
137123
|
-
exports.
|
|
138429
|
+
exports.FanPresetStateSchema = FanPresetStateSchema;
|
|
137124
138430
|
exports.FanPresetsRefusalSchema = FanPresetsRefusalSchema;
|
|
137125
138431
|
exports.FanPresetsSetResultSchema = FanPresetsSetResultSchema;
|
|
137126
138432
|
exports.FeatureManifestSchema = FeatureManifestSchema;
|
|
@@ -137962,6 +139268,7 @@ exports.PowerSourceActionResultSchema = PowerSourceActionResultSchema;
|
|
|
137962
139268
|
exports.PowerSourceInfoSchema = PowerSourceInfoSchema;
|
|
137963
139269
|
exports.PowerSourceRefusalReasonSchema = PowerSourceRefusalReasonSchema;
|
|
137964
139270
|
exports.PowerSourceStateSchema = PowerSourceStateSchema;
|
|
139271
|
+
exports.PowerSwitchRefusedError = PowerSwitchRefusedError;
|
|
137965
139272
|
exports.PrecisionGopsSchema = PrecisionGopsSchema;
|
|
137966
139273
|
exports.PreferenceDeviceIdSchema = PreferenceDeviceIdSchema;
|
|
137967
139274
|
exports.PreferenceNamespaceSchema = PreferenceNamespaceSchema;
|
|
@@ -138406,6 +139713,7 @@ exports.SessionPlacementPolicySchema = SessionPlacementPolicySchema;
|
|
|
138406
139713
|
exports.SessionTriggerSchema = SessionTriggerSchema;
|
|
138407
139714
|
exports.SetCameraSensorsInputSchema = SetCameraSensorsInputSchema;
|
|
138408
139715
|
exports.SetLoggingSettingsInputSchema = SetLoggingSettingsInputSchema;
|
|
139716
|
+
exports.SetOscillationAxisInputSchema = SetOscillationAxisInputSchema;
|
|
138409
139717
|
exports.SetShareSourceInputSchema = SetShareSourceInputSchema;
|
|
138410
139718
|
exports.SetSiteLocationInputSchema = SetSiteLocationInputSchema;
|
|
138411
139719
|
exports.SetTrackPurityInputSchema = SetTrackPurityInputSchema;
|
|
@@ -138526,8 +139834,10 @@ exports.TEMPLATE_KINDS = TEMPLATE_KINDS;
|
|
|
138526
139834
|
exports.TEMPLATE_PAYLOAD_SCHEMAS = TEMPLATE_PAYLOAD_SCHEMAS;
|
|
138527
139835
|
exports.TEMPLATE_WRITE_REFUSALS = TEMPLATE_WRITE_REFUSALS;
|
|
138528
139836
|
exports.THRESHOLD_GRID_W = THRESHOLD_GRID_W;
|
|
139837
|
+
exports.TIMED_RUN_DEVICE_ROLES = TIMED_RUN_DEVICE_ROLES;
|
|
138529
139838
|
exports.TIMED_RUN_DEVICE_TYPES = TIMED_RUN_DEVICE_TYPES;
|
|
138530
|
-
exports.
|
|
139839
|
+
exports.TIMED_RUN_HEATER_LIMIT = TIMED_RUN_HEATER_LIMIT;
|
|
139840
|
+
exports.TIMED_RUN_PET_FOUNTAIN_LIMIT = TIMED_RUN_PET_FOUNTAIN_LIMIT;
|
|
138531
139841
|
exports.TIMELAPSE_DENSE_FLOOR_SEC = TIMELAPSE_DENSE_FLOOR_SEC;
|
|
138532
139842
|
exports.TIMEZONES = TIMEZONES;
|
|
138533
139843
|
exports.TRACK_RELATIONS_DEFAULT_LIMIT = TRACK_RELATIONS_DEFAULT_LIMIT;
|
|
@@ -138535,6 +139845,7 @@ exports.TRAINING_JOB_SCHEMA = TRAINING_JOB_SCHEMA;
|
|
|
138535
139845
|
exports.TRAINING_RESULT_SCHEMA = TRAINING_RESULT_SCHEMA;
|
|
138536
139846
|
exports.TRANSCODE_DOWN_MAX_BITRATE_KBPS = TRANSCODE_DOWN_MAX_BITRATE_KBPS;
|
|
138537
139847
|
exports.TRANSCODE_DOWN_MAX_HEIGHT = TRANSCODE_DOWN_MAX_HEIGHT;
|
|
139848
|
+
exports.TRIGGERED_BY_MAX_IDS = TRIGGERED_BY_MAX_IDS;
|
|
138538
139849
|
exports.TamperStatusSchema = TamperStatusSchema;
|
|
138539
139850
|
exports.TargetKindCapsSchema = TargetKindCapsSchema;
|
|
138540
139851
|
exports.TargetKindLevelSchema = TargetKindLevelSchema;
|
|
@@ -138787,6 +140098,7 @@ exports.allVocabActions = require_sleep.allVocabActions;
|
|
|
138787
140098
|
exports.allowedSuppliedEffect = allowedSuppliedEffect;
|
|
138788
140099
|
exports.ambientLightSensorCapability = ambientLightSensorCapability;
|
|
138789
140100
|
exports.annotateClipsWithEventLabels = annotateClipsWithEventLabels;
|
|
140101
|
+
exports.anyAxisOscillating = anyAxisOscillating;
|
|
138790
140102
|
exports.anySubjectMatches = anySubjectMatches;
|
|
138791
140103
|
exports.appFlowLocation = appFlowLocation;
|
|
138792
140104
|
exports.appendTrace = appendTrace;
|
|
@@ -138864,6 +140176,7 @@ exports.buildModelVariantGroups = buildModelVariantGroups;
|
|
|
138864
140176
|
exports.buildNcTaxonomy = buildNcTaxonomy;
|
|
138865
140177
|
exports.buildNotificationTargetInstances = buildNotificationTargetInstances;
|
|
138866
140178
|
exports.buildPlusCatalogClassMap = buildPlusCatalogClassMap;
|
|
140179
|
+
exports.buildPowerSwitch = buildPowerSwitch;
|
|
138867
140180
|
exports.buildRepairPrompt = buildRepairPrompt;
|
|
138868
140181
|
exports.buildRoleScopes = buildRoleScopes;
|
|
138869
140182
|
exports.buildSecretRef = require_sleep.buildSecretRef;
|
|
@@ -138896,7 +140209,9 @@ exports.canConvertUnit = require_convert.canConvertUnit;
|
|
|
138896
140209
|
exports.canonicalEgressPlan = canonicalEgressPlan;
|
|
138897
140210
|
exports.canonicalIconKey = canonicalIconKey;
|
|
138898
140211
|
exports.canonicalJson = canonicalJson;
|
|
140212
|
+
exports.canonicalStoredDeviceType = canonicalStoredDeviceType;
|
|
138899
140213
|
exports.canonicalizeAppCallback = canonicalizeAppCallback;
|
|
140214
|
+
exports.capAppliesToDeviceKind = capAppliesToDeviceKind;
|
|
138900
140215
|
exports.capUnitResolver = capUnitResolver;
|
|
138901
140216
|
exports.capabilityScopesOf = capabilityScopesOf;
|
|
138902
140217
|
exports.capacityForModel = capacityForModel;
|
|
@@ -138925,6 +140240,7 @@ exports.clearKnownSecrets = require_sleep.clearKnownSecrets;
|
|
|
138925
140240
|
exports.clearModelBoundOverrides = clearModelBoundOverrides;
|
|
138926
140241
|
exports.clearModelBoundSetting = clearModelBoundSetting;
|
|
138927
140242
|
exports.climateControlCapability = climateControlCapability;
|
|
140243
|
+
exports.climateRoleOf = climateRoleOf;
|
|
138928
140244
|
exports.clipEventLabelDepsFromApi = clipEventLabelDepsFromApi;
|
|
138929
140245
|
exports.clipExportFailure = clipExportFailure;
|
|
138930
140246
|
exports.clipExportFailureOf = clipExportFailureOf;
|
|
@@ -138981,6 +140297,7 @@ exports.compositionSliceKey = require_implemented_methods.compositionSliceKey;
|
|
|
138981
140297
|
exports.compositionSourceKey = require_implemented_methods.compositionSourceKey;
|
|
138982
140298
|
exports.compositionSourceRefs = compositionSourceRefs;
|
|
138983
140299
|
exports.compositionTargetCaps = compositionTargetCaps;
|
|
140300
|
+
exports.compositionUnionReads = compositionUnionReads;
|
|
138984
140301
|
exports.computeCapacityShares = computeCapacityShares;
|
|
138985
140302
|
exports.computeScores = computeScores;
|
|
138986
140303
|
exports.conditionExclusionReason = conditionExclusionReason;
|
|
@@ -139179,6 +140496,7 @@ exports.evaluateZoneRules = evaluateZoneRules;
|
|
|
139179
140496
|
exports.event = require_sleep.event;
|
|
139180
140497
|
exports.eventEmitterCapability = eventEmitterCapability;
|
|
139181
140498
|
exports.eventKindLabel = eventKindLabel;
|
|
140499
|
+
exports.eventLeafIdAt = eventLeafIdAt;
|
|
139182
140500
|
exports.eventOverlapsClipWindow = eventOverlapsClipWindow;
|
|
139183
140501
|
exports.evictionPolicyForMode = evictionPolicyForMode;
|
|
139184
140502
|
exports.evictionPolicyOfLocation = evictionPolicyOfLocation;
|
|
@@ -139197,6 +140515,7 @@ exports.extractSourceInfoFromMetadata = extractSourceInfoFromMetadata;
|
|
|
139197
140515
|
exports.faceGalleryCapability = faceGalleryCapability;
|
|
139198
140516
|
exports.failureContributionCapability = failureContributionCapability;
|
|
139199
140517
|
exports.failureRate = failureRate;
|
|
140518
|
+
exports.fanAxisPath = fanAxisPath;
|
|
139200
140519
|
exports.fanControlCapability = fanControlCapability;
|
|
139201
140520
|
exports.fanOutTargets = fanOutTargets;
|
|
139202
140521
|
exports.fanPresetsCapability = fanPresetsCapability;
|
|
@@ -139275,6 +140594,8 @@ exports.hasHoldLeaves = hasHoldLeaves;
|
|
|
139275
140594
|
exports.hasModelBoundOverrides = hasModelBoundOverrides;
|
|
139276
140595
|
exports.hasMotionTrigger = hasMotionTrigger;
|
|
139277
140596
|
exports.hasOwnRunningPowerDefaults = hasOwnRunningPowerDefaults;
|
|
140597
|
+
exports.hasTimeLeaves = hasTimeLeaves;
|
|
140598
|
+
exports.hasTriggeredByLeaves = hasTriggeredByLeaves;
|
|
139278
140599
|
exports.hasUrlScheme = hasUrlScheme;
|
|
139279
140600
|
exports.heatPumpControlCapability = heatPumpControlCapability;
|
|
139280
140601
|
exports.heatPumpInstantCop = heatPumpInstantCop;
|
|
@@ -139302,6 +140623,7 @@ exports.hydrateSchema = require_sleep.hydrateSchema;
|
|
|
139302
140623
|
exports.iconCategoryLabel = iconCategoryLabel;
|
|
139303
140624
|
exports.iconEntry = iconEntry;
|
|
139304
140625
|
exports.iconsInCategory = iconsInCategory;
|
|
140626
|
+
exports.identifiedEventLeaves = identifiedEventLeaves;
|
|
139305
140627
|
exports.imageCapability = imageCapability;
|
|
139306
140628
|
exports.imageModesForKind = imageModesForKind;
|
|
139307
140629
|
exports.imageSettingsCapability = imageSettingsCapability;
|
|
@@ -139336,6 +140658,7 @@ exports.invocationFromEncodeProfile = require_implemented_methods.invocationFrom
|
|
|
139336
140658
|
exports.irSourceProblem = irSourceProblem;
|
|
139337
140659
|
exports.irTransmitterCapability = irTransmitterCapability;
|
|
139338
140660
|
exports.isAgentOnlyPlacement = isAgentOnlyPlacement;
|
|
140661
|
+
exports.isAirConditioner = isAirConditioner;
|
|
139339
140662
|
exports.isAlarmControllableCap = isAlarmControllableCap;
|
|
139340
140663
|
exports.isAlertEpisodeOpen = isAlertEpisodeOpen;
|
|
139341
140664
|
exports.isAlertEpisodeSeverity = isAlertEpisodeSeverity;
|
|
@@ -139437,6 +140760,7 @@ exports.isVoidInput = isVoidInput;
|
|
|
139437
140760
|
exports.isZodSecret = require_sleep.isZodSecret;
|
|
139438
140761
|
exports.ituDbfsFromPreEpoch = ituDbfsFromPreEpoch;
|
|
139439
140762
|
exports.jobKindSchema = jobKindSchema;
|
|
140763
|
+
exports.judgeTimeWindow = judgeTimeWindow;
|
|
139440
140764
|
exports.kebabToCamel = kebabToCamel;
|
|
139441
140765
|
exports.keychainAdminCapability = keychainAdminCapability;
|
|
139442
140766
|
exports.keychainCapability = keychainCapability;
|
|
@@ -139550,6 +140874,7 @@ exports.networkLinkCapability = networkLinkCapability;
|
|
|
139550
140874
|
exports.networkQualityCapability = networkQualityCapability;
|
|
139551
140875
|
exports.nextLocalMidnight = require_implemented_methods.nextLocalMidnight;
|
|
139552
140876
|
exports.nextOccurrence = nextOccurrence;
|
|
140877
|
+
exports.nextTimeBoundaryInMs = nextTimeBoundaryInMs;
|
|
139553
140878
|
exports.nodeBenchmarkRefusals = nodeBenchmarkRefusals;
|
|
139554
140879
|
exports.nodeCertificatesCapability = nodeCertificatesCapability;
|
|
139555
140880
|
exports.nodeIdOfScopedKey = require_sleep.nodeIdOfScopedKey;
|
|
@@ -139678,6 +141003,9 @@ exports.plusCatalogDefaultClassFloors = plusCatalogDefaultClassFloors;
|
|
|
139678
141003
|
exports.plusCatalogLabelFields = plusCatalogLabelFields;
|
|
139679
141004
|
exports.poolMemoryThreshold = poolMemoryThreshold;
|
|
139680
141005
|
exports.powerMeterCapability = powerMeterCapability;
|
|
141006
|
+
exports.powerOnFromSlice = powerOnFromSlice;
|
|
141007
|
+
exports.powerServedBy = powerServedBy;
|
|
141008
|
+
exports.powerSourceActuatorConflicts = powerSourceActuatorConflicts;
|
|
139681
141009
|
exports.powerSourceCapability = powerSourceCapability;
|
|
139682
141010
|
exports.powerSourceLinkOfComposition = powerSourceLinkOfComposition;
|
|
139683
141011
|
exports.preconditionOf = preconditionOf;
|
|
@@ -139734,6 +141062,7 @@ exports.readUseRootModel = readUseRootModel;
|
|
|
139734
141062
|
exports.readinessKey = require_sleep.readinessKey;
|
|
139735
141063
|
exports.readingMeta = require_sleep.readingMeta;
|
|
139736
141064
|
exports.rebootCapability = rebootCapability;
|
|
141065
|
+
exports.recipeSiteIssues = recipeSiteIssues;
|
|
139737
141066
|
exports.recommendNode = recommendNode;
|
|
139738
141067
|
exports.reconcileBlockDevices = reconcileBlockDevices;
|
|
139739
141068
|
exports.reconcileRemovedDevices = reconcileRemovedDevices;
|
|
@@ -139756,6 +141085,7 @@ exports.rectsToCells = rectsToCells;
|
|
|
139756
141085
|
exports.reducePoints = reducePoints;
|
|
139757
141086
|
exports.reducerForActive = reducerForActive;
|
|
139758
141087
|
exports.registerKnownSecret = require_sleep.registerKnownSecret;
|
|
141088
|
+
exports.registerPowerSwitch = registerPowerSwitch;
|
|
139759
141089
|
exports.registrySwitchPortsOver = require_sleep.registrySwitchPortsOver;
|
|
139760
141090
|
exports.registrySwitchToBodyId = require_sleep.registrySwitchToBodyId;
|
|
139761
141091
|
exports.registrySwitchToBodyMigration = require_sleep.registrySwitchToBodyMigration;
|
|
@@ -139958,7 +141288,6 @@ exports.smokeCapability = smokeCapability;
|
|
|
139958
141288
|
exports.smtpProviderCapability = smtpProviderCapability;
|
|
139959
141289
|
exports.smtpSinceKey = smtpSinceKey;
|
|
139960
141290
|
exports.snapshotCapability = snapshotCapability;
|
|
139961
|
-
exports.sourcePickForHeaterPlug = sourcePickForHeaterPlug;
|
|
139962
141291
|
exports.sourcePickForHistory = sourcePickForHistory;
|
|
139963
141292
|
exports.sourcePickForMath = sourcePickForMath;
|
|
139964
141293
|
exports.sourcePickForTemplate = sourcePickForTemplate;
|
|
@@ -139974,6 +141303,7 @@ exports.stateVocabularyFor = stateVocabularyFor;
|
|
|
139974
141303
|
exports.statisticCadenceMs = require_implemented_methods.statisticCadenceMs;
|
|
139975
141304
|
exports.statisticDraft = statisticDraft;
|
|
139976
141305
|
exports.statusInstanceOf = statusInstanceOf;
|
|
141306
|
+
exports.stepGuardSiteIssues = stepGuardSiteIssues;
|
|
139977
141307
|
exports.stepModelRunsOnFormat = stepModelRunsOnFormat;
|
|
139978
141308
|
exports.stepPulse = stepPulse;
|
|
139979
141309
|
exports.stepSettingSource = stepSettingSource;
|
|
@@ -140079,6 +141409,7 @@ exports.transcodeBody = transcodeBody;
|
|
|
140079
141409
|
exports.transformSecretWrite = require_sleep.transformSecretWrite;
|
|
140080
141410
|
exports.triggerLeafVariables = triggerLeafVariables;
|
|
140081
141411
|
exports.triggerVariablesOf = triggerVariablesOf;
|
|
141412
|
+
exports.triggeredByIssue = triggeredByIssue;
|
|
140082
141413
|
exports.tryConvertDelta = require_convert.tryConvertDelta;
|
|
140083
141414
|
exports.tryConvertUnit = require_convert.tryConvertUnit;
|
|
140084
141415
|
exports.turnProviderCapability = turnProviderCapability;
|
|
@@ -140130,6 +141461,7 @@ exports.weeklyMaskIndex = weeklyMaskIndex;
|
|
|
140130
141461
|
exports.weeklyMaskIsUniform = weeklyMaskIsUniform;
|
|
140131
141462
|
exports.weeklyMaskToWindows = weeklyMaskToWindows;
|
|
140132
141463
|
exports.whenDepth = whenDepth;
|
|
141464
|
+
exports.whenSiteIssues = whenSiteIssues;
|
|
140133
141465
|
exports.widenDeviceConstructor = widenDeviceConstructor;
|
|
140134
141466
|
exports.windowsToWeeklyMask = windowsToWeeklyMask;
|
|
140135
141467
|
exports.wiringAddonHealthSchema = wiringAddonHealthSchema;
|