/** * @file Node-RED helper that syncs downstream smart-device state back to an LSH actuator. * * The node is intentionally policy-light: upstream flow nodes translate vendor-specific * payloads to a boolean desired state and annotate each message with the LSH device/actuator * that powers that downstream device. This helper only reads the selected `lsh-logic` * context exports, compares state when available, and emits a Homie `state/set` command. */ import type { Node, NodeAPI } from "node-red"; import type { ContextName } from "./node-red-runtime"; type AllowedDirection = "both" | "on-only" | "off-only"; type LshActuatorSyncNodeDef = { id: string; type: string; name: string; z: string; stateContext: ContextName; stateKey: string; configContext: ContextName; configKey: string; desiredStateProperty: string; deviceIdProperty: string; actuatorIdProperty: string; qos: string | number; ignoreRetained: boolean | string; requireKnownState: boolean | string; commandCooldownMs: number | string; stateWaitTimeoutMs?: number | string; allowedDirection?: AllowedDirection; }; /** * Runtime class attached to a single `lsh-actuator-sync` Node-RED node instance. */ export declare class LshActuatorSyncNode { private readonly node; private readonly red; private readonly config; private readonly lastCommandTimes; private readonly pendingSyncs; /** * Creates one runtime instance and validates the editor configuration once. */ constructor(node: Node, red: NodeAPI, config: LshActuatorSyncNodeDef); /** * Wires Node-RED lifecycle events and guarantees pending timers are cleaned up. */ private registerNodeEventHandlers; /** * Handles one external state message and always completes the Node-RED callback. */ private handleInput; /** * Parses input into a concrete sync target, applies direction policy, then builds a command. */ private handleSyncRequest; /** * Reads current LSH exports and returns either a command, a no-op, or a retryable reason. */ private tryBuildCommand; /** * Queues retryable startup problems or reports them immediately when waiting is disabled. */ private deferOrSkip; /** * Stores the latest pending state for a target and schedules the next readiness check. */ private queuePendingSync; /** * Re-checks one queued target and emits a command only after LSH state is safe to trust. */ private retryPendingSync; /** * Reads the authoritative actuator state from the exported LSH device registry. */ private readCurrentState; /** * Reads a configured Node-RED message property using the runtime utility API. */ private readMessageProperty; /** * Selects the configured flow/global context store. */ private getContext; /** * Enforces a per-actuator command cooldown to avoid feedback loops. */ private isCoolingDown; /** * Applies the ON-only/OFF-only guard used for powered smart-light edge cases. */ private isDirectionAllowed; /** * Builds the stable map key used for cooldown and pending-sync tracking. */ private targetKey; /** * Formats the warning shown when a retryable problem ultimately times out. */ private warningForRetryableReason; /** * Formats compact status text for retryable startup problems. */ private statusForReason; /** * Reports an intentional no-op without throwing or failing the Node-RED message. */ private skip; /** * Updates the Node-RED node status with the package-wide status shape. */ private setStatus; } export {}; //# sourceMappingURL=lsh-actuator-sync.d.ts.map