@camstack/types 1.2.529 → 1.2.530

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.
Files changed (29) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/addon.js +1 -1
  3. package/dist/addon.mjs +1 -1
  4. package/dist/capabilities/capability-definition.d.ts +15 -0
  5. package/dist/capabilities/climate-control.cap.d.ts +26 -1
  6. package/dist/capabilities/enum-sensor.cap.d.ts +1 -1
  7. package/dist/capabilities/hero-layout.cap.d.ts +158 -17
  8. package/dist/capabilities/water-heater.cap.d.ts +5 -1
  9. package/dist/device/hero/climate-view.d.ts +45 -0
  10. package/dist/device/hero/hero-contribution-kit.d.ts +27 -0
  11. package/dist/device/hero/hero-contributions-access.d.ts +2 -0
  12. package/dist/device/hero/hero-contributions-actuators.d.ts +2 -0
  13. package/dist/device/hero/hero-contributions-climate.d.ts +3 -0
  14. package/dist/device/hero/hero-contributions-devices.d.ts +2 -0
  15. package/dist/device/hero/hero-contributions-groups.d.ts +2 -0
  16. package/dist/device/hero/hero-contributions-sensors.d.ts +2 -0
  17. package/dist/device/hero/hero-contributions.d.ts +2 -5
  18. package/dist/device/hero/hero-fragment.d.ts +11 -1
  19. package/dist/device/hero/hero-look.d.ts +80 -14
  20. package/dist/device/hero/hero-model.d.ts +224 -34
  21. package/dist/device/hero/hero-row.d.ts +30 -5
  22. package/dist/device/hero/media-player-view.d.ts +6 -0
  23. package/dist/generated/addon-cap-facts.d.ts +1 -1
  24. package/dist/generated/runtime-state-durability.d.ts +6 -1
  25. package/dist/index.js +2488 -216
  26. package/dist/index.mjs +2488 -216
  27. package/dist/{sleep-CqvzKIq2.mjs → sleep-CfYvHNFz.mjs} +16 -0
  28. package/dist/{sleep-DX_umr22.js → sleep-CqsZMKxq.js} +16 -0
  29. package/package.json +1 -1
@@ -23,6 +23,7 @@ export declare const WaterHeaterStatusSchema: z.ZodObject<{
23
23
  away: z.ZodNullable<z.ZodBoolean>;
24
24
  minTemp: z.ZodNullable<z.ZodNumber>;
25
25
  maxTemp: z.ZodNullable<z.ZodNumber>;
26
+ lastActiveMode: z.ZodOptional<z.ZodString>;
26
27
  lastChangedAt: z.ZodNumber;
27
28
  }, z.core.$strip>;
28
29
  export type WaterHeaterStatus = z.infer<typeof WaterHeaterStatusSchema>;
@@ -55,6 +56,7 @@ export declare const waterHeaterCapability: {
55
56
  away: z.ZodNullable<z.ZodBoolean>;
56
57
  minTemp: z.ZodNullable<z.ZodNumber>;
57
58
  maxTemp: z.ZodNullable<z.ZodNumber>;
59
+ lastActiveMode: z.ZodOptional<z.ZodString>;
58
60
  lastChangedAt: z.ZodNumber;
59
61
  }, z.core.$strip>;
60
62
  readonly kind: 'push';
@@ -71,6 +73,7 @@ export declare const waterHeaterCapability: {
71
73
  away: z.ZodNullable<z.ZodBoolean>;
72
74
  minTemp: z.ZodNullable<z.ZodNumber>;
73
75
  maxTemp: z.ZodNullable<z.ZodNumber>;
76
+ lastActiveMode: z.ZodOptional<z.ZodString>;
74
77
  lastChangedAt: z.ZodNumber;
75
78
  }, z.core.$strip>;
76
79
  /**
@@ -79,7 +82,8 @@ export declare const waterHeaterCapability: {
79
82
  * See `RuntimeStateDurability`. Enforced by
80
83
  * `scripts/check-runtime-state-durability.ts`.
81
84
  */
82
- readonly durability: 'session';
85
+ readonly durability: 'restored';
86
+ readonly restoredStateFields: readonly ["lastActiveMode"];
83
87
  /**
84
88
  * History (D850): recorded series. The schema carries no unit; providers publish Celsius. Setpoint keeps every change.
85
89
  */
