/** * Message Codec for Dyson Protocol * * Encodes commands and decodes state messages for Dyson devices. * Handles conversions between HomeKit values and Dyson protocol format. * All methods are static - no instance state needed. */ import type { DeviceState } from '../devices/types.js'; /** Fan speed limits */ export declare const FAN_SPEED: { readonly MIN: 1; readonly MAX: 10; readonly DEFAULT: 4; readonly AUTO: -1; }; /** Oscillation angle limits */ export declare const OSCILLATION_ANGLE: { readonly MIN: 45; readonly MAX: 355; }; /** Temperature conversion constants */ export declare const TEMPERATURE: { /** Kelvin to Celsius offset */ readonly KELVIN_OFFSET: 273.15; /** Dyson uses Kelvin * 10 for precision */ readonly KELVIN_MULTIPLIER: 10; }; /** Heating temperature limits (Celsius) */ export declare const HEATING_TEMP: { readonly MIN_CELSIUS: 1; readonly MAX_CELSIUS: 37; }; /** Humidity limits for humidifier */ export declare const HUMIDITY: { readonly MIN_PERCENT: 0; readonly MAX_PERCENT: 100; readonly DEFAULT_MIN: 30; readonly DEFAULT_MAX: 70; }; /** Filter life constants */ export declare const FILTER: { /** Maximum filter life in hours */ readonly MAX_HOURS: 4300; /** Percentage divisor for conversion */ readonly PERCENT_DIVISOR: 100; }; /** Protocol string formatting */ export declare const FORMAT: { /** Padding length for numeric values */ readonly PAD_LENGTH: 4; /** Padding character */ readonly PAD_CHAR: "0"; }; /** Dyson protocol values */ export declare const PROTOCOL: { readonly ON: "ON"; readonly OFF: "OFF"; readonly AUTO: "AUTO"; readonly FAN: "FAN"; readonly HEAT: "HEAT"; }; /** HomeKit percentage range */ export declare const PERCENT: { readonly MIN: 0; readonly MAX: 100; /** Conversion factor for speed (10% per speed level) */ readonly PER_SPEED_LEVEL: 10; }; /** * Command data that can be sent to a Dyson device */ export interface CommandData { /** Fan power (ON/OFF) */ fanPower?: boolean; /** Fan speed (1-10, or -1 for AUTO) */ fanSpeed?: number; /** Fan mode (OFF, FAN, AUTO) */ fanMode?: 'OFF' | 'FAN' | 'AUTO'; /** Oscillation enabled */ oscillation?: boolean; /** Oscillation start angle (45-355) */ oscillationAngleStart?: number; /** Oscillation end angle (45-355) */ oscillationAngleEnd?: number; /** Night mode enabled */ nightMode?: boolean; /** Continuous monitoring enabled */ continuousMonitoring?: boolean; /** Jet focus / front airflow enabled */ frontAirflow?: boolean; /** Heating mode enabled (HP models) */ heatingMode?: boolean; /** Target temperature in Celsius (HP models) */ targetTemperature?: number; /** Humidifier enabled (PH models) */ humidifierMode?: boolean; /** Target humidity percentage (PH models) */ targetHumidity?: number; } /** * Raw Dyson protocol state data * Values can be either strings or arrays [oldValue, newValue] for STATE-CHANGE messages */ export interface RawStateData { fpwr?: string | [string, string]; fmod?: string | [string, string]; auto?: string | [string, string]; fnsp?: string | [string, string]; fnst?: string | [string, string]; qtar?: string | [string, string]; oson?: string | [string, string]; oscs?: string | [string, string]; osce?: string | [string, string]; nmod?: string | [string, string]; rhtm?: string | [string, string]; ffoc?: string | [string, string]; hmod?: string | [string, string]; hmax?: string | [string, string]; hsta?: string | [string, string]; hume?: string | [string, string]; humt?: string | [string, string]; tact?: string | [string, string]; hact?: string | [string, string]; p25r?: string | [string, string]; p10r?: string | [string, string]; pact?: string | [string, string]; va10?: string | [string, string]; vact?: string | [string, string]; noxl?: string | [string, string]; hchr?: string | [string, string]; sltm?: string | [string, string]; ercd?: string | [string, string]; wacd?: string | [string, string]; tilt?: string | [string, string]; filf?: string | [string, string]; fltf?: string | [string, string]; cflr?: string | [string, string]; [key: string]: string | [string, string] | undefined; } /** * Dyson protocol message structure */ export interface DysonMessage { msg: string; time?: string; 'mode-reason'?: string; data?: RawStateData; 'product-state'?: RawStateData; } /** * Message codec for encoding commands and decoding state. * All methods are static since the codec is stateless. */ export declare class MessageCodec { /** * Extract value from raw state field * Handles both direct values ("ON") and change arrays (["OFF", "ON"]) */ static extractValue(value: string | [string, string] | undefined): string | undefined; /** * Encode a command to send to the device * * @param data - Command data to encode * @returns JSON string to publish to command topic */ static encodeCommand(data: Partial): string; /** * Decode a state message from the device * * @param payload - Raw message payload (Buffer or object) * @returns Partial device state */ static decodeState(payload: Buffer | DysonMessage): Partial; /** * Parse raw state data into DeviceState * Handles both CURRENT-STATE (direct values) and STATE-CHANGE ([old, new] arrays) */ static parseRawState(raw: RawStateData): Partial; /** * Parse environmental sensor data from raw state */ static parseEnvironmentalData(raw: RawStateData, state: Partial): void; /** * Parse filter status from raw state */ private static parseFilterData; /** * Parse heating data from raw state (HP models) */ private static parseHeatingData; /** * Parse humidifier data from raw state (PH models) */ private static parseHumidifierData; /** * Parse Link series specific fields */ private static parseLinkSeriesData; /** * Encode fan speed (1-10 or -1 for AUTO) to Dyson format */ static encodeFanSpeed(speed: number): string; /** * Decode fan speed from Dyson format */ static decodeFanSpeed(encoded: string): { speed: number; autoMode: boolean; }; /** * Convert HomeKit percentage (0-100) to Dyson speed (1-10) */ static percentToSpeed(percent: number): number; /** * Convert Dyson speed (1-10) to HomeKit percentage (0-100) */ static speedToPercent(speed: number): number; /** * Encode oscillation angle to Dyson format */ static encodeAngle(angle: number): string; /** * Encode temperature from Celsius to Dyson format (Kelvin * 10) */ static encodeTemperature(celsius: number): string; /** * Decode temperature from Dyson format to Celsius */ static decodeTemperature(encoded: string | number): number; /** * Create a REQUEST-CURRENT-STATE message */ static encodeRequestState(): string; } //# sourceMappingURL=messageCodec.d.ts.map