@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/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.2.549] - 2026-11-11
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Devices are typed by their controls and told apart by role: a plug-in heater is a switch with role switch-heater (timed run included), a plug-powered fan a switch with role switch-fan, and the thermostat type is folded into climate with climate-* roles (AC, thermostat, radiator, floor, heater, heat-pump circuit).
|
|
15
|
+
- A device provider can now rebuild two device classes that share one type (BaseDeviceProvider.deviceClassForRow), so a radiator valve and a room climate can both be climate devices.
|
|
16
|
+
- Customize refuses a power source that is the device's own actuator switch (power-source-is-actuator); power-source actions refuse such a stored link (switch-is-actuator).
|
|
17
|
+
- A power source that points at the device's own actuator switch is now refused (power-source-is-actuator at Customize, switch-is-actuator when a power action reads a stored link); link a real supply plug as the power source instead.
|
|
18
|
+
- A humidifier, media player, climate unit, water heater or pet fountain now declares how it powers on and off, and registerPowerSwitch gives such a device its on/off switch from that one declaration.
|
|
19
|
+
- Fans gain per-axis oscillation (oscillationAxes, setOscillationAxis) and a Customize spec on fan-control whose axis fields and preset the operator can link to sibling devices.
|
|
20
|
+
- Fan presets are a desired fan-control state (speed, preset, direction, oscillation axes) instead of a list of steps; a Customize source whose value can be a number or a string is linkable and judged by the kind it reports now.
|
|
21
|
+
|
|
22
|
+
## [1.2.548] - 2026-11-11
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- Automations can gate on the time of day: a new 'time is' condition (a window such as 22:00 to 06:00, and/or chosen weekdays) that also starts a state-only automation when the window opens. A window bounded by a sun event is refused at save when the site has no location.
|
|
27
|
+
- Automations: a "Started by" condition tells which trigger row started the run, so one automation can run a different step per trigger
|
|
28
|
+
- Automations: a "device becomes" trigger hands the run the device, the value before the change and the new value (vars.deviceId, vars.from, vars.to)
|
|
29
|
+
|
|
10
30
|
## [1.2.547] - 2026-11-11
|
|
11
31
|
|
|
12
32
|
### Changed
|
package/dist/addon.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-
|
|
4
|
+
const require_composed_stable_id = require("./composed-stable-id-CDNLq7Y8.js");
|
|
5
5
|
//#region src/generated/cap-input-defaults.ts
|
|
6
6
|
/**
|
|
7
7
|
* AUTO-GENERATED by scripts/generate-cap-input-defaults.ts — DO NOT EDIT.
|
|
@@ -16,7 +16,7 @@ const require_composed_stable_id = require("./composed-stable-id-DrGLxjVF.js");
|
|
|
16
16
|
* Plain data, zero Zod: a forked runner must not import the schema barrel
|
|
17
17
|
* (~144MB RSS per runner — D28).
|
|
18
18
|
*
|
|
19
|
-
* Coverage:
|
|
19
|
+
* Coverage: 33 caps, 84 methods with defaults.
|
|
20
20
|
*/
|
|
21
21
|
var CAP_INPUT_DEFAULTS = Object.freeze({
|
|
22
22
|
"addons": { "getLogs": { "limit": 100 } },
|
|
@@ -63,7 +63,6 @@ var CAP_INPUT_DEFAULTS = Object.freeze({
|
|
|
63
63
|
"listRecentTransitions": { "limit": 50 },
|
|
64
64
|
"listTransitions": { "limit": 50 }
|
|
65
65
|
},
|
|
66
|
-
"fan-presets": { "capturePreset": { "steps": [] } },
|
|
67
66
|
"llm-runtime": {
|
|
68
67
|
"complete": { "runtime": { "__nested__": {
|
|
69
68
|
"contextSize": 4096,
|
|
@@ -453,7 +452,7 @@ function isCollectionArrayMethodName(capName, method) {
|
|
|
453
452
|
* Per capability, the methods declared `optionalMethod` — the ones whose
|
|
454
453
|
* ABSENCE on a provider is a fact about that provider, not a bug.
|
|
455
454
|
*
|
|
456
|
-
* Coverage: 10 caps,
|
|
455
|
+
* Coverage: 10 caps, 44 methods.
|
|
457
456
|
*/
|
|
458
457
|
var PROVIDER_OPTIONAL_METHODS = Object.freeze({
|
|
459
458
|
"climate-control": [
|
|
@@ -478,6 +477,7 @@ var PROVIDER_OPTIONAL_METHODS = Object.freeze({
|
|
|
478
477
|
"fan-control": [
|
|
479
478
|
"setDirection",
|
|
480
479
|
"setOscillating",
|
|
480
|
+
"setOscillationAxis",
|
|
481
481
|
"setPercentage",
|
|
482
482
|
"setPreset"
|
|
483
483
|
],
|
package/dist/addon.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as DEVICE_CHILDREN_BATCH_MAX, $r as RECORD_DATABASES, A as CAP_ADVANCE_FIELDS, Ai as RecordSecretUnavailableError, An as CALLER_USERNAME_HEADER, Ar as nodeIdOfScopedKey, Bn as RecordKindNameSchema, Ci as FilterRequiredError, Cn as scrubKnownSecrets, Ct as createDebugEmitter, Di as PlaintextSecretError, Dn as PEER_BYTES_STALL_MS, Ei as NoCallerError, En as PEER_BYTES_MAX_OUTSTANDING, F as withoutCallerStamp, Fi as TransactRefusedError, Fn as entryBody, G as readNodePin, Gn as defineRecordKinds, Gr as parseSecretPath, H as commandOrigin, Hn as StoredRecordKindDeclarationSchema, Hr as REMOVE_LEAF, I as customAction, Ii as UnindexedFilterError, In as EntryDescriptorSchema, J as PipelineRunResultBridge, Jn as isZodSecret, Jr as recordSecretRef, Kr as recordArrayItemPath, L as defineCustomActions, Li as UnknownRecordKindError, Ln as RecordFieldPathSchema, Mi as RecordUniqueViolationError, Mr as resolvedValues, N as CAP_STATE_LEAVES, Ni as RecordsError, Nn as DisposerChain, O as HF_REPO, Oi as RECORDS_ERROR_CODES, On as PEER_BYTES_TICKET_TTL_MS, P as CALLER_STAMPED_CAPABILITIES, Pi as RevConflictError, Pn as defineEntryKind, Q as deviceOpsCapability, Qr as RECORD_CLASSES, R as describeCustomActions, Ri as asRecordsError, Rn as RecordIndexSchema, Sa as findMigrationsBlocked, Si as DeclarationRefusedError, Sn as registerKnownSecret, T as isCommand, Ti as InvalidRecordError, Tn as PEER_BYTES_CHUNK_BYTES, U as nodePin, Un as assertValidDeclaration, Ur as collectSecretLeaves, Vn as RecordRetentionSchema, Vr as secretViewsOf, W as readCommandOrigin, Wn as declarationsOf, Wr as mapSecretLeaves, X as MIGRATION_API_VERSION, Xi as emitReadiness, Xr as RECORD_BATCH_MAX, Y as PipelineStepInputSchema, Yi as createEvent, Yr as secretArrayPrefixes, Zr as RECORD_BATCH_MAX_BYTES, _i as parseSecretRef, _n as createSecretsAccess, ai as RECORD_MAX_INDEX_FIELDS, bn as forgetKnownSecret, c as asString, ca as isSecretClear, ci as RECORD_SETTINGS_MAX_ROWS, d as parseJsonUnknown, da as isSecretMarkerLike, di as arrayItemFieldPath, dn as ruleFireOfClaim, dr as ErrorI18nPayloadSchema, dt as ReadinessRegistry, ei as RECORD_DEFAULT_MAX_DATA_BYTES, et as adminUiCapability, f as hfModelUrl, fa as makeSecretMarker, fi as buildSecretRef, fn as makeInMemoryRecords, ft as ReadinessTimeoutError, g as createDeviceProxy, gi as normalizeSecretOwner, gn as REVALIDATE_AFTER_MS, gr as BaseAddon, h as isDeviceScopedCap, hi as isSecretRef, hn as resolveSecretViewsIn, ht as scopeKey, ii as RECORD_MAX_INDEXES, j as CAP_METHOD_TIMEOUTS_MS, ji as RecordTooLargeError, jn as DATAPLANE_SECRET_HEADER, jr as resolveDeviceSettings, ki as RecordNotFoundError, kr as SCOPED_SETTINGS_SCOPES, la as isSecretFieldView, li as RECORD_SWEEP_INTERVAL_MS, ln as CommandOriginClaimSchema, m as DEVICE_SCOPED_CAPS, mi as globalSecretScope, mn as assertTransactScope, mr as readErrorI18n, ni as RECORD_ID_MAX_LENGTH, nr as expandCapMethods, nt as addonPagesSourceCapability, o as asJsonObject, oa as SECRET_CLEAR, oi as RECORD_QUERY_MAX, p as BOOT_RECOVERY_BACKOFF_MS, pa as toSecretFieldView, pi as formatSecretScope, pn as createRecordsAccess, q as viewerUiCapability, qn as collectZodSecretPaths, qr as recordSecretCollection, r as maskUrlCredentials, ri as RECORD_MAX_DATA_BYTES, sa as classifySecretWrite, si as RECORD_SECRET_COLLECTION_PREFIX, t as sleep, ti as RECORD_DELETE_BATCH, ua as isSecretMarker, ui as SECRET_REF_SCHEME, un as RuleFireOriginSchema, ut as MODEL_FORMATS, v as addonSliceHandleApi, vn as MIN_SCRUBBED_LENGTH, wi as ForeignSecretMarkerError, wn as shortSecretRefHash, xa as AddonMigrationsBlockedError, xi as BatchTooLargeError, xn as knownSecretCount, y as createEventBusSliceSource, yn as clearKnownSecrets, yr as normalizeAddonInitResult, zi as recordsErrorFromMessage, zn as RecordKindDeclarationSchema } from "./sleep-
|
|
1
|
+
import { $ as DEVICE_CHILDREN_BATCH_MAX, $r as RECORD_DATABASES, A as CAP_ADVANCE_FIELDS, Ai as RecordSecretUnavailableError, An as CALLER_USERNAME_HEADER, Ar as nodeIdOfScopedKey, Bn as RecordKindNameSchema, Ci as FilterRequiredError, Cn as scrubKnownSecrets, Ct as createDebugEmitter, Di as PlaintextSecretError, Dn as PEER_BYTES_STALL_MS, Ei as NoCallerError, En as PEER_BYTES_MAX_OUTSTANDING, F as withoutCallerStamp, Fi as TransactRefusedError, Fn as entryBody, G as readNodePin, Gn as defineRecordKinds, Gr as parseSecretPath, H as commandOrigin, Hn as StoredRecordKindDeclarationSchema, Hr as REMOVE_LEAF, I as customAction, Ii as UnindexedFilterError, In as EntryDescriptorSchema, J as PipelineRunResultBridge, Jn as isZodSecret, Jr as recordSecretRef, Kr as recordArrayItemPath, L as defineCustomActions, Li as UnknownRecordKindError, Ln as RecordFieldPathSchema, Mi as RecordUniqueViolationError, Mr as resolvedValues, N as CAP_STATE_LEAVES, Ni as RecordsError, Nn as DisposerChain, O as HF_REPO, Oi as RECORDS_ERROR_CODES, On as PEER_BYTES_TICKET_TTL_MS, P as CALLER_STAMPED_CAPABILITIES, Pi as RevConflictError, Pn as defineEntryKind, Q as deviceOpsCapability, Qr as RECORD_CLASSES, R as describeCustomActions, Ri as asRecordsError, Rn as RecordIndexSchema, Sa as findMigrationsBlocked, Si as DeclarationRefusedError, Sn as registerKnownSecret, T as isCommand, Ti as InvalidRecordError, Tn as PEER_BYTES_CHUNK_BYTES, U as nodePin, Un as assertValidDeclaration, Ur as collectSecretLeaves, Vn as RecordRetentionSchema, Vr as secretViewsOf, W as readCommandOrigin, Wn as declarationsOf, Wr as mapSecretLeaves, X as MIGRATION_API_VERSION, Xi as emitReadiness, Xr as RECORD_BATCH_MAX, Y as PipelineStepInputSchema, Yi as createEvent, Yr as secretArrayPrefixes, Zr as RECORD_BATCH_MAX_BYTES, _i as parseSecretRef, _n as createSecretsAccess, ai as RECORD_MAX_INDEX_FIELDS, bn as forgetKnownSecret, c as asString, ca as isSecretClear, ci as RECORD_SETTINGS_MAX_ROWS, d as parseJsonUnknown, da as isSecretMarkerLike, di as arrayItemFieldPath, dn as ruleFireOfClaim, dr as ErrorI18nPayloadSchema, dt as ReadinessRegistry, ei as RECORD_DEFAULT_MAX_DATA_BYTES, et as adminUiCapability, f as hfModelUrl, fa as makeSecretMarker, fi as buildSecretRef, fn as makeInMemoryRecords, ft as ReadinessTimeoutError, g as createDeviceProxy, gi as normalizeSecretOwner, gn as REVALIDATE_AFTER_MS, gr as BaseAddon, h as isDeviceScopedCap, hi as isSecretRef, hn as resolveSecretViewsIn, ht as scopeKey, ii as RECORD_MAX_INDEXES, j as CAP_METHOD_TIMEOUTS_MS, ji as RecordTooLargeError, jn as DATAPLANE_SECRET_HEADER, jr as resolveDeviceSettings, ki as RecordNotFoundError, kr as SCOPED_SETTINGS_SCOPES, la as isSecretFieldView, li as RECORD_SWEEP_INTERVAL_MS, ln as CommandOriginClaimSchema, m as DEVICE_SCOPED_CAPS, mi as globalSecretScope, mn as assertTransactScope, mr as readErrorI18n, ni as RECORD_ID_MAX_LENGTH, nr as expandCapMethods, nt as addonPagesSourceCapability, o as asJsonObject, oa as SECRET_CLEAR, oi as RECORD_QUERY_MAX, p as BOOT_RECOVERY_BACKOFF_MS, pa as toSecretFieldView, pi as formatSecretScope, pn as createRecordsAccess, q as viewerUiCapability, qn as collectZodSecretPaths, qr as recordSecretCollection, r as maskUrlCredentials, ri as RECORD_MAX_DATA_BYTES, sa as classifySecretWrite, si as RECORD_SECRET_COLLECTION_PREFIX, t as sleep, ti as RECORD_DELETE_BATCH, ua as isSecretMarker, ui as SECRET_REF_SCHEME, un as RuleFireOriginSchema, ut as MODEL_FORMATS, v as addonSliceHandleApi, vn as MIN_SCRUBBED_LENGTH, wi as ForeignSecretMarkerError, wn as shortSecretRefHash, xa as AddonMigrationsBlockedError, xi as BatchTooLargeError, xn as knownSecretCount, y as createEventBusSliceSource, yn as clearKnownSecrets, yr as normalizeAddonInitResult, zi as recordsErrorFromMessage, zn as RecordKindDeclarationSchema } from "./sleep-Bn346wCJ.mjs";
|
|
2
2
|
import { t as EventCategory } from "./event-category-78tcBemo.mjs";
|
|
3
|
-
import { a as DeviceType, s as errMsg, t as COMPOSED_DEVICE_STABLE_ID_PREFIX } from "./composed-stable-id-
|
|
3
|
+
import { a as DeviceType, s as errMsg, t as COMPOSED_DEVICE_STABLE_ID_PREFIX } from "./composed-stable-id-CPp3votu.mjs";
|
|
4
4
|
//#region src/generated/cap-input-defaults.ts
|
|
5
5
|
/**
|
|
6
6
|
* AUTO-GENERATED by scripts/generate-cap-input-defaults.ts — DO NOT EDIT.
|
|
@@ -15,7 +15,7 @@ import { a as DeviceType, s as errMsg, t as COMPOSED_DEVICE_STABLE_ID_PREFIX } f
|
|
|
15
15
|
* Plain data, zero Zod: a forked runner must not import the schema barrel
|
|
16
16
|
* (~144MB RSS per runner — D28).
|
|
17
17
|
*
|
|
18
|
-
* Coverage:
|
|
18
|
+
* Coverage: 33 caps, 84 methods with defaults.
|
|
19
19
|
*/
|
|
20
20
|
var CAP_INPUT_DEFAULTS = Object.freeze({
|
|
21
21
|
"addons": { "getLogs": { "limit": 100 } },
|
|
@@ -62,7 +62,6 @@ var CAP_INPUT_DEFAULTS = Object.freeze({
|
|
|
62
62
|
"listRecentTransitions": { "limit": 50 },
|
|
63
63
|
"listTransitions": { "limit": 50 }
|
|
64
64
|
},
|
|
65
|
-
"fan-presets": { "capturePreset": { "steps": [] } },
|
|
66
65
|
"llm-runtime": {
|
|
67
66
|
"complete": { "runtime": { "__nested__": {
|
|
68
67
|
"contextSize": 4096,
|
|
@@ -452,7 +451,7 @@ function isCollectionArrayMethodName(capName, method) {
|
|
|
452
451
|
* Per capability, the methods declared `optionalMethod` — the ones whose
|
|
453
452
|
* ABSENCE on a provider is a fact about that provider, not a bug.
|
|
454
453
|
*
|
|
455
|
-
* Coverage: 10 caps,
|
|
454
|
+
* Coverage: 10 caps, 44 methods.
|
|
456
455
|
*/
|
|
457
456
|
var PROVIDER_OPTIONAL_METHODS = Object.freeze({
|
|
458
457
|
"climate-control": [
|
|
@@ -477,6 +476,7 @@ var PROVIDER_OPTIONAL_METHODS = Object.freeze({
|
|
|
477
476
|
"fan-control": [
|
|
478
477
|
"setDirection",
|
|
479
478
|
"setOscillating",
|
|
479
|
+
"setOscillationAxis",
|
|
480
480
|
"setPercentage",
|
|
481
481
|
"setPreset"
|
|
482
482
|
],
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* ones a short-circuit never reached) with a stable path and a human reason, so
|
|
13
13
|
* the editor can paint each block.
|
|
14
14
|
*/
|
|
15
|
+
import type { TimeSite } from '../time/time-spec.js';
|
|
15
16
|
import { type HoldTracker } from './hold.js';
|
|
16
17
|
import { type LegacyCondition } from './legacy-recipe.js';
|
|
17
18
|
import { type AutomationWhen } from './when.js';
|
|
@@ -48,6 +49,15 @@ export interface StableIdDevice {
|
|
|
48
49
|
export declare function stableIdMapOf(devices: readonly StableIdDevice[]): Map<string, number>;
|
|
49
50
|
/** Every (device, cap) a `when` tree's STATE leaves read, deduplicated. */
|
|
50
51
|
export declare function collectWhenMirrorSources(cond: AutomationWhen | undefined): MirrorSource[];
|
|
52
|
+
/** Does the tree hold a `time-is` leaf? */
|
|
53
|
+
export declare function hasTimeLeaves(when: AutomationWhen): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* The soonest ANY `time-is` leaf changes sides (ms from `now`), over every
|
|
56
|
+
* leaf of the tree — a short-circuit that skipped a leaf in the last
|
|
57
|
+
* evaluation must not hide its boundary. Undefined: no time leaf, no site, or
|
|
58
|
+
* no boundary within reach.
|
|
59
|
+
*/
|
|
60
|
+
export declare function nextTimeBoundaryInMs(when: AutomationWhen, now: number, site: TimeSite | undefined, rootPath?: string): number | undefined;
|
|
51
61
|
/** Legacy name, for blocks generated before the single tree: an old condition tree. */
|
|
52
62
|
export declare function collectMirrorSources(cond: LegacyCondition | undefined): MirrorSource[];
|
|
53
63
|
export interface ConditionReader {
|
|
@@ -91,6 +101,8 @@ export interface ConditionEvaluation {
|
|
|
91
101
|
readonly nodes: readonly AutomationConditionTraceNode[];
|
|
92
102
|
/** The soonest a pending `for` completes (ms from now); absent when none is pending. */
|
|
93
103
|
readonly holdDueInMs?: number;
|
|
104
|
+
/** The soonest a `time-is` leaf changes sides (ms from now); absent when the tree holds none or no site. */
|
|
105
|
+
readonly timeDueInMs?: number;
|
|
94
106
|
}
|
|
95
107
|
/** Options of one evaluation of a `when` tree. */
|
|
96
108
|
export interface WhenEvaluationOptions {
|
|
@@ -100,6 +112,18 @@ export interface WhenEvaluationOptions {
|
|
|
100
112
|
readonly holds?: HoldTracker;
|
|
101
113
|
/** The root path (default `when`; the legacy wrapper keeps `conditions`). */
|
|
102
114
|
readonly rootPath?: string;
|
|
115
|
+
/** The site the `time-is` leaves read their clock on; absent, such a leaf is unknown. */
|
|
116
|
+
readonly site?: TimeSite;
|
|
117
|
+
/**
|
|
118
|
+
* What started the run, for a `triggered-by` leaf. Absent, it is read off
|
|
119
|
+
* the tree itself: the id of the leaf at `firedPath`. A tree that is NOT the
|
|
120
|
+
* one the trigger sits in (a step guard) must be told, or say `'unknown'`.
|
|
121
|
+
*/
|
|
122
|
+
readonly trigger?: RunTrigger | 'unknown';
|
|
123
|
+
}
|
|
124
|
+
/** What started a run: the id of the event leaf that fired, or null when none with an id did. */
|
|
125
|
+
export interface RunTrigger {
|
|
126
|
+
readonly leafId: string | null;
|
|
103
127
|
}
|
|
104
128
|
/** Evaluate a `when` tree: the fired event leaf is true, every other event leaf false. */
|
|
105
129
|
export declare function evaluateWhenTree(when: AutomationWhen, reader: ConditionReader, now: number, options?: WhenEvaluationOptions): ConditionEvaluation;
|
|
@@ -123,9 +123,18 @@ export type BecomesRead = {
|
|
|
123
123
|
} | {
|
|
124
124
|
readonly ok: false;
|
|
125
125
|
};
|
|
126
|
+
/** What a `device-becomes` trigger hands the run. */
|
|
127
|
+
export interface BecomesVars {
|
|
128
|
+
readonly deviceId: number;
|
|
129
|
+
/** The value before the change, `null` when it was not a scalar or not seen. */
|
|
130
|
+
readonly from: string | number | boolean | null;
|
|
131
|
+
readonly to: string | number | boolean | null;
|
|
132
|
+
}
|
|
126
133
|
export type BecomesEffect = {
|
|
127
134
|
readonly kind: 'fire';
|
|
128
135
|
readonly value: unknown;
|
|
136
|
+
/** What the field held before it last changed; `undefined` when no change was seen. */
|
|
137
|
+
readonly from: unknown;
|
|
129
138
|
readonly hold?: HoldTrace;
|
|
130
139
|
} | {
|
|
131
140
|
readonly kind: 'hold';
|
|
@@ -153,6 +162,8 @@ export declare class BecomesWatch {
|
|
|
153
162
|
private readonly spec;
|
|
154
163
|
private readonly deps;
|
|
155
164
|
private previous;
|
|
165
|
+
/** The value the field left at its last change — a re-report does not move it. */
|
|
166
|
+
private from;
|
|
156
167
|
private seeded;
|
|
157
168
|
private readonly core;
|
|
158
169
|
private handle;
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export type { GenerateAutomationBlockInput } from './codegen.js';
|
|
12
12
|
export { generateAutomationBlock } from './codegen.js';
|
|
13
|
-
export type { ConditionEvaluation, ConditionReader, MirrorRefreshFetchers, MirrorRefreshReport, MirrorSource, } from './condition-eval.js';
|
|
14
|
-
export { collectMirrorSources, collectWhenMirrorSources, ConditionMirror, stableIdKey, stableIdMapOf, evaluateConditionTree, evaluateWhenTree, hasHoldLeaves, observeHoldLeaves, } from './condition-eval.js';
|
|
13
|
+
export type { ConditionEvaluation, ConditionReader, MirrorRefreshFetchers, RunTrigger, MirrorRefreshReport, MirrorSource, } from './condition-eval.js';
|
|
14
|
+
export { collectMirrorSources, collectWhenMirrorSources, ConditionMirror, stableIdKey, stableIdMapOf, evaluateConditionTree, evaluateWhenTree, hasHoldLeaves, hasTimeLeaves, nextTimeBoundaryInMs, observeHoldLeaves, } from './condition-eval.js';
|
|
15
15
|
export type { BecomesDeps, BecomesEffect, BecomesOperator, BecomesSpec, HoldMode, HoldReading, HoldSpec, HoldTrace, LegacyHoldFields, } from './hold.js';
|
|
16
16
|
export { BecomesOperatorSchema, BecomesWatch, describeHold, describeHoldMs, HoldCore, HoldSpecSchema, HoldTraceSchema, HoldTracker, holdOf, } from './hold.js';
|
|
17
17
|
export type { DetectionDecision, DetectionTrigger, DetectionVars, TrackLifecycleInput, } from './detection-trigger.js';
|
|
@@ -26,8 +26,8 @@ export type { AutomationConditionTraceNode, AutomationRunOutcome, AutomationRunT
|
|
|
26
26
|
export { AutomationConditionTraceNodeSchema, EMPTY_AUTOMATION_STATE, mergeSkipTraces, AutomationRunOutcomeSchema, AutomationRunTraceSchema, AutomationRunVerdictSchema, AutomationStateDocSchema, AutomationStepTraceSchema, AutomationTriggerTraceSchema, appendTrace, buildStepArgsTrace, buildTriggerTrace, isSkippedTrace, MAX_TRACE_ARG_LENGTH, MAX_STEP_DEVICE_OUTCOMES, MAX_TRACE_ARGS, REDACTED_ARG, skipSignature, StepDeviceTraceSchema, TraceNodeOutcomeSchema, TraceValueSchema, } from './trace.js';
|
|
27
27
|
export type { ActionStep, AutomationAction, AutomationCapStep, AutomationRecipe, AutomationRunMode, LegacyAutomationRecipe, NormalizedCapStep, } from './recipe.js';
|
|
28
28
|
export { ActionStepSchema, AutomationActionSchema, AutomationCapStepSchema, AutomationWaitStepSchema, AutomationRecipeSchema, AutomationRunModeSchema, CurrentAutomationRecipeSchema, convertLegacyRecipe, DEFAULT_TRACE_KEEP, LegacyAutomationRecipeSchema, MAX_TRACE_KEEP, MAX_CONDITION_DEPTH, MAX_CONDITION_LEAVES, normalizeCapStep, normalizeStepTargets, validateRecipeBounds, } from './recipe.js';
|
|
29
|
-
export type { AutomationAll, AutomationAny, AutomationConditionOperator, AutomationEventLeaf, AutomationLeaf, AutomationNot, AutomationStateLeaf, AutomationWhen, DetectionLeaf, DeviceBecomesLeaf, DeviceIsLeaf, ExpressionLeaf, StationaryLeaf, StationaryPresentLeaf, } from './when.js';
|
|
30
|
-
export { AutomationConditionOperatorSchema, AutomationWhenSchema, countWhenLeaves, forEachLeaf, hasEventLeaves, isEventLeaf, isLeaf, MAX_WHEN_DEPTH, MAX_WHEN_LEAVES, validateWhenTree, whenDepth, } from './when.js';
|
|
29
|
+
export type { AutomationAll, AutomationAny, AutomationConditionOperator, AutomationEventLeaf, AutomationLeaf, AutomationNot, AutomationStateLeaf, AutomationWhen, DetectionLeaf, DeviceBecomesLeaf, DeviceIsLeaf, ExpressionLeaf, TimeIsLeaf, TriggeredByLeaf, IdentifiedEventLeaf, StationaryLeaf, StationaryPresentLeaf, } from './when.js';
|
|
30
|
+
export { AutomationConditionOperatorSchema, AutomationWhenSchema, countWhenLeaves, eventLeafIdAt, identifiedEventLeaves, hasTriggeredByLeaves, triggeredByIssue, EVENT_LEAF_ID_RE, TRIGGERED_BY_MAX_IDS, forEachLeaf, hasEventLeaves, isEventLeaf, isLeaf, MAX_WHEN_DEPTH, MAX_WHEN_LEAVES, validateWhenTree, whenDepth, } from './when.js';
|
|
31
31
|
export type { LegacyCondition, LegacyTrigger, } from './legacy-recipe.js';
|
|
32
32
|
export { convertLegacyCondition, convertLegacyWhen, LegacyConditionSchema, LegacyTriggerSchema, } from './legacy-recipe.js';
|
|
33
33
|
export type { DetectionLabelSource, DetectionSubject, IdentityLabel, PlateLabel, SubClassLabel, SubjectObservation, SubjectVerdict, } from './detection-subject.js';
|
|
@@ -42,3 +42,5 @@ export { prepareRecipeUnits } from './prepare-units.js';
|
|
|
42
42
|
export type { PreparedRecipe } from './prepare-units.js';
|
|
43
43
|
export type { AutomationLeafCatalog, AutomationLeafCatalogEntry, AutomationLeafCategory, AutomationLeafContext, AutomationLeafKind, AutomationLeafRole, } from './leaf-catalog.js';
|
|
44
44
|
export { AUTOMATION_LEAF_CATALOG, AUTOMATION_LEAF_CATEGORIES, AUTOMATION_LEAF_KINDS, leafCatalogEntry, leafKindsFor, seedLeaf, } from './leaf-catalog.js';
|
|
45
|
+
export { recipeSiteIssues, stepGuardSiteIssues, whenSiteIssues } from './when-site.js';
|
|
46
|
+
export type { GuardedStepLike, WhenSiteIssue } from './when-site.js';
|
|
@@ -141,6 +141,11 @@ export declare const LeafActionStepSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
|
|
|
141
141
|
}, z.core.$strip>], "kind">;
|
|
142
142
|
/** How many steps one `else` list holds. */
|
|
143
143
|
export declare const STEP_ELSE_MAX = 10;
|
|
144
|
+
/**
|
|
145
|
+
* A step of a STANDALONE list (an action, a scheduler point, a preset): the
|
|
146
|
+
* same two step kinds an automation runs, minus a guard that reads the
|
|
147
|
+
* automation's trigger, which such a list does not have.
|
|
148
|
+
*/
|
|
144
149
|
export declare const ActionStepSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
145
150
|
kind: z.ZodLiteral<"wait">;
|
|
146
151
|
seconds: z.ZodNumber;
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* read is UNKNOWN, and unknown runs neither side (D49: a failed read changes
|
|
6
6
|
* nothing, and never decides a branch).
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import type { TimeSite } from '../time/time-spec.js';
|
|
9
|
+
import { ConditionMirror, type MirrorRefreshFetchers, type RunTrigger } from './condition-eval.js';
|
|
9
10
|
import type { HoldTracker } from './hold.js';
|
|
10
11
|
import type { AutomationWhen } from './when.js';
|
|
11
12
|
export type StepConditionResult = 'true' | 'false' | 'unknown';
|
|
@@ -27,4 +28,8 @@ export interface StepConditionHistory {
|
|
|
27
28
|
readonly rootPath: string;
|
|
28
29
|
}
|
|
29
30
|
/** Fill a mirror for the tree's leaves from `fetchers` and judge it NOW. */
|
|
30
|
-
export declare function evaluateStepCondition(when: AutomationWhen, fetchers: MirrorRefreshFetchers, now?: () => number, history?: StepConditionHistory
|
|
31
|
+
export declare function evaluateStepCondition(when: AutomationWhen, fetchers: MirrorRefreshFetchers, now?: () => number, history?: StepConditionHistory,
|
|
32
|
+
/** The site a `time-is` leaf reads its clock on; absent, such a leaf is unknown. */
|
|
33
|
+
site?: TimeSite,
|
|
34
|
+
/** What started the run, for a `triggered-by` leaf; absent, such a leaf is unknown. */
|
|
35
|
+
trigger?: RunTrigger): Promise<StepConditionVerdict>;
|
|
@@ -78,6 +78,8 @@ export declare const AutomationConditionTraceNodeSchema: z.ZodObject<{
|
|
|
78
78
|
schedule: "schedule";
|
|
79
79
|
stationary: "stationary";
|
|
80
80
|
"stationary-present": "stationary-present";
|
|
81
|
+
"time-is": "time-is";
|
|
82
|
+
"triggered-by": "triggered-by";
|
|
81
83
|
}>;
|
|
82
84
|
outcome: z.ZodEnum<{
|
|
83
85
|
fail: "fail";
|
|
@@ -250,6 +252,8 @@ export declare const AutomationRunTraceSchema: z.ZodObject<{
|
|
|
250
252
|
schedule: "schedule";
|
|
251
253
|
stationary: "stationary";
|
|
252
254
|
"stationary-present": "stationary-present";
|
|
255
|
+
"time-is": "time-is";
|
|
256
|
+
"triggered-by": "triggered-by";
|
|
253
257
|
}>;
|
|
254
258
|
outcome: z.ZodEnum<{
|
|
255
259
|
fail: "fail";
|
|
@@ -434,6 +438,8 @@ export declare const AutomationStateDocSchema: z.ZodObject<{
|
|
|
434
438
|
schedule: "schedule";
|
|
435
439
|
stationary: "stationary";
|
|
436
440
|
"stationary-present": "stationary-present";
|
|
441
|
+
"time-is": "time-is";
|
|
442
|
+
"triggered-by": "triggered-by";
|
|
437
443
|
}>;
|
|
438
444
|
outcome: z.ZodEnum<{
|
|
439
445
|
fail: "fail";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { AutomationWhen } from './when.js';
|
|
2
2
|
export interface TriggerVariable {
|
|
3
3
|
readonly name: string;
|
|
4
|
-
/** English hint; the editor translates it by `name`. */
|
|
4
|
+
/** English hint; the editor translates it by `hintKey`, else by `name`. */
|
|
5
5
|
readonly description: string;
|
|
6
|
+
/** Set when the same name means something else on another trigger kind. */
|
|
7
|
+
readonly hintKey?: string;
|
|
6
8
|
}
|
|
7
9
|
/** What one event row kind provides; kinds that provide none are absent. */
|
|
8
10
|
export declare function triggerLeafVariables(kind: string): readonly TriggerVariable[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Save-time check of a `when` tree against the SITE: a `time-is` window
|
|
3
|
+
* bounded by a sun event needs the site location, and any window needs a known
|
|
4
|
+
* time zone. Refused before the save with a typed reason — at run time the
|
|
5
|
+
* same leaf can only read `unknown`, and a rule that never decides is a rule
|
|
6
|
+
* the operator believes is working. Pure: the site reading is handed in.
|
|
7
|
+
*/
|
|
8
|
+
import { type SiteReading, type TimeSpecRefusal } from '../time/time-spec.js';
|
|
9
|
+
import type { AutomationRecipe } from './recipe.js';
|
|
10
|
+
import { type AutomationWhen } from './when.js';
|
|
11
|
+
export interface WhenSiteIssue {
|
|
12
|
+
/** `when.1.between.from` — the end of the window that cannot be placed. */
|
|
13
|
+
readonly path: string;
|
|
14
|
+
readonly reason: TimeSpecRefusal;
|
|
15
|
+
readonly message: string;
|
|
16
|
+
}
|
|
17
|
+
/** Every `time-is` window end of the tree this site cannot place. `rootPath` replaces the leading `when`. */
|
|
18
|
+
export declare function whenSiteIssues(when: AutomationWhen, reading: SiteReading, rootPath?: string): WhenSiteIssue[];
|
|
19
|
+
/** A step as far as its guard goes. */
|
|
20
|
+
export interface GuardedStepLike {
|
|
21
|
+
readonly kind: string;
|
|
22
|
+
readonly if?: AutomationWhen | undefined;
|
|
23
|
+
}
|
|
24
|
+
/** The same check over the guard (`if`) of every step of a list, reported under `<rootPath>.<i>.if`. */
|
|
25
|
+
export declare function stepGuardSiteIssues(steps: readonly GuardedStepLike[], reading: SiteReading, rootPath: string): WhenSiteIssue[];
|
|
26
|
+
/** The whole recipe: its `when` tree and every step guard. */
|
|
27
|
+
export declare function recipeSiteIssues(recipe: AutomationRecipe, reading: SiteReading): WhenSiteIssue[];
|
|
@@ -45,6 +45,12 @@ export declare const AutomationConditionOperatorSchema: z.ZodEnum<{
|
|
|
45
45
|
ne: "ne";
|
|
46
46
|
}>;
|
|
47
47
|
export type AutomationConditionOperator = z.infer<typeof AutomationConditionOperatorSchema>;
|
|
48
|
+
/**
|
|
49
|
+
* The stable name of an event leaf. A path (`when.0.1`) moves when a row is
|
|
50
|
+
* reordered; the id does not, so a `triggered-by` leaf keeps pointing at the
|
|
51
|
+
* same row. Optional: a leaf nothing refers to needs none.
|
|
52
|
+
*/
|
|
53
|
+
export declare const EVENT_LEAF_ID_RE: RegExp;
|
|
48
54
|
/**
|
|
49
55
|
* D8 compliance, and it is the reason a "becomes" leaf is not merely an event
|
|
50
56
|
* subscription: it evaluates against the **state mirror**, which is reconciled,
|
|
@@ -52,6 +58,7 @@ export type AutomationConditionOperator = z.infer<typeof AutomationConditionOper
|
|
|
52
58
|
* fire; it does not lose it.
|
|
53
59
|
*/
|
|
54
60
|
declare const DeviceBecomesLeafSchema: z.ZodObject<{
|
|
61
|
+
id: z.ZodOptional<z.ZodString>;
|
|
55
62
|
kind: z.ZodLiteral<"device-becomes">;
|
|
56
63
|
deviceId: z.ZodNumber;
|
|
57
64
|
cap: z.ZodString;
|
|
@@ -81,6 +88,7 @@ declare const DeviceBecomesLeafSchema: z.ZodObject<{
|
|
|
81
88
|
debounceMs: z.ZodOptional<z.ZodNumber>;
|
|
82
89
|
}, z.core.$strip>;
|
|
83
90
|
declare const DeviceEventLeafSchema: z.ZodObject<{
|
|
91
|
+
id: z.ZodOptional<z.ZodString>;
|
|
84
92
|
kind: z.ZodLiteral<"device-event">;
|
|
85
93
|
category: z.ZodString;
|
|
86
94
|
deviceId: z.ZodOptional<z.ZodNumber>;
|
|
@@ -92,6 +100,7 @@ declare const DeviceEventLeafSchema: z.ZodObject<{
|
|
|
92
100
|
* a stored automation never stops firing, and is not written by new editors.
|
|
93
101
|
*/
|
|
94
102
|
declare const ScheduleLeafSchema: z.ZodObject<{
|
|
103
|
+
id: z.ZodOptional<z.ZodString>;
|
|
95
104
|
kind: z.ZodLiteral<"schedule">;
|
|
96
105
|
at: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
97
106
|
kind: z.ZodLiteral<"clock">;
|
|
@@ -122,13 +131,16 @@ declare const ScheduleLeafSchema: z.ZodObject<{
|
|
|
122
131
|
cron: z.ZodOptional<z.ZodString>;
|
|
123
132
|
}, z.core.$strip>;
|
|
124
133
|
declare const ManualLeafSchema: z.ZodObject<{
|
|
134
|
+
id: z.ZodOptional<z.ZodString>;
|
|
125
135
|
kind: z.ZodLiteral<"manual">;
|
|
126
136
|
}, z.core.$strip>;
|
|
127
137
|
declare const IntervalLeafSchema: z.ZodObject<{
|
|
138
|
+
id: z.ZodOptional<z.ZodString>;
|
|
128
139
|
kind: z.ZodLiteral<"interval">;
|
|
129
140
|
minutes: z.ZodNumber;
|
|
130
141
|
}, z.core.$strip>;
|
|
131
142
|
declare const DetectionLeafSchema: z.ZodObject<{
|
|
143
|
+
id: z.ZodOptional<z.ZodString>;
|
|
132
144
|
kind: z.ZodLiteral<"detection">;
|
|
133
145
|
subjects: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
134
146
|
macro: z.ZodLiteral<"animal">;
|
|
@@ -167,6 +179,7 @@ declare const DetectionLeafSchema: z.ZodObject<{
|
|
|
167
179
|
minScore: z.ZodOptional<z.ZodNumber>;
|
|
168
180
|
}, z.core.$strip>;
|
|
169
181
|
declare const StationaryLeafSchema: z.ZodObject<{
|
|
182
|
+
id: z.ZodOptional<z.ZodString>;
|
|
170
183
|
kind: z.ZodLiteral<"stationary">;
|
|
171
184
|
deviceIds: z.ZodArray<z.ZodNumber>;
|
|
172
185
|
subjects: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -280,6 +293,73 @@ declare const StationaryPresentLeafSchema: z.ZodObject<{
|
|
|
280
293
|
zones: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
281
294
|
minCount: z.ZodOptional<z.ZodNumber>;
|
|
282
295
|
}, z.core.$strip>;
|
|
296
|
+
/**
|
|
297
|
+
* True while the site-local clock is inside a daily window and/or on one of
|
|
298
|
+
* the named days. `days` names the local day a window STARTS on, so
|
|
299
|
+
* 22:00-06:00 on weekdays is still inside at 01:00 Saturday. A one-date spec
|
|
300
|
+
* (`kind: 'date'`) is refused: only a clock time or a sun event makes a window
|
|
301
|
+
* that repeats every day.
|
|
302
|
+
*/
|
|
303
|
+
declare const TimeIsLeafSchema: z.ZodObject<{
|
|
304
|
+
kind: z.ZodLiteral<"time-is">;
|
|
305
|
+
between: z.ZodOptional<z.ZodObject<{
|
|
306
|
+
from: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
307
|
+
kind: z.ZodLiteral<"clock">;
|
|
308
|
+
hh: z.ZodNumber;
|
|
309
|
+
mm: z.ZodNumber;
|
|
310
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
311
|
+
kind: z.ZodLiteral<"sun">;
|
|
312
|
+
event: z.ZodEnum<{
|
|
313
|
+
dawn: "dawn";
|
|
314
|
+
dusk: "dusk";
|
|
315
|
+
sunrise: "sunrise";
|
|
316
|
+
sunset: "sunset";
|
|
317
|
+
}>;
|
|
318
|
+
offsetMin: z.ZodNumber;
|
|
319
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
320
|
+
kind: z.ZodLiteral<"date">;
|
|
321
|
+
local: z.ZodString;
|
|
322
|
+
}, z.core.$strip>], "kind">;
|
|
323
|
+
to: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
324
|
+
kind: z.ZodLiteral<"clock">;
|
|
325
|
+
hh: z.ZodNumber;
|
|
326
|
+
mm: z.ZodNumber;
|
|
327
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
328
|
+
kind: z.ZodLiteral<"sun">;
|
|
329
|
+
event: z.ZodEnum<{
|
|
330
|
+
dawn: "dawn";
|
|
331
|
+
dusk: "dusk";
|
|
332
|
+
sunrise: "sunrise";
|
|
333
|
+
sunset: "sunset";
|
|
334
|
+
}>;
|
|
335
|
+
offsetMin: z.ZodNumber;
|
|
336
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
337
|
+
kind: z.ZodLiteral<"date">;
|
|
338
|
+
local: z.ZodString;
|
|
339
|
+
}, z.core.$strip>], "kind">;
|
|
340
|
+
}, z.core.$strip>>;
|
|
341
|
+
days: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
342
|
+
fri: "fri";
|
|
343
|
+
mon: "mon";
|
|
344
|
+
sat: "sat";
|
|
345
|
+
sun: "sun";
|
|
346
|
+
thu: "thu";
|
|
347
|
+
tue: "tue";
|
|
348
|
+
wed: "wed";
|
|
349
|
+
}>>>;
|
|
350
|
+
}, z.core.$strip>;
|
|
351
|
+
/** How many event leaves one `triggered-by` names. */
|
|
352
|
+
export declare const TRIGGERED_BY_MAX_IDS = 20;
|
|
353
|
+
/**
|
|
354
|
+
* True for the run that one of the named event leaves started. It reads the
|
|
355
|
+
* run, not a device: in the tree it is judged against the leaf that fired, in
|
|
356
|
+
* a step guard against the trigger the run carries. A run no event leaf
|
|
357
|
+
* started (a state-only tree becoming true) is false.
|
|
358
|
+
*/
|
|
359
|
+
declare const TriggeredByLeafSchema: z.ZodObject<{
|
|
360
|
+
kind: z.ZodLiteral<"triggered-by">;
|
|
361
|
+
leafIds: z.ZodArray<z.ZodString>;
|
|
362
|
+
}, z.core.$strip>;
|
|
283
363
|
/**
|
|
284
364
|
* The escape hatch: the bounded expression engine over named device bindings.
|
|
285
365
|
* Declared as a plain object so a discriminated union can read `kind`; the
|
|
@@ -313,7 +393,7 @@ declare const ExpressionLeafSchema: z.ZodObject<{
|
|
|
313
393
|
}, z.core.$strip>>;
|
|
314
394
|
}, z.core.$strip>;
|
|
315
395
|
export type AutomationEventLeaf = z.infer<typeof DeviceBecomesLeafSchema> | z.infer<typeof DeviceEventLeafSchema> | z.infer<typeof ScheduleLeafSchema> | z.infer<typeof ManualLeafSchema> | z.infer<typeof IntervalLeafSchema> | z.infer<typeof DetectionLeafSchema> | z.infer<typeof StationaryLeafSchema>;
|
|
316
|
-
export type AutomationStateLeaf = z.infer<typeof DeviceIsLeafSchema> | z.infer<typeof StationaryPresentLeafSchema> | z.infer<typeof ExpressionLeafSchema>;
|
|
396
|
+
export type AutomationStateLeaf = z.infer<typeof DeviceIsLeafSchema> | z.infer<typeof StationaryPresentLeafSchema> | z.infer<typeof ExpressionLeafSchema> | z.infer<typeof TimeIsLeafSchema> | z.infer<typeof TriggeredByLeafSchema>;
|
|
317
397
|
export type AutomationLeaf = AutomationEventLeaf | AutomationStateLeaf;
|
|
318
398
|
export type DeviceBecomesLeaf = Extract<AutomationEventLeaf, {
|
|
319
399
|
kind: 'device-becomes';
|
|
@@ -333,6 +413,12 @@ export type StationaryPresentLeaf = Extract<AutomationStateLeaf, {
|
|
|
333
413
|
export type ExpressionLeaf = Extract<AutomationStateLeaf, {
|
|
334
414
|
kind: 'expression';
|
|
335
415
|
}>;
|
|
416
|
+
export type TimeIsLeaf = Extract<AutomationStateLeaf, {
|
|
417
|
+
kind: 'time-is';
|
|
418
|
+
}>;
|
|
419
|
+
export type TriggeredByLeaf = Extract<AutomationStateLeaf, {
|
|
420
|
+
kind: 'triggered-by';
|
|
421
|
+
}>;
|
|
336
422
|
export interface AutomationAll {
|
|
337
423
|
readonly kind: 'all';
|
|
338
424
|
readonly children: readonly AutomationWhen[];
|
|
@@ -356,6 +442,26 @@ export declare function countWhenLeaves(node: AutomationWhen): number;
|
|
|
356
442
|
/** Every leaf with its path (`when`, `when.0`, `when.0.1`, `when.0` under a `not`). */
|
|
357
443
|
export declare function forEachLeaf(node: AutomationWhen, visit: (leaf: AutomationLeaf, path: string) => void, path?: string): void;
|
|
358
444
|
export declare function hasEventLeaves(node: AutomationWhen): boolean;
|
|
445
|
+
/** One event leaf that carries an id, with where it sits. */
|
|
446
|
+
export interface IdentifiedEventLeaf {
|
|
447
|
+
readonly id: string;
|
|
448
|
+
readonly path: string;
|
|
449
|
+
readonly leaf: AutomationEventLeaf;
|
|
450
|
+
}
|
|
451
|
+
/** The event leaves of the tree that carry an id, in tree order. */
|
|
452
|
+
export declare function identifiedEventLeaves(when: AutomationWhen): IdentifiedEventLeaf[];
|
|
453
|
+
/** The id of the event leaf at `path` (`when.0.1`); null when the leaf has none or the path names no event leaf. */
|
|
454
|
+
export declare function eventLeafIdAt(when: AutomationWhen, path: string): string | null;
|
|
455
|
+
/** Does the tree hold a `triggered-by` leaf? */
|
|
456
|
+
export declare function hasTriggeredByLeaves(when: AutomationWhen): boolean;
|
|
457
|
+
/** Why a `triggered-by` leaf is refused outside an automation: there is no trigger row to name. */
|
|
458
|
+
export declare const TRIGGERED_BY_NEEDS_AUTOMATION = "\"triggered by\" reads which trigger started an automation \u2014 an action or a scheduler has no trigger rows, so it could never be true here";
|
|
459
|
+
/**
|
|
460
|
+
* What is wrong with the `triggered-by` leaves of `tree`, given the ids the
|
|
461
|
+
* automation's event leaves carry: an id nothing carries can never be true.
|
|
462
|
+
* `where` names the tree in the message (`the rules`, `step 2`).
|
|
463
|
+
*/
|
|
464
|
+
export declare function triggeredByIssue(tree: AutomationWhen, knownIds: ReadonlySet<string>, where: string): string | null;
|
|
359
465
|
/**
|
|
360
466
|
* Author-time bounds and sense check of a `when` tree. Returns `null` when it
|
|
361
467
|
* is legal, else a message the editor shows verbatim.
|
|
@@ -34,7 +34,7 @@ export declare const accessoriesCapability: {
|
|
|
34
34
|
readonly scope: 'device';
|
|
35
35
|
readonly deviceNative: true;
|
|
36
36
|
readonly mode: 'singleton';
|
|
37
|
-
readonly deviceTypes: readonly [DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Sensor, DeviceType.
|
|
37
|
+
readonly deviceTypes: readonly [DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Sensor, DeviceType.Climate, DeviceType.Cover, DeviceType.Lock, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Generic];
|
|
38
38
|
readonly methods: {
|
|
39
39
|
/**
|
|
40
40
|
* Toggle the UI-visibility of a single accessory child. Hidden
|
|
@@ -316,6 +316,8 @@ export declare const actionsCapability: {
|
|
|
316
316
|
schedule: "schedule";
|
|
317
317
|
stationary: "stationary";
|
|
318
318
|
"stationary-present": "stationary-present";
|
|
319
|
+
"time-is": "time-is";
|
|
320
|
+
"triggered-by": "triggered-by";
|
|
319
321
|
}>;
|
|
320
322
|
outcome: z.ZodEnum<{
|
|
321
323
|
fail: "fail";
|
|
@@ -29,7 +29,7 @@ export declare const batteryCapability: {
|
|
|
29
29
|
readonly scope: 'device';
|
|
30
30
|
readonly deviceNative: true;
|
|
31
31
|
readonly mode: 'singleton';
|
|
32
|
-
readonly deviceTypes: readonly [DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.
|
|
32
|
+
readonly deviceTypes: readonly [DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Climate, DeviceType.EventEmitter];
|
|
33
33
|
readonly methods: {
|
|
34
34
|
/**
|
|
35
35
|
* Explicitly wake the camera from low-power sleep ahead of a
|
|
@@ -177,7 +177,7 @@ export declare const batteryCapability: {
|
|
|
177
177
|
readonly cap: 'battery';
|
|
178
178
|
readonly stateField: 'level';
|
|
179
179
|
};
|
|
180
|
-
readonly deviceTypes: readonly [DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.
|
|
180
|
+
readonly deviceTypes: readonly [DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Climate, DeviceType.EventEmitter];
|
|
181
181
|
readonly apply: 'add';
|
|
182
182
|
readonly path: 'level';
|
|
183
183
|
readonly sources: readonly [{
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* 5. Registry auto-mounts tRPC router from definition.methods
|
|
13
13
|
*/
|
|
14
14
|
import { z } from 'zod';
|
|
15
|
-
import { DeviceType } from '../device/device-type.js';
|
|
15
|
+
import { type DeviceRole, DeviceType } from '../device/device-type.js';
|
|
16
16
|
import type { ConfigUISchemaWithValues } from '../interfaces/config-ui.js';
|
|
17
17
|
import type { ExtensionSlotDescriptor } from '../device-extension/slot-descriptor.js';
|
|
18
18
|
import type { MethodRoleDecl } from '../auth/viewer-access.js';
|
|
@@ -531,6 +531,37 @@ export type ComposedMethodAnswer = {
|
|
|
531
531
|
readonly kind: 'slice';
|
|
532
532
|
readonly field: string;
|
|
533
533
|
};
|
|
534
|
+
/** A boolean slice field and its setter, e.g. `humidifier.on` + `setOn({ on })`. */
|
|
535
|
+
export interface PowerHintField {
|
|
536
|
+
readonly kind: 'field';
|
|
537
|
+
readonly field: string;
|
|
538
|
+
readonly set: string;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* A state field read as on unless it is one of `offValues`, and two argument-
|
|
542
|
+
* less methods, e.g. `media-player.state` + `turnOn` / `turnOff`.
|
|
543
|
+
*/
|
|
544
|
+
export interface PowerHintMethods {
|
|
545
|
+
readonly kind: 'methods';
|
|
546
|
+
readonly field: string;
|
|
547
|
+
readonly offValues: readonly string[];
|
|
548
|
+
readonly on: string;
|
|
549
|
+
readonly off: string;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* A mode whose `offValue` is off, e.g. `climate-control.mode` + `setMode({ mode })`.
|
|
553
|
+
* On restores `lastField`, the last non-off mode kept in the same slice by
|
|
554
|
+
* `registerPowerSwitch`; with none it refuses (`no-last-mode`), never guesses.
|
|
555
|
+
*/
|
|
556
|
+
export interface PowerHintMode {
|
|
557
|
+
readonly kind: 'mode';
|
|
558
|
+
readonly field: string;
|
|
559
|
+
readonly offValue: string;
|
|
560
|
+
readonly set: string;
|
|
561
|
+
readonly lastField: string;
|
|
562
|
+
}
|
|
563
|
+
/** Which field and method of a cap are the device's own power (#462). */
|
|
564
|
+
export type CapabilityPowerHint = PowerHintField | PowerHintMethods | PowerHintMode;
|
|
534
565
|
/**
|
|
535
566
|
* Full definition of a capability — the single source of truth for the
|
|
536
567
|
* functional contract (methods + events).
|
|
@@ -701,8 +732,23 @@ export interface CapabilityDefinition<TName extends string = string, TMethods ex
|
|
|
701
732
|
* vendor providers carry NO contribution methods.
|
|
702
733
|
*/
|
|
703
734
|
readonly deviceConfig?: DeviceConfigSpec;
|
|
735
|
+
/**
|
|
736
|
+
* Which field and method of THIS cap are the device's own power (#462). The
|
|
737
|
+
* owner registers `switch` for such a device through `registerPowerSwitch`,
|
|
738
|
+
* which reads `switch.on` from this cap's slice and routes `setState` here.
|
|
739
|
+
* Behavioural metadata, so it lives here and only here (D4).
|
|
740
|
+
* `scripts/check-power-hint.ts` refuses another on/off field or setter.
|
|
741
|
+
*/
|
|
742
|
+
readonly power?: CapabilityPowerHint;
|
|
704
743
|
/** For `scope: 'device'` caps — allowed device types. Omit → applies to every type. */
|
|
705
744
|
readonly deviceTypes?: readonly DeviceType[];
|
|
745
|
+
/**
|
|
746
|
+
* Narrows `deviceTypes` by role (D1033): for a type named here, the cap is
|
|
747
|
+
* offered only on a device carrying one of these roles. A type absent from
|
|
748
|
+
* this map keeps every role. `timed-run` is offered on a `switch` only when
|
|
749
|
+
* it is a `switch-heater`.
|
|
750
|
+
*/
|
|
751
|
+
readonly deviceRoles?: Readonly<Partial<Record<DeviceType, readonly DeviceRole[]>>>;
|
|
706
752
|
/**
|
|
707
753
|
* Extension slots this capability OWNS (D648): the ways a device of this
|
|
708
754
|
* kind can be extended by other devices, served by this cap's owner over
|