UNPKG

vastra-radiator-valve

Version:

Node.js library to query and configure Vastra's smart radiator valves.

50 lines (49 loc) 1.79 kB
/// <reference types="node" /> import { EventEmitter } from "events"; import { IGattCentral } from "./bluetooth"; import Logger from "./logger"; import RadiatorValve from "./valve"; export type RadiatorValvesOptions = { wakeUpInterval: number; maxConnectionAttempts: number; connectionTimeout: number; maxReadAttempts: number; readTimeout: number; maxWriteAttempts: number; logger?: Logger; verbose?: boolean; /** * Whether to automatically connect to the peripheral once it is * discovered. A `connected` event will be emitted once the connection * is established. If this is disabled, then only the `discovered` event * will be emitted. */ autoConnect?: boolean; /** * Whether to enable notification flag in client configuration descriptor * of the RX characteristic. Some drivers do it automatically, so it's not * always necessary. */ raspberryFix: boolean; }; export declare interface RadiatorValveScanner { emit(event: "connected", valve: RadiatorValve): boolean; emit(event: "discovered", valve: RadiatorValve): boolean; on(event: "connected", listener: (valve: RadiatorValve) => void): this; on(event: "discovered", listener: (valve: RadiatorValve) => void): this; } export declare class RadiatorValveScanner extends EventEmitter { private readonly bluetooth; private readonly options; private connectedValves; private connectQueue; private connecting; private scanning; constructor(bluetooth: IGattCentral, options?: Partial<RadiatorValvesOptions>); disconnectAll(): Promise<void>; findOne(): Promise<RadiatorValve>; start(): Promise<void>; stop(): Promise<void>; private queueConnect; private processConnectQueue; }