This commit is contained in:
watsonb8 2019-09-08 13:12:20 -04:00
parent dabdfc56a5
commit b688b365fb
6 changed files with 36 additions and 4006 deletions

View File

@ -1 +1,4 @@
**/HAPNodeJS.d.ts
bin
node_modules

4001
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
{
"name": "homebridge-automation",
"version": "1.0.0",
"description": "Homebridge plugin to expose and cast spotify playlists via the homekit app.",
"description": "Homebridge plugin for supervised home learning.",
"main": "bin/index.js",
"scripts": {
"build": "npx eslint **/*.ts&&tsc",
@ -30,6 +30,7 @@
"bonjour": "^3.5.0",
"decamelize": "^3.2.0",
"inflection": "^1.12.0",
"reflect-metadata": "^0.1.13",
"request": "^2.88.0",
"request-promise-native": "^1.0.7",
"source-map-support": "^0.5.13",

3
src/Services/index.ts Normal file
View File

@ -0,0 +1,3 @@
import Monitor from './monitor';
export { Monitor };

View File

@ -1,5 +1,9 @@
import 'reflect-metadata';
import './Services';
import { log, Homebridge } from './Types/types';
import { EventEmitter } from 'events';
import { container } from 'tsyringe';
import { Monitor } from './Services';
class AutomationPlatform {
private log: log;
@ -12,6 +16,21 @@ class AutomationPlatform {
this.api = api;
this.log('INFO - Registering automation platform');
this.api.on('didFinishLaunching', this.didFinishLaunching.bind(this));
this.main();
}
/**
* Called by homebridge to gather accessories.
* @param callback
*/
accessories = (callback: (accessories: Array<unknown>) => void): void => {
callback([]);
}
private main = (): void => {
//Register the log function for DI
container.register("log", { useValue: this.log });
container.resolve(Monitor);
}
/**

View File

@ -1,19 +1,16 @@
import { HapClient } from "../HapClient";
import { log } from '../Types/types';
import { singleton } from 'tsyringe';
import { singleton, inject } from 'tsyringe';
export interface IMonitorProps {
log: log;
}
@singleton()
export class Monitor {
export default class Monitor {
private log: log;
private api: any;
private client: HapClient;
constructor(props: IMonitorProps) {
this.log = props.log;
constructor(@inject("log") log: log) {
this.log = log;
this.client = new HapClient({
pin: "031-45-154",