UNPKG

lib-comfoair

Version:

Library to communicate with Zehnder ComfoAirQ ventilation unit through the ComfoControl gateway

66 lines (65 loc) 2.34 kB
import { EventEmitter } from 'node:events'; import { Logger } from './util/logging/index'; import { ComfoControlMessage } from './comfoControlMessage'; import { OpcodeMessageType, opcodes } from './opcodes'; export interface ComfoControlTransportOptions { /** * IP address of the device */ address: string; /** * Port of the device defaults to 56747; see {@link GATEWAY_PORT} constant */ port?: number; /** * UUID of the device encodes as HEX string of exactly 32 characters */ uuid: string; /** * The UUID of the client; defaults to the default client UUID: see {@link CLIENT_UUID} constant */ clientUuid?: string; /** * The interval in milliseconds to send keep-alive messages to the device; defaults to 30000ms */ keepAliveInterval?: number; } /** * The ComfoControlTransport class is responsible for managing the connection to the ComfoControl device on the network. * It sends and receives messages to the device and emits events when messages are received. * Events: * - connect: emitted when the connection to the device is established * - message: emitted when a message is received from the device - the message is a ComfoControlMessage instance * - disconnect: emitted when the connection to the device is closed - the underlying socket is closed * */ export declare class ComfoControlTransport extends EventEmitter<{ connect: []; message: [ComfoControlMessage]; disconnect: []; }> { private readonly options; private readonly logger; private socket; private messageId; private clientUuid; private keepAlive; private state; private keepAliveHandle; get isConnected(): boolean; get isConnecting(): boolean; /** * Create a new device instance with the specified details. * Use the static discover method to find devices on the network if you do not have the details. */ constructor(options: ComfoControlTransportOptions, logger?: Logger); disconnect(): void; connect(): Promise<this>; send<T extends keyof typeof opcodes>(opcode: T, data: OpcodeMessageType<T>): Promise<number>; private prepareMessage; private onSocketData; private onSocketClose; private onSocketError; private onSocketTimeout; sendKeepAlive(): void; }