/** * MQTT Sink Trait * * Publish object state changes to MQTT topics. * Supports retained messages, QoS levels, and automatic serialization. * * @version 1.0.0 */ import type { TraitHandler, HSPlusNode } from '@holoscript/core'; import { MQTTClient, type QoS } from '@holoscript/engine/runtime/protocols/MQTTClient'; export interface MQTTSinkConfig { /** MQTT broker URL */ broker: string; /** Topic to publish to (can include {placeholders} for dynamic topics) */ topic: string; /** Retain messages on broker */ retain: boolean; /** QoS level (0, 1, or 2) */ qos: QoS; /** Client ID (optional, auto-generated if not provided) */ clientId?: string; /** Username for authentication */ username?: string; /** Password for authentication */ password?: string; /** State fields to publish (default: all) */ fields?: string[]; /** Throttle interval in ms (min time between publishes) */ throttle?: number; /** Publish only on state change */ onChangeOnly?: boolean; /** Auto-connect on attach */ autoConnect?: boolean; /** Serialize as JSON */ serializeJson?: boolean; /** Include timestamp in payload */ includeTimestamp?: boolean; } export interface MQTTSinkState { /** Whether connected to broker */ connected: boolean; /** Total messages published */ publishCount: number; /** Last publish timestamp */ lastPublished: number; /** Connection error if any */ error: string | null; /** MQTT client instance */ client: MQTTClient | null; /** Last published state hash for change detection */ lastStateHash: string | null; } export declare const mqttSinkHandler: TraitHandler; /** * Check if a node has the @mqtt_sink trait */ export declare function hasMQTTSinkTrait(node: HSPlusNode): boolean; /** * Get the MQTT sink state from a node */ export declare function getMQTTSinkState(node: HSPlusNode): MQTTSinkState | null; /** * Get the MQTT client from a node with @mqtt_sink trait */ export declare function getMQTTSinkClient(node: HSPlusNode): MQTTClient | null; /** * Check if MQTT sink is connected */ export declare function isMQTTSinkConnected(node: HSPlusNode): boolean; /** * Manually trigger a publish */ export declare function publishToMQTTSink(node: HSPlusNode, payload?: unknown, topic?: string): Promise; export default mqttSinkHandler; //# sourceMappingURL=MQTTSinkTrait.d.ts.map