@constructorfleet/ultimate-govee
Version:
Library for interacting with Govee devices written in Typescript.
44 lines • 2.62 kB
TypeScript
import { Observer, Subject, Subscription } from 'rxjs';
import { Optional, Ignorable, ForwardBehaviorSubject, FixedLengthStack } from '../../../common';
import { Logger, OnModuleDestroy } from '@nestjs/common';
import { GoveeDeviceCommand, GoveeDeviceStatus } from '../../../data';
import { DeviceModel } from '../devices.model';
import { CommandResult, MessageData, OpCommandIdentifier, ParseOption, StateCommandAndStatus } from './states.types';
export declare const filterCommands: (commands: number[][], type?: Optional<number>, identifier?: Optional<number | number[]>) => number[][];
export declare class DeviceState<StateName extends string, StateValue> implements OnModuleDestroy {
protected readonly device: DeviceModel;
readonly name: StateName;
protected readonly logger: Logger;
protected readonly pendingCommands: Map<string, Partial<Pick<GoveeDeviceStatus, 'state'> & {
op?: {
command: (number | undefined)[][];
};
}>[]>;
protected readonly stateValue: ForwardBehaviorSubject<StateValue>;
readonly commandBus: Subject<Omit<GoveeDeviceCommand, 'deviceId'>>;
protected readonly clearCommand$: Subject<CommandResult>;
readonly clearCommand: import("rxjs").Connectable<CommandResult>;
readonly history: FixedLengthStack<StateValue>;
protected readonly subscriptions: Subscription[];
protected readonly parseOption: ParseOption;
protected readonly stateToCommand?: (state: StateValue) => Optional<StateCommandAndStatus>;
get isCommandable(): boolean;
subscribe(observerOrNext?: Partial<Observer<StateValue>> | ((value: StateValue) => void)): Subscription;
get value(): StateValue;
constructor(device: DeviceModel, name: StateName, initialValue: StateValue, parseOption?: ParseOption);
previousState(last?: number): string[];
parseState(data: unknown): void;
parse(data: MessageData): void;
setState(nextState: StateValue): string[];
onModuleDestroy(): void;
}
export declare class DeviceOpState<StateName extends string, StateValue> extends DeviceState<StateName, StateValue> {
protected readonly opType: Ignorable<Optional<number>>;
readonly identifier: Ignorable<Optional<number[]>>;
constructor({ opType, identifier }: OpCommandIdentifier, device: DeviceModel, name: StateName, initialValue: StateValue, parseOption?: ParseOption);
parseOpCommand(opCommand: number[]): void;
parseMultiOpCommand(opCommands: number[][]): void;
parse(data: MessageData): void;
protected filterOpCommands(opCommands: number[][]): number[][];
}
//# sourceMappingURL=device.state.d.ts.map