UNPKG

@ljames8/hormann-hcp-client

Version:

Hormann Communication Protocol v1 garage door serial client

60 lines (59 loc) 2.52 kB
import { EventEmitter } from "node:events"; import { Debugger } from "debug"; import { type HCPClient, SerialHCPClient, type SerialOptions, STATUS_RESPONSE_BYTE0_BITFIELD } from "./serialHCPClient"; import type { PacketFilterParams } from "./parser"; export { MockHCPClient } from "./mockHCPClient"; export { SerialHCPClient }; export type { HCPClient, SerialOptions, PacketFilterParams }; export declare enum CurrentDoorState { OPEN = 0, CLOSED = 1, OPENING = 2, CLOSING = 3, STOPPED = 4, VENTING = 5 } export declare const TargetDoorState: { readonly OPEN: CurrentDoorState.OPEN; readonly CLOSED: CurrentDoorState.CLOSED; readonly VENTING: CurrentDoorState.VENTING; }; export type TargetDoorState = CurrentDoorState.OPEN | CurrentDoorState.CLOSED | CurrentDoorState.VENTING; export interface GarageState { door: CurrentDoorState; light: boolean; } declare abstract class GarageDoorOpener extends EventEmitter { readonly name: string; protected manufacturer: string; protected model: string; protected currentState: CurrentDoorState | null; protected targetState: TargetDoorState | null; protected lightState: boolean | null; constructor(name: string); abstract getCurrentState(): CurrentDoorState; abstract getTargetState(): TargetDoorState; abstract setTargetState(newState: TargetDoorState): Promise<void>; abstract getLightOnState(): boolean; abstract setLightOnState(newState: boolean): Promise<void>; } export declare class HormannGarageDoorOpener extends GarageDoorOpener { hcpClient: HCPClient; logger: Debugger; broadcastStatus: Uint8Array; constructor(name: string | undefined, hcpClient: HCPClient); static targetStateToRequest(targetState: TargetDoorState): { flags: STATUS_RESPONSE_BYTE0_BITFIELD[]; emergencyStop?: boolean; }; static broadcastToCurrentState(status: Uint8Array): GarageState | Error; private onBroadcast; getCurrentState(): CurrentDoorState; getTargetState(): TargetDoorState; setTargetState(newState: TargetDoorState): Promise<void>; getLightOnState(): boolean; setLightOnState(newState: boolean): Promise<void>; } export declare function createHormannGarageDoorOpener( /** factory function to create a serial enabled Hormann garage door opener */ name: string | undefined, { path, ...rest }: SerialOptions, { packetTimeout, filterBreaks, filterMaxLength }?: PacketFilterParams, listenOnly?: boolean): HormannGarageDoorOpener;