@@ -0,0 +1,45 @@
1
+ /**
2
+ * What a climate-control slice means for a hero (D1023): one pure derivation,
3
+ * so the contribution only maps it to model parts. Nothing here guesses: a
4
+ * slice that did not answer is `null`, a missing bound is a missing bound.
5
+ */
6
+ import type { ClimateControlStatus, HvacMode } from '../../capabilities/climate-control.cap.js';
7
+ import type { HeroSceneMode } from './hero-scene.js';
8
+ import { type HeroText } from './hero-text.js';
9
+ export interface ClimateSetpointRange {
10
+ readonly min: number;
11
+ readonly max: number;
12
+ readonly step: number;
13
+ }
14
+ export interface ClimateView {
15
+ readonly mode: HvacMode;
16
+ readonly isOff: boolean;
17
+ readonly modeLabel: HeroText;
18
+ readonly target: number | null;
19
+ readonly measured: number | null;
20
+ /** The dual setpoint of a range mode (`heat_cool`); both ends or neither. */
21
+ readonly targetRange: {
22
+ readonly low: number;
23
+ readonly high: number;
24
+ } | null;
25
+ readonly targetHumidity: number | null;
26
+ readonly humidity: number | null;
27
+ /** The bounds the device reported; `null` when it did not (the stepper is then not offered). */
28
+ readonly range: ClimateSetpointRange | null;
29
+ readonly availableModes: readonly HvacMode[];
30
+ readonly sceneMode: HeroSceneMode | null;
31
+ /** The setpoint inside its range, 0..1; `null` without a setpoint or a range. */
32
+ readonly level: number | null;
33
+ /** The mode that "turn on" selects; `null` when the device lists none. */
34
+ readonly onMode: HvacMode | null;
35
+ }
36
+ export declare function modeLabelOf(mode: HvacMode): HeroText;
37
+ /** 22 -> "22", 22.3 -> "22.3": a trailing zero is noise on a thermostat. */
38
+ export declare function formatDegrees(value: number): string;
39
+ export declare function deriveClimateView(slice: ClimateControlStatus): ClimateView;
40
+ /** "22° (22.3°)": the setpoint and, in brackets, what is measured. The mode is the headline, not repeated here. */
41
+ export declare function thermalStatusText(target: number | string | null, measured: number | null): HeroText | null;
42
+ export declare function climateStatusText(view: ClimateView): HeroText | null;
43
+ /** The setpoint inside its range, 0..1. */
44
+ export declare function levelWithin(value: number | null, range: ClimateSetpointRange | null): number | null;
45
+ export declare function rangeFrom(min: number | null | undefined, max: number | null | undefined, step: number | null | undefined): ClimateSetpointRange | null;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The pieces every cap contribution is written with (D1023): the contribution
3
+ * shape, the boundary parse, and the builders of an action, a reading and a
4
+ * fact. Shared by `hero-contributions.ts` and the per-theme contribution files,
5
+ * so a contribution reads the same wherever it lives.
6
+ */
7
+ import type { z } from 'zod';
8
+ import type { VocabIcon } from './cap-vocabulary-icon.js';
9
+ import type { HeroContext, HeroFragment, StateReading } from './hero-fragment.js';
10
+ import type { HeroAction, HeroArgs, HeroConfirm, HeroControl, HeroFact, HeroRow } from './hero-model.js';
11
+ import type { HeroState } from './hero-state.js';
12
+ import { type HeroText } from './hero-text.js';
13
+ export interface HeroContribution {
14
+ readonly cap: string;
15
+ readonly contribute: (slice: unknown, ctx: HeroContext) => HeroFragment;
16
+ }
17
+ /** Parses the raw slice with the cap's own schema; `undefined` when it does not parse. */
18
+ export declare function contribution<S>(cap: string, schema: z.ZodType<S>, build: (slice: S | undefined, ctx: HeroContext) => HeroFragment): HeroContribution;
19
+ export declare function action(id: string, label: HeroText, icon: VocabIcon, cap: string, method: string, args?: HeroArgs, emphasis?: 'primary' | 'normal', confirm?: HeroConfirm | null): HeroAction;
20
+ export declare const asAction: (a: HeroAction) => HeroControl;
21
+ export declare function reading(source: StateReading['source'], state: HeroState, assumed?: boolean, title?: HeroText): StateReading;
22
+ export declare function fact(id: HeroFact['id'], icon: HeroFact['icon'], text: HeroText, tone?: HeroFact['tone']): HeroFact;
23
+ export declare function row(id: HeroRow['id'], icon: HeroRow['icon'], status: HeroText | null, controls?: readonly HeroControl[]): HeroRow;
24
+ /** "5 min" / "3 h" / "2 d" since `at`; `null` when the moment is unknown (0) or in the future. */
25
+ export declare function elapsedText(at: number, now: number): HeroText | null;
26
+ /** Joins words with " · ", skipping what is not there. */
27
+ export declare function joinText(parts: readonly (HeroText | null)[]): HeroText | null;
@@ -0,0 +1,2 @@
1
+ import { type HeroContribution } from './hero-contribution-kit.js';
2
+ export declare const ACCESS_FAMILY_CONTRIBUTIONS: Readonly<Record<string, HeroContribution>>;
@@ -0,0 +1,2 @@
1
+ import { type HeroContribution } from './hero-contribution-kit.js';
2
+ export declare const ACTUATORS_FAMILY_CONTRIBUTIONS: Readonly<Record<string, HeroContribution>>;
@@ -0,0 +1,3 @@
1
+ import { type HeroContribution } from './hero-contribution-kit.js';
2
+ /** The climate family, in the order their fragments are merged (a valve's level outranks a setpoint's). */
3
+ export declare const CLIMATE_FAMILY_CONTRIBUTIONS: Readonly<Record<string, HeroContribution>>;
@@ -0,0 +1,2 @@
1
+ import { type HeroContribution } from './hero-contribution-kit.js';
2
+ export declare const DEVICES_FAMILY_CONTRIBUTIONS: Readonly<Record<string, HeroContribution>>;
@@ -0,0 +1,2 @@
1
+ import { type HeroContribution } from './hero-contribution-kit.js';
2
+ export declare const GROUPS_FAMILY_CONTRIBUTIONS: Readonly<Record<string, HeroContribution>>;
@@ -0,0 +1,2 @@
1
+ import { type HeroContribution } from './hero-contribution-kit.js';
2
+ export declare const SENSORS_FAMILY_CONTRIBUTIONS: Readonly<Record<string, HeroContribution>>;
@@ -1,7 +1,4 @@
1
- import type { HeroContext, HeroFragment } from './hero-fragment.js';
2
- export interface HeroContribution {
3
- readonly cap: string;
4
- readonly contribute: (slice: unknown, ctx: HeroContext) => HeroFragment;
5
- }
1
+ import { type HeroContribution } from './hero-contribution-kit.js';
2
+ export type { HeroContribution } from './hero-contribution-kit.js';
6
3
  /** Every contributing cap, in the order their fragments are merged. */
