Correctly working activities :)

This commit is contained in:
watsonb8
2019-06-16 12:55:19 -04:00
parent a7ae259567
commit 06fb2009bc
3 changed files with 113 additions and 87 deletions

View File

@ -99,7 +99,9 @@ export class ControlUnit implements IAccessory {
.on("get", callbackify(this.onGetActiveIdentifier));
}
//TODO
/**
* Event handler for SET active characteristic
*/
private onSetAccessoryActive = async (value: any) => {
this.log(`set active + ${value}`);
switch (value) {
@ -108,13 +110,14 @@ export class ControlUnit implements IAccessory {
}
}
//TODO
/**
* Event handler for GET active characteristic
*/
private onGetAccessoryActive = async () => {
this.log(`get active`)
//@ts-ignore
return this.dataProvider.getIsActive ? Characteristic.Active.Active : Characteristic.Active.Inactive
// return Characteristic.Active.Active;
}
//TODO
@ -122,13 +125,25 @@ export class ControlUnit implements IAccessory {
this.log(`set remote key + ${key}`);
}
/**
* Event handler for SET active identifier characteristic
*/
private onSetActiveIdentifier = async (identifier: any) => {
this.log(`set active identifier + ${identifier}`);
this.dataProvider.startActivity(this.name, this.activities[identifier]);
}
/**
* Event handler for GET active identifier characteristic
*/
private onGetActiveIdentifier = async () => {
this.log(`get active identifier`);
return 1;
let currentActivity: Activity = this.dataProvider.getIsActive(this.name)!;
let identifier: number = 0;
if (currentActivity) {
identifier = this.activities.findIndex(e => e.displayName === currentActivity.displayName);
}
return identifier;
}
/******************