Files
homebridge-harmony-control/src/models/harmonyDevice.ts
Brandon Watson e6e3d45b5b
All checks were successful
continuous-integration/drone/push Build is passing
Removing business logic from models. First pass at overrides feature
2021-12-28 20:11:13 -05:00

48 lines
1007 B
TypeScript

import { ICommand } from "./device";
import { sleep } from "../util/sleep";
export interface IHarmonyDeviceProps {
id: string;
name: string;
harmony: any;
log: any;
commands: { [name: string]: ICommand };
}
export class HarmonyDevice {
private _commands: { [name: string]: ICommand } = {};
private _on: boolean;
constructor(props: IHarmonyDeviceProps) {
this.id = props.id;
this.name = props.name;
this._on = false;
this._commands = props.commands;
}
public id: string;
public name: string;
public get on(): boolean {
return this._on;
}
public set on(value: boolean) {
this._on = value;
}
public get commands(): { [name: string]: ICommand } {
return this._commands;
}
//Define device methods
public supportsCommand(commandName: string): boolean {
let command = this._commands[commandName];
return command ? true : false;
}
public getCommand(commandName: string): ICommand {
return this._commands[commandName];
}
}