@chrispyduck/homie-sensors
Version:
Sensor library intended for ues with homie-device
24 lines • 1.07 kB
TypeScript
/// <reference types="node" />
import { HomieDevice, IHomieNodeConfiguration } from "@chrispyduck/homie-device";
import { EventEmitter } from "events";
export interface ISensorType<TConfig extends ISensorConfiguration, TResult extends Record<never, any>> {
new (config?: TConfig): ISensor<TResult>;
DefaultConfiguration: TConfig;
}
export interface ISensorEvents<TResult> {
"init": () => void;
"read": (result: TResult) => void;
}
export interface ISensor<TResult extends Record<never, any>> extends EventEmitter {
register(device: HomieDevice): void;
read(): Promise<TResult>;
init(): Promise<void>;
on<U extends keyof ISensorEvents<TResult>>(event: U, listener: ISensorEvents<TResult>[U]): this;
emit<U extends keyof ISensorEvents<TResult>>(event: U, ...args: Parameters<ISensorEvents<TResult>[U]>): boolean;
}
export interface ISensorConfiguration {
node: IHomieNodeConfiguration;
type: string;
}
export declare function staticImplements<T>(): <U extends T>(constructor: U) => void;
//# sourceMappingURL=ISensor.d.ts.map