@constructorfleet/ultimate-govee
Version:
Library for interacting with Govee devices written in Typescript.
67 lines • 2.84 kB
TypeScript
import { BehaviorSubject } from 'rxjs';
import { OnModuleDestroy } from '@nestjs/common';
import { Optional } from '../../common';
import { GoveeDeviceStatus } from '../../data';
import { CommandBus, EventBus } from '@nestjs/cqrs';
import { DeviceModel } from './devices.model';
import { DeviceState } from './states/device.state';
import { DeviceStateValues, DeviceStatesType, DeviceType } from './devices.types';
import { Version } from './version.info';
export declare const DefaultFactory: 'default';
export type DeviceImage = {
sku?: string;
on?: string;
off?: string;
};
export type StateFactory<TDevice extends DeviceState<string, unknown>> = (device: DeviceModel) => TDevice;
type ModelStateFactoryValue = StateFactory<DeviceState<string, any>> | StateFactory<DeviceState<string, any>>[];
export type ModelStateFactory = Record<string, ModelStateFactoryValue> | StateFactory<DeviceState<string, any>>;
export type StateFactories = ModelStateFactory[];
export declare class Device<States extends DeviceStatesType = DeviceStatesType> extends BehaviorSubject<Optional<Device<States>>> implements DeviceType<States>, OnModuleDestroy {
readonly device: DeviceModel;
protected readonly eventBus: EventBus;
protected readonly commandBus: CommandBus;
private readonly logger;
static readonly deviceType: string;
get deviceType(): string;
private readonly deviceStates;
private readonly opIdentifiers;
private readonly refresh$;
private readonly subscriptions;
protected isDebug: boolean;
protected addState<TDevice extends DeviceState<string, any>>(state: TDevice): TDevice;
get id(): string;
get model(): string;
get name(): string;
get goodsType(): number;
get pactCode(): number;
get images(): Optional<DeviceImage>;
get pactType(): number;
get iotTopic(): Optional<string>;
get bleAddress(): Optional<string>;
get version(): Version;
get states(): States;
currentStates(): DeviceStateValues<States>;
previousStates(): DeviceStateValues<States>;
state<TState extends DeviceState<string, any> = DeviceState<string, any>>(stateName: string): Optional<TState>;
deviceStatus(status: GoveeDeviceStatus): void;
refresh(): void;
setState(stateName: string, nextState: any): any;
debug(isDebug: boolean): this;
constructor(device: DeviceModel, eventBus: EventBus, commandBus: CommandBus, stateFactories: StateFactories);
loggableState(deviceId: string): {
deviceId: string;
name: string;
model: string;
type: string;
iotTopic: Optional<string>;
bleAddress: Optional<string>;
states: any;
history: any;
};
logState(): void;
closeSubscriptions(): void;
onModuleDestroy(): void;
}
export {};
//# sourceMappingURL=device.d.ts.map