/** * Primary-capability ranking for device tiles (design.md D12, D16; task 10.5). * * A tile has room for one primary action and one primary readout, while the * capability schema supplies an unranked set. This module is the single, * purely presentational place that curates one of each — nothing here has a * server-side representation, so it can be re-tuned against real hardware * without touching specs (design.md D16, D23). * * Ranking reads well-known property names authored across every source * (`on`, `state`, `position`, `brightness`, `power`, `temperature`, …). The * named branches consult only those property names; the enum/numeric * fall-through additionally consults {@link OUTPUT_KINDS}, the one * cross-source `kind` contract every source already authors deliberately * (design.md D4) — so a configuration setting on a purely-reporting device * (a motion sensor's sensitivity) is not mistaken for a primary action. */ import type { Capability, CapabilityAccess, CapabilityValueType } from "../../../../types/capabilities.js"; /** * The source-neutral output-device kinds — a cross-source `kind` contract * `shelly-capabilities.ts`, `nanoleaf-source.ts`, and `state-source.ts` * already author deliberately, and the mapped Zigbee2MQTT `exposes` use for * the same families. The single set behind both the ranking guard below and * the collection filter, so a device hidden by the filter is exactly one * that would not have offered a primary action (design.md D4). */ export declare const OUTPUT_KINDS: ReadonlySet; /** A leaf (non-container) capability, flattened out of any nested `features`. */ export interface FlatCapability { property: string; valueType: CapabilityValueType; access: CapabilityAccess; unit?: string; permittedValues?: (string | number)[]; range?: { min?: number; max?: number; }; step?: number; /** The declared on/off encoding for a boolean property (design.md D1). */ valueOn?: string | number | boolean; valueOff?: string | number | boolean; /** * The `kind` of the top-level capability entry this leaf was flattened * from — its own `kind` when it is not nested in a container, or its * container's `kind` when it is (design.md D4). Consulted only by the * enum/numeric fall-through via {@link OUTPUT_KINDS}. */ kind: string; } /** Recursively flattens a capability tree into its leaf (property-bearing) entries. */ export declare function flattenCapabilities(capabilities: Capability[]): FlatCapability[]; /** Which ranked action a device's primary action matched, if any. */ export type PrimaryActionKind = "on_off" | "position" | "brightness" | "setpoint" | "enum" | "numeric"; export interface PrimaryAction { kind: PrimaryActionKind; capability: FlatCapability; } /** * Selects a device's single primary actuatable property, first match wins * (design.md D16). Returns `null` when nothing writable matches any rank — * the tile then degrades to read-only rather than failing to render. */ export declare function selectPrimaryAction(capabilities: Capability[]): PrimaryAction | null; /** * Whether a device would offer a tile primary action at all (design.md D4; * specs/web-ui "Device Tiles" — the output filter). Defined as exactly the * devices {@link selectPrimaryAction} finds one for, so a device hidden by * the filter is exactly one that would not have offered a primary action — * two independently maintained rules would drift and produce a device that * is filtered out yet has a working control, or vice versa. */ export declare function isOperableDevice(capabilities: Capability[]): boolean; /** Which ranked readout a device's primary readout matched, if any. */ export type PrimaryReadoutKind = "brightness" | "position" | "power" | "setpoint" | "temperature" | "humidity" | "occupancy" | "contact" | "illuminance" | "water_leak" | "battery" | "numeric"; export interface PrimaryReadout { kind: PrimaryReadoutKind; capability: FlatCapability; } /** * Selects a device's single primary readout property (design.md D16). * `primaryAction` is the result of {@link selectPrimaryAction} for the same * device — the readout ranking differs depending on whether one was found. */ export declare function selectPrimaryReadout(capabilities: Capability[], primaryAction: PrimaryAction | null): PrimaryReadout | null; /** The decided tile ranking for one device — what {@link selectPrimaryAction}/{@link selectPrimaryReadout} together produce. */ export interface TileRanking { action: PrimaryAction | null; readout: PrimaryReadout | null; } /** Convenience: computes both the primary action and the primary readout for a device's capability schema. */ export declare function rankDeviceTile(capabilities: Capability[]): TileRanking; //# sourceMappingURL=capability-ranking.d.ts.map