7
4
  export declare const HERO_CAP_CONTRIBUTIONS: readonly HeroContribution[];
@@ -5,13 +5,19 @@
5
5
  import type { HeroBadge, HeroConsumablesSlot, HeroConsumptionSlot, HeroFact, HeroOwnPowerSlot, HeroPowerSupplySlot, HeroRemoteSlot, HeroRow, HeroSideTile, HeroTimedRunSlot } from './hero-model.js';
6
6
  import type { HeroSceneMode } from './hero-scene.js';
7
7
  import type { HeroState } from './hero-state.js';
8
+ import type { HeroText } from './hero-text.js';
8
9
  /** Which cap a state reading comes from; `STATE_SOURCE_ORDER` ranks them. */
9
- export type StateSource = 'media-player' | 'dishwasher' | 'running-state' | 'switch' | 'contact';
10
+ export type StateSource = 'media-player' | 'dishwasher' | 'lock-control' | 'alarm-panel' | 'vacuum-control' | 'lawn-mower-control' | 'fan-control' | 'pet-feeder' | 'pet-fountain' | 'automation-control' | 'script-runner' | 'event-emitter' | 'running-state' | 'switch' | 'contact' | 'group-active' | 'cover' | 'valve' | 'humidifier' | 'brightness' | 'smoke' | 'flood' | 'gas' | 'tamper' | 'vibration' | 'doorbell' | 'motion' | 'presence' | 'update' | 'weather' | 'image' | 'control' | 'meter' | 'binary' | 'button' | 'climate-control' | 'sensor';
10
11
  export interface StateReading {
11
12
  readonly source: StateSource;
12
13
  readonly state: HeroState;
13
14
  /** The state is the driver's own bookkeeping, not a reading. */
14
15
  readonly assumed: boolean;
16
+ /**
17
+ * The words for the state when the generic ones ("On", "Off") would mislead:
18
+ * a lock is "Locked", an alarm "Armed away". Absent = the state's own words.
19
+ */
20
+ readonly title?: HeroText;
15
21
  }
16
22
  export interface HeroContext {
17
23
  readonly deviceId: number;
@@ -22,6 +28,8 @@ export interface HeroContext {
22
28
  readonly running: boolean | null | undefined;
23
29
  /** Saved remote commands; `null` = not known. */
24
30
  readonly remoteCommands: number | null;
31
+ /** The caps the device is bound to: a contribution that overlaps another cap's fact yields to it. */
32
+ readonly caps: readonly string[];
25
33
  }
26
34
  export interface HeroFragment {
27
35
  readonly reading?: StateReading;
@@ -47,6 +55,8 @@ export interface HeroFragment {
47
55
  readonly right?: readonly HeroSideTile[];
48
56
  };
49
57
  /** What the scene is doing, when this cap knows. The first fragment that names a field wins. */
58
+ /** What the hero's headline says instead of the state word (a mode, a reading). The first fragment that names one wins; offline and unknown are never overridden. */
59
+ readonly title?: HeroText;
50
60
  readonly scene?: {
51
61
  readonly mode?: HeroSceneMode;
52
62
  readonly level?: number;