Added device emit option for debugging purposes
This commit is contained in:
@ -1,14 +1,16 @@
|
||||
import HarmonyDataProvider from "../DataProviders/HarmonyDataProvider";
|
||||
import { IDeviceButton } from "../Models/DeviceButton";
|
||||
import { IDeviceButton } from "../Models/Config/IDeviceButton";
|
||||
import { IAccessory } from "./IAccessory";
|
||||
import { sleep } from "../Util/Sleep";
|
||||
import { ICommand } from "../Models/IDevice";
|
||||
|
||||
let Service: HAPNodeJS.Service;
|
||||
let Characteristic: HAPNodeJS.Characteristic;
|
||||
|
||||
export interface IDeviceButtonProps {
|
||||
dataProvider: HarmonyDataProvider,
|
||||
name: string,
|
||||
buttonName: string,
|
||||
displayName: string,
|
||||
deviceInfo: IDeviceButton,
|
||||
api: any,
|
||||
log: any,
|
||||
@ -28,10 +30,12 @@ export class DeviceButton implements IAccessory {
|
||||
|
||||
private _dataProvider: HarmonyDataProvider;
|
||||
|
||||
private _deviceCommand: string = "";
|
||||
private _deviceCommand?: ICommand;
|
||||
|
||||
private _buttonState: boolean;
|
||||
|
||||
private _buttonName: string;
|
||||
|
||||
|
||||
constructor(props: IDeviceButtonProps) {
|
||||
//Assign class variables
|
||||
@ -39,7 +43,8 @@ export class DeviceButton implements IAccessory {
|
||||
this._api = props.api;
|
||||
Service = props.api.hap.Service;
|
||||
Characteristic = props.api.hap.Characteristic;
|
||||
this.name = props.name;
|
||||
this._buttonName = props.buttonName;
|
||||
this.name = props.displayName;
|
||||
this._homebridge = props.homebridge;
|
||||
|
||||
this._buttonInfo = props.deviceInfo;
|
||||
@ -93,7 +98,10 @@ export class DeviceButton implements IAccessory {
|
||||
|
||||
//Get device command if we don't have it
|
||||
if (!this._deviceCommand) {
|
||||
this._deviceCommand = this._dataProvider.getCommand(this._buttonInfo.ButtonName, this._buttonInfo.DeviceName);
|
||||
let cmd = this._dataProvider.getCommand(this._buttonInfo.ButtonName, this._buttonInfo.DeviceName);
|
||||
if (cmd) {
|
||||
this._deviceCommand = cmd;
|
||||
}
|
||||
}
|
||||
|
||||
//Execute command
|
||||
|
Reference in New Issue
Block a user