lib-comfoair
Version:
Library to communicate with Zehnder ComfoAirQ ventilation unit through the ComfoControl gateway
81 lines (80 loc) • 3.44 kB
TypeScript
import { EventEmitter } from 'events';
import { Logger } from './util/logging/index';
export interface ComfoControlServerInfo {
/**
* IP address of the device
*/
address: string;
/**
* Port of the device
*/
port: number;
/**
* UUID of the device encodes as HEX string
*/
uuid: string;
/**
* Version of the device
*/
version: number;
/**
* MAC address of the device
*/
mac: string;
}
/**
* The discovery operation to find devices on the network. Sends a discovery message to one or more broadcast address
* and listens for responses from devices. Uses UDP sockets to send and receive messages on the default discovery port (56747).
*
* For the discovery process to work, the devices must be on the same network segment as the host running the discovery operation.
* If the network is segmented into multiple subnets, the discovery process will not work unless the router is configured to relay discovery message to other subnets.
* By default routers do not relay broadcast messages between subnets.
*/
export declare class DiscoveryOperation extends EventEmitter implements Promise<ComfoControlServerInfo[]> {
private port;
private logger;
private readonly socket;
private timeoutHandle;
private broadcastHandle;
private discoveryPromise?;
private discoveredDevices;
private broadcastAddresses;
[Symbol.toStringTag]: string;
constructor(broadcastAddresses: string[] | string, port?: number, logger?: Logger);
/**
* Initiates the discovery process to find devices.
* @param timeout - The duration in milliseconds to run the discovery before timing out.
* @param abortSignal - Optional AbortSignal to cancel the discovery.
* @returns The current instance of deviceDiscoveryOperation.
* @throws Error if a discovery operation is already in progress.
*/
discover(options: {
timeout: number;
limit?: number;
}, abortSignal?: AbortSignal): this;
private sendDiscoveryMessages;
private parseDiscoveryResponse;
private onError;
private onAbort;
private stop;
private cleanup;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled - The callback to execute when the Promise is resolved.
* @param onrejected - The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
then<TResult1 = ComfoControlServerInfo[], TResult2 = never>(onfulfilled?: (value: ComfoControlServerInfo[]) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: unknown) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>;
/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected - The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
catch<TResult = never>(onrejected?: (reason: unknown) => TResult | PromiseLike<TResult>): Promise<ComfoControlServerInfo[] | TResult>;
/**
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected).
* @param onfinally - The callback to execute when the Promise is settled.
* @returns A Promise for the completion of the callback.
*/
finally(onfinally?: () => void): Promise<ComfoControlServerInfo[]>;
}