Compare commits
	
		
			6 Commits
		
	
	
		
			1.1.1
			...
			feature/wi
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					440a4d62a1 | ||
| 
						 | 
					d73dead5d4 | ||
| 
						 | 
					c3a6882413 | ||
| 
						 | 
					f8320319a4 | ||
| 
						 | 
					779ffac227 | ||
| 
						 | 
					55c65dac84 | 
							
								
								
									
										63
									
								
								.drone.yml
									
									
									
									
									
								
							
							
						
						
									
										63
									
								
								.drone.yml
									
									
									
									
									
								
							@@ -2,6 +2,9 @@ kind: pipeline
 | 
				
			|||||||
type: docker
 | 
					type: docker
 | 
				
			||||||
name: default
 | 
					name: default
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					node:
 | 
				
			||||||
 | 
					  lan: internal
 | 
				
			||||||
 | 
					
 | 
				
			||||||
steps:
 | 
					steps:
 | 
				
			||||||
  - name: build
 | 
					  - name: build
 | 
				
			||||||
    image: node
 | 
					    image: node
 | 
				
			||||||
@@ -25,7 +28,7 @@ steps:
 | 
				
			|||||||
          - master
 | 
					          - master
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  - name: publish pre
 | 
					  - name: publish pre
 | 
				
			||||||
    image: plugins/npm
 | 
					    image: plugins/npm:1.0.0
 | 
				
			||||||
    settings:
 | 
					    settings:
 | 
				
			||||||
      username:
 | 
					      username:
 | 
				
			||||||
        from_secret: npm_username
 | 
					        from_secret: npm_username
 | 
				
			||||||
@@ -43,7 +46,7 @@ steps:
 | 
				
			|||||||
          - master
 | 
					          - master
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  - name: publish tagged version
 | 
					  - name: publish tagged version
 | 
				
			||||||
    image: plugins/npm
 | 
					    image: plugins/npm:1.0.0
 | 
				
			||||||
    settings:
 | 
					    settings:
 | 
				
			||||||
      username:
 | 
					      username:
 | 
				
			||||||
        from_secret: npm_username
 | 
					        from_secret: npm_username
 | 
				
			||||||
@@ -57,6 +60,62 @@ steps:
 | 
				
			|||||||
      exclude:
 | 
					      exclude:
 | 
				
			||||||
        - pull_request
 | 
					        - pull_request
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  - name: remove old package
 | 
				
			||||||
 | 
					    image: appleboy/drone-ssh
 | 
				
			||||||
 | 
					    environment:
 | 
				
			||||||
 | 
					      SSH_USER:
 | 
				
			||||||
 | 
					        from_secret: ssh_user
 | 
				
			||||||
 | 
					    settings:
 | 
				
			||||||
 | 
					      host: homebridge.me
 | 
				
			||||||
 | 
					      envs:
 | 
				
			||||||
 | 
					        - SSH_USER
 | 
				
			||||||
 | 
					      username:
 | 
				
			||||||
 | 
					        from_secret: ssh_user
 | 
				
			||||||
 | 
					      key:
 | 
				
			||||||
 | 
					        from_secret: ssh_key
 | 
				
			||||||
 | 
					      port: 22
 | 
				
			||||||
 | 
					      script:
 | 
				
			||||||
 | 
					        - rm -r /home/$SSH_USER/.npm-global/lib/node_modules/@watsonb8/homebridge-flux
 | 
				
			||||||
 | 
					    when:
 | 
				
			||||||
 | 
					      event:
 | 
				
			||||||
 | 
					        - tag
 | 
				
			||||||
 | 
					      exclude:
 | 
				
			||||||
 | 
					        - pull_request
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  - name: deploy
 | 
				
			||||||
 | 
					    image: appleboy/drone-ssh
 | 
				
			||||||
 | 
					    settings:
 | 
				
			||||||
 | 
					      host: homebridge.me
 | 
				
			||||||
 | 
					      username:
 | 
				
			||||||
 | 
					        from_secret: ssh_user
 | 
				
			||||||
 | 
					      key:
 | 
				
			||||||
 | 
					        from_secret: ssh_key
 | 
				
			||||||
 | 
					      port: 22
 | 
				
			||||||
 | 
					      script:
 | 
				
			||||||
 | 
					        - npm install -g @watsonb8/homebridge-flux --registry http://10.44.1.6:4873
 | 
				
			||||||
 | 
					    when:
 | 
				
			||||||
 | 
					      event:
 | 
				
			||||||
 | 
					        - tag
 | 
				
			||||||
 | 
					      exclude:
 | 
				
			||||||
 | 
					        - pull_request
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  - name: restart homebridge
 | 
				
			||||||
 | 
					    image: appleboy/drone-ssh
 | 
				
			||||||
 | 
					    settings:
 | 
				
			||||||
 | 
					      host: homebridge.me
 | 
				
			||||||
 | 
					      username:
 | 
				
			||||||
 | 
					        from_secret: elevated_ssh_user
 | 
				
			||||||
 | 
					      key:
 | 
				
			||||||
 | 
					        from_secret: ssh_key
 | 
				
			||||||
 | 
					      port: 22
 | 
				
			||||||
 | 
					      script:
 | 
				
			||||||
 | 
					        - systemctl restart homebridge
 | 
				
			||||||
 | 
					    when:
 | 
				
			||||||
 | 
					      event:
 | 
				
			||||||
 | 
					        - tag
 | 
				
			||||||
 | 
					      exclude:
 | 
				
			||||||
 | 
					        - pull_request
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  - name: Notify
 | 
					  - name: Notify
 | 
				
			||||||
    image: drillster/drone-email
 | 
					    image: drillster/drone-email
 | 
				
			||||||
    settings:
 | 
					    settings:
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								.prettierrc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								.prettierrc
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "tabWidth": 4,
 | 
				
			||||||
 | 
					    "useTabs": false
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										10
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							@@ -8,9 +8,13 @@
 | 
				
			|||||||
            "type": "node",
 | 
					            "type": "node",
 | 
				
			||||||
            "request": "launch",
 | 
					            "request": "launch",
 | 
				
			||||||
            "name": "Launch Program",
 | 
					            "name": "Launch Program",
 | 
				
			||||||
            "preLaunchTask": "build and install",
 | 
					            "preLaunchTask": "build",
 | 
				
			||||||
            "program": "/Users/brandonwatson/.npm-global/bin/homebridge",
 | 
					            "program": "/Users/brandonwatson/.nvm/versions/node/v14.15.0/lib/node_modules/homebridge/bin/homebridge",
 | 
				
			||||||
            "sourceMaps": true,
 | 
					            "env": {
 | 
				
			||||||
 | 
					                "HOMEBRIDGE_OPTS": "/Users/brandonwatson/.homebridge",
 | 
				
			||||||
 | 
					                "LOG_LEVEL": "debug"
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            "sourceMaps": true
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
							
								
								
									
										1
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
								
							@@ -6,6 +6,7 @@
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
      "type": "npm",
 | 
					      "type": "npm",
 | 
				
			||||||
      "script": "build",
 | 
					      "script": "build",
 | 
				
			||||||
 | 
					      "label": "build",
 | 
				
			||||||
      "problemMatcher": []
 | 
					      "problemMatcher": []
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2664
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2664
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,6 +1,6 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    "name": "@watsonb8/homebridge-flux",
 | 
					    "name": "@watsonb8/homebridge-flux",
 | 
				
			||||||
    "version": "1.1.1",
 | 
					    "version": "1.1.3",
 | 
				
			||||||
    "description": "",
 | 
					    "description": "",
 | 
				
			||||||
    "main": "bin/index.js",
 | 
					    "main": "bin/index.js",
 | 
				
			||||||
    "publishConfig": {
 | 
					    "publishConfig": {
 | 
				
			||||||
@@ -21,7 +21,7 @@
 | 
				
			|||||||
        "typescript"
 | 
					        "typescript"
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    "engines": {
 | 
					    "engines": {
 | 
				
			||||||
        "homebridge": ">=0.4.21",
 | 
					        "homebridge": ">=1.1.6",
 | 
				
			||||||
        "node": ">=7.6.0"
 | 
					        "node": ">=7.6.0"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "author": "Brandon Watson",
 | 
					    "author": "Brandon Watson",
 | 
				
			||||||
@@ -29,13 +29,14 @@
 | 
				
			|||||||
    "dependencies": {
 | 
					    "dependencies": {
 | 
				
			||||||
        "@types/node-cron": "^2.0.3",
 | 
					        "@types/node-cron": "^2.0.3",
 | 
				
			||||||
        "@types/suncalc": "^1.8.0",
 | 
					        "@types/suncalc": "^1.8.0",
 | 
				
			||||||
 | 
					        "@watsonb8/wiz-lib": "^1.0.1-62427.0",
 | 
				
			||||||
        "node-cron": "^2.0.3",
 | 
					        "node-cron": "^2.0.3",
 | 
				
			||||||
        "node-hue-api": "^4.0.5",
 | 
					        "node-hue-api": "^4.0.5",
 | 
				
			||||||
        "suncalc": "^1.8.0"
 | 
					        "suncalc": "^1.8.0"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "devDependencies": {
 | 
					    "devDependencies": {
 | 
				
			||||||
        "@types/node": "^13.11.1",
 | 
					        "@types/node": "^13.11.1",
 | 
				
			||||||
        "homebridge": "^1.3.9",
 | 
					        "homebridge": "^1.5.0",
 | 
				
			||||||
        "typescript": "^4.5.4"
 | 
					        "typescript": "^4.5.4"
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,3 @@
 | 
				
			|||||||
import { IAccessory } from "./models/iAccessory";
 | 
					 | 
				
			||||||
import Api = require("node-hue-api/lib/api/Api");
 | 
					import Api = require("node-hue-api/lib/api/Api");
 | 
				
			||||||
import Light = require("node-hue-api/lib/model/Light");
 | 
					import Light = require("node-hue-api/lib/model/Light");
 | 
				
			||||||
import LightState = require("node-hue-api/lib/model/lightstate/LightState");
 | 
					import LightState = require("node-hue-api/lib/model/lightstate/LightState");
 | 
				
			||||||
@@ -8,48 +7,46 @@ import { IConfig } from "./models/iConfig";
 | 
				
			|||||||
import { GetTimesResult, getTimes } from "suncalc";
 | 
					import { GetTimesResult, getTimes } from "suncalc";
 | 
				
			||||||
import HueError = require("node-hue-api/lib/HueError");
 | 
					import HueError = require("node-hue-api/lib/HueError");
 | 
				
			||||||
import cron from "node-cron";
 | 
					import cron from "node-cron";
 | 
				
			||||||
import { callbackify } from "util";
 | 
					import { WizBulb } from "@watsonb8/wiz-lib/build/wizBulb";
 | 
				
			||||||
 | 
					import { colorTemperature2rgb, RGB } from "@watsonb8/wiz-lib";
 | 
				
			||||||
 | 
					import { PlatformAccessory } from "homebridge";
 | 
				
			||||||
 | 
					import { Platform } from "./platform";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let Service: HAPNodeJS.Service;
 | 
					 | 
				
			||||||
let Characteristic: HAPNodeJS.Characteristic;
 | 
					 | 
				
			||||||
const SECONDS_IN_DAY = 86400000;
 | 
					const SECONDS_IN_DAY = 86400000;
 | 
				
			||||||
const MINUTES_IN_MILLISECOND = 60000;
 | 
					const MINUTES_IN_MILLISECOND = 60000;
 | 
				
			||||||
const SECONDS_IN_HOUR = 3600;
 | 
					const SECONDS_IN_HOUR = 3600;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IFluxProps {
 | 
					export interface IFluxProps {
 | 
				
			||||||
  api: any;
 | 
					    platform: Platform;
 | 
				
			||||||
  log: any;
 | 
					    accessory: PlatformAccessory;
 | 
				
			||||||
  homebridge: any;
 | 
					 | 
				
			||||||
    hue: Api;
 | 
					    hue: Api;
 | 
				
			||||||
 | 
					    wizBulbs: Array<WizBulb>;
 | 
				
			||||||
    config: IConfig;
 | 
					    config: IConfig;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class FluxAccessory implements IAccessory {
 | 
					export class FluxAccessory {
 | 
				
			||||||
  private _api: any;
 | 
					    private readonly _platform: Platform;
 | 
				
			||||||
  private _homebridge: any;
 | 
					    private readonly _accessory: PlatformAccessory;
 | 
				
			||||||
  private _log: any = {};
 | 
					 | 
				
			||||||
    private _config: IConfig;
 | 
					    private _config: IConfig;
 | 
				
			||||||
    private _isActive: boolean;
 | 
					    private _isActive: boolean;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //Service fields
 | 
					    //Service fields
 | 
				
			||||||
  private _switchService: HAPNodeJS.Service;
 | 
					    private _switchService;
 | 
				
			||||||
  private _infoService: HAPNodeJS.Service;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private _hue: Api;
 | 
					    private _hue: Api;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private _lights: Array<Light> = [];
 | 
					    private _lights: Array<Light> = [];
 | 
				
			||||||
 | 
					    private _wizLights: Array<WizBulb> = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private _times: GetTimesResult;
 | 
					    private _times: GetTimesResult;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    constructor(props: IFluxProps) {
 | 
					    constructor(props: IFluxProps) {
 | 
				
			||||||
        //Assign class variables
 | 
					        //Assign class variables
 | 
				
			||||||
    this._log = props.log;
 | 
					        this._platform = props.platform;
 | 
				
			||||||
    this._api = props.api;
 | 
					        this._accessory = props.accessory;
 | 
				
			||||||
        this._config = props.config;
 | 
					        this._config = props.config;
 | 
				
			||||||
    Service = props.api.hap.Service;
 | 
					 | 
				
			||||||
    Characteristic = props.api.hap.Characteristic;
 | 
					 | 
				
			||||||
    this._homebridge = props.homebridge;
 | 
					 | 
				
			||||||
        this._isActive = false;
 | 
					        this._isActive = false;
 | 
				
			||||||
 | 
					        this._wizLights = props.wizBulbs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this._times = getTimes(
 | 
					        this._times = getTimes(
 | 
				
			||||||
            new Date(),
 | 
					            new Date(),
 | 
				
			||||||
@@ -58,8 +55,7 @@ export class FluxAccessory implements IAccessory {
 | 
				
			|||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //Schedule job to refresh times
 | 
					        //Schedule job to refresh times
 | 
				
			||||||
    cron
 | 
					        cron.schedule(
 | 
				
			||||||
      .schedule(
 | 
					 | 
				
			||||||
            "0 12 * * *",
 | 
					            "0 12 * * *",
 | 
				
			||||||
            () => {
 | 
					            () => {
 | 
				
			||||||
                this._times = getTimes(
 | 
					                this._times = getTimes(
 | 
				
			||||||
@@ -67,41 +63,48 @@ export class FluxAccessory implements IAccessory {
 | 
				
			|||||||
                    this._config.latitude,
 | 
					                    this._config.latitude,
 | 
				
			||||||
                    this._config.longitude
 | 
					                    this._config.longitude
 | 
				
			||||||
                );
 | 
					                );
 | 
				
			||||||
          this._log("Updated sunset times");
 | 
					                this._platform.log.info("Updated sunset times");
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                scheduled: true,
 | 
					                scheduled: true,
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
      )
 | 
					        ).start();
 | 
				
			||||||
      .start();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this._hue = props.hue;
 | 
					        this._hue = props.hue;
 | 
				
			||||||
        this.name = this._config.name;
 | 
					        this.name = this._config.name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.platformAccessory = new this._homebridge.platformAccessory(
 | 
					        this._accessory
 | 
				
			||||||
      this.name,
 | 
					            .getService(this._platform.api.hap.Service.AccessoryInformation)!
 | 
				
			||||||
      this.generateUUID(),
 | 
					            .setCharacteristic(
 | 
				
			||||||
      this._homebridge.hap.Accessory.Categories.SWITCH
 | 
					                this._platform.api.hap.Characteristic.Manufacturer,
 | 
				
			||||||
    );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    //@ts-ignore
 | 
					 | 
				
			||||||
    this._infoService = new Service.AccessoryInformation();
 | 
					 | 
				
			||||||
    this._infoService.setCharacteristic(
 | 
					 | 
				
			||||||
      Characteristic.Manufacturer,
 | 
					 | 
				
			||||||
                "Brandon Watson"
 | 
					                "Brandon Watson"
 | 
				
			||||||
    );
 | 
					            )
 | 
				
			||||||
    this._infoService.setCharacteristic(Characteristic.Model, "F.lux");
 | 
					            .setCharacteristic(
 | 
				
			||||||
    this._infoService.setCharacteristic(
 | 
					                this._platform.api.hap.Characteristic.Model,
 | 
				
			||||||
      Characteristic.SerialNumber,
 | 
					                "F.lux"
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					            .setCharacteristic(
 | 
				
			||||||
 | 
					                this._platform.api.hap.Characteristic.SerialNumber,
 | 
				
			||||||
                "123-456-789"
 | 
					                "123-456-789"
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this._switchService = new Service.Switch(this.name, "fluxService");
 | 
					        const switchUUID = this._platform.api.hap.uuid.generate(
 | 
				
			||||||
 | 
					            `${this._accessory.displayName} Switch`
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this._switchService =
 | 
				
			||||||
 | 
					            this._accessory.getService(this._platform.api.hap.Service.Switch) ||
 | 
				
			||||||
 | 
					            this._accessory.addService(
 | 
				
			||||||
 | 
					                this._platform.api.hap.Service.Switch,
 | 
				
			||||||
 | 
					                this._accessory.displayName,
 | 
				
			||||||
 | 
					                switchUUID
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this._switchService
 | 
					        this._switchService
 | 
				
			||||||
      .getCharacteristic(Characteristic.On)
 | 
					            .getCharacteristic(this._platform.api.hap.Characteristic.On)
 | 
				
			||||||
            //@ts-ignore
 | 
					            //@ts-ignore
 | 
				
			||||||
            .on("set", this.onSetEnabled)
 | 
					            .on("set", this.onSetEnabled)
 | 
				
			||||||
 | 
					            //@ts-ignore
 | 
				
			||||||
            .on("get", this.onGetEnabled);
 | 
					            .on("get", this.onGetEnabled);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -134,19 +137,15 @@ export class FluxAccessory implements IAccessory {
 | 
				
			|||||||
     * Handler for switch get event
 | 
					     * Handler for switch get event
 | 
				
			||||||
     * @param callback The callback function to call when complete
 | 
					     * @param callback The callback function to call when complete
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
  private onGetEnabled = (): boolean => {
 | 
					    private onGetEnabled = (
 | 
				
			||||||
    return this._isActive;
 | 
					        callback: (error: Error | null, value: boolean) => void
 | 
				
			||||||
 | 
					    ): void => {
 | 
				
			||||||
 | 
					        callback(null, this._isActive);
 | 
				
			||||||
 | 
					        // return this._isActive;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
   * Called by homebridge to gather services.
 | 
					     * Populates internal lights array using the configuration values
 | 
				
			||||||
   */
 | 
					 | 
				
			||||||
  public getServices = (): Array<HAPNodeJS.Service> => {
 | 
					 | 
				
			||||||
    return [this._infoService, this._switchService!];
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /**
 | 
					 | 
				
			||||||
   * Popuplates internal lights array using the configuration values
 | 
					 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private getLights = async (): Promise<void> => {
 | 
					    private getLights = async (): Promise<void> => {
 | 
				
			||||||
        for (const value of this._config.lights) {
 | 
					        for (const value of this._config.lights) {
 | 
				
			||||||
@@ -156,9 +155,7 @@ export class FluxAccessory implements IAccessory {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private colorTempToRgb = (
 | 
					    private colorTempToRgb = (kelvin: number): RGB => {
 | 
				
			||||||
    kelvin: number
 | 
					 | 
				
			||||||
  ): { red: number; green: number; blue: number } => {
 | 
					 | 
				
			||||||
        var temp = kelvin / 100;
 | 
					        var temp = kelvin / 100;
 | 
				
			||||||
        var red, green, blue;
 | 
					        var red, green, blue;
 | 
				
			||||||
        if (temp <= 66) {
 | 
					        if (temp <= 66) {
 | 
				
			||||||
@@ -182,9 +179,9 @@ export class FluxAccessory implements IAccessory {
 | 
				
			|||||||
            blue = 255;
 | 
					            blue = 255;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return {
 | 
					        return {
 | 
				
			||||||
      red: this.clamp(red, 0, 255),
 | 
					            r: this.clamp(red, 0, 255),
 | 
				
			||||||
      green: this.clamp(green, 0, 255),
 | 
					            g: this.clamp(green, 0, 255),
 | 
				
			||||||
      blue: this.clamp(blue, 0, 255),
 | 
					            b: this.clamp(blue, 0, 255),
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -202,7 +199,7 @@ export class FluxAccessory implements IAccessory {
 | 
				
			|||||||
        return "_hueError" in object;
 | 
					        return "_hueError" in object;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private setLights = async (state: LightState) => {
 | 
					    private setHueLights = async (state: LightState) => {
 | 
				
			||||||
        const promises: Array<Promise<unknown> | PromiseLike<unknown>> = [];
 | 
					        const promises: Array<Promise<unknown> | PromiseLike<unknown>> = [];
 | 
				
			||||||
        this._lights.map(async (light: Light) => {
 | 
					        this._lights.map(async (light: Light) => {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
@@ -215,7 +212,9 @@ export class FluxAccessory implements IAccessory {
 | 
				
			|||||||
                ) {
 | 
					                ) {
 | 
				
			||||||
                    //Eat this
 | 
					                    //Eat this
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
          this._log(`Error while setting lights: ${err}`);
 | 
					                    this._platform.log.info(
 | 
				
			||||||
 | 
					                        `Error while setting lights: ${err}`
 | 
				
			||||||
 | 
					                    );
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
@@ -223,6 +222,16 @@ export class FluxAccessory implements IAccessory {
 | 
				
			|||||||
        await Promise.all(promises);
 | 
					        await Promise.all(promises);
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private setWizLights = async (rgb: RGB, fade: number): Promise<void> => {
 | 
				
			||||||
 | 
					        await Promise.all(
 | 
				
			||||||
 | 
					            this._wizLights.map(async (bulb) => {
 | 
				
			||||||
 | 
					                const pilot = await bulb.get();
 | 
				
			||||||
 | 
					                bulb.set(rgb, pilot?.dimming, fade);
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Helper function to generate a UUID
 | 
					     * Helper function to generate a UUID
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
@@ -256,7 +265,8 @@ export class FluxAccessory implements IAccessory {
 | 
				
			|||||||
    ) => {
 | 
					    ) => {
 | 
				
			||||||
        const now = this.getNow().getTime();
 | 
					        const now = this.getNow().getTime();
 | 
				
			||||||
        const percentComplete =
 | 
					        const percentComplete =
 | 
				
			||||||
      (now - startTime.getTime()) / (endTime.getTime() - startTime.getTime());
 | 
					            (now - startTime.getTime()) /
 | 
				
			||||||
 | 
					            (endTime.getTime() - startTime.getTime());
 | 
				
			||||||
        const tempRange = Math.abs(startTemp - endTemp);
 | 
					        const tempRange = Math.abs(startTemp - endTemp);
 | 
				
			||||||
        const tempOffset = tempRange * percentComplete;
 | 
					        const tempOffset = tempRange * percentComplete;
 | 
				
			||||||
        return startTemp - tempOffset;
 | 
					        return startTemp - tempOffset;
 | 
				
			||||||
@@ -329,20 +339,25 @@ export class FluxAccessory implements IAccessory {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //Set lights
 | 
					            //Set lights
 | 
				
			||||||
      const rgb = this.colorTempToRgb(newTemp);
 | 
					            const hueRGB = this.colorTempToRgb(newTemp);
 | 
				
			||||||
      if (rgb && newTemp !== 0) {
 | 
					            const wizRGB = colorTemperature2rgb(newTemp);
 | 
				
			||||||
 | 
					            if (hueRGB && newTemp !== 0) {
 | 
				
			||||||
                const lightState = new LightState();
 | 
					                const lightState = new LightState();
 | 
				
			||||||
                lightState
 | 
					                lightState
 | 
				
			||||||
                    .transitionInMillis(
 | 
					                    .transitionInMillis(
 | 
				
			||||||
                        this._config.transition ? this._config.transition : 5000
 | 
					                        this._config.transition ? this._config.transition : 5000
 | 
				
			||||||
                    )
 | 
					                    )
 | 
				
			||||||
          .rgb(
 | 
					                    .rgb(hueRGB.r ?? 0, hueRGB.g ?? 0, hueRGB.b ?? 0);
 | 
				
			||||||
            rgb.red ? rgb.red : 0,
 | 
					                await this.setHueLights(lightState);
 | 
				
			||||||
            rgb.green ? rgb.green : 0,
 | 
					                await this.setWizLights(
 | 
				
			||||||
            rgb.blue ? rgb.blue : 0
 | 
					                    wizRGB,
 | 
				
			||||||
 | 
					                    this._config.transition ? this._config.transition / 1000 : 5
 | 
				
			||||||
 | 
					                );
 | 
				
			||||||
 | 
					                this._platform.log.info(
 | 
				
			||||||
 | 
					                    `Adjusting light temp to ${newTemp}, ${JSON.stringify(
 | 
				
			||||||
 | 
					                        hueRGB
 | 
				
			||||||
 | 
					                    )}`
 | 
				
			||||||
                );
 | 
					                );
 | 
				
			||||||
        await this.setLights(lightState);
 | 
					 | 
				
			||||||
        this._log(`Adjusting light temp to ${newTemp}, ${JSON.stringify(rgb)}`);
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            await Sleep(this._config.delay ? this._config.delay : 60000);
 | 
					            await Sleep(this._config.delay ? this._config.delay : 60000);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										217
									
								
								src/index.ts
									
									
									
									
									
								
							
							
						
						
									
										217
									
								
								src/index.ts
									
									
									
									
									
								
							@@ -1,105 +1,146 @@
 | 
				
			|||||||
import { IConfig } from "./models/iConfig";
 | 
					import { API } from "homebridge";
 | 
				
			||||||
import { v3 } from 'node-hue-api';
 | 
					 | 
				
			||||||
import LocalBootstrap = require("node-hue-api/lib/api/http/LocalBootstrap");
 | 
					 | 
				
			||||||
import Api = require("node-hue-api/lib/api/Api");
 | 
					 | 
				
			||||||
import { Sleep } from "./sleep";
 | 
					 | 
				
			||||||
import { IAccessory } from "./models/iAccessory";
 | 
					 | 
				
			||||||
import { FluxAccessory } from "./fluxAccessory";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
let Accessory: any;
 | 
					import { PLATFORM_NAME } from "./settings";
 | 
				
			||||||
let Homebridge: any;
 | 
					import { Platform } from "./platform";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Main entry.
 | 
					 * This method registers the platform with Homebridge
 | 
				
			||||||
 * @param homebridge 
 | 
					 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export default function (homebridge: any) {
 | 
					export = (api: API) => {
 | 
				
			||||||
    Homebridge = homebridge;
 | 
					    api.registerPlatform(PLATFORM_NAME, Platform);
 | 
				
			||||||
    Accessory = homebridge.platformAccessory;
 | 
					 | 
				
			||||||
    homebridge.registerPlatform(
 | 
					 | 
				
			||||||
        'homebridge-flux',
 | 
					 | 
				
			||||||
        'Flux',
 | 
					 | 
				
			||||||
        FluxPlatform,
 | 
					 | 
				
			||||||
        true
 | 
					 | 
				
			||||||
    );
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class FluxPlatform {
 | 
					// import { IConfig } from "./models/iConfig";
 | 
				
			||||||
    log: any = {};
 | 
					// import { v3 } from "node-hue-api";
 | 
				
			||||||
    api: any;
 | 
					// import LocalBootstrap = require("node-hue-api/lib/api/http/LocalBootstrap");
 | 
				
			||||||
    accessoryList: Array<IAccessory> = [];
 | 
					// import Api = require("node-hue-api/lib/api/Api");
 | 
				
			||||||
    config: IConfig;
 | 
					// import { Sleep } from "./sleep";
 | 
				
			||||||
    hue: Api | undefined;
 | 
					// import { IAccessory } from "./models/iAccessory";
 | 
				
			||||||
 | 
					// import { FluxAccessory } from "./fluxAccessory";
 | 
				
			||||||
 | 
					// import { WizBulb } from "@watsonb8/wiz-lib/build/wizBulb";
 | 
				
			||||||
 | 
					// import discover from "@watsonb8/wiz-lib/build/discovery";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// let Accessory: any;
 | 
				
			||||||
 | 
					// let Homebridge: any;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    constructor(log: any, config: any, api: any) {
 | 
					// /**
 | 
				
			||||||
        this.log = log;
 | 
					//  * Main entry.
 | 
				
			||||||
        this.api = api;
 | 
					//  * @param homebridge
 | 
				
			||||||
        this.config = config;
 | 
					//  */
 | 
				
			||||||
        this.log('INFO - Registering Flux platform');
 | 
					// export default function (homebridge: any) {
 | 
				
			||||||
        this.api.on('didFinishLaunching', this.didFinishLaunching.bind(this));
 | 
					//     Homebridge = homebridge;
 | 
				
			||||||
    }
 | 
					//     Accessory = homebridge.platformAccessory;
 | 
				
			||||||
 | 
					//     homebridge.registerPlatform("homebridge-flux", "Flux", FluxPlatform, true);
 | 
				
			||||||
 | 
					// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private connectHue = async () => {
 | 
					// class FluxPlatform {
 | 
				
			||||||
        if (!this.config) {
 | 
					//     log: any = {};
 | 
				
			||||||
            return;
 | 
					//     api: any;
 | 
				
			||||||
        }
 | 
					//     accessoryList: Array<IAccessory> = [];
 | 
				
			||||||
 | 
					//     config: IConfig;
 | 
				
			||||||
 | 
					//     hue: Api | undefined;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (this.config.userName && this.config.clientKey) {
 | 
					//     constructor(log: any, config: any, api: any) {
 | 
				
			||||||
            this.hue = await v3.api.createLocal(this.config.ipAddress).connect(this.config.userName, this.config.clientKey, undefined);
 | 
					//         this.log = log;
 | 
				
			||||||
            this.log("Using existing connection info");
 | 
					//         this.api = api;
 | 
				
			||||||
        } else {
 | 
					//         this.config = config;
 | 
				
			||||||
            const unauthenticatedApi = await v3.api.createLocal(this.config.ipAddress).connect(undefined, undefined, undefined);
 | 
					//         this.log("INFO - Registering Flux platform");
 | 
				
			||||||
            let createdUser;
 | 
					//         this.api.on("didFinishLaunching", this.didFinishLaunching.bind(this));
 | 
				
			||||||
            let connected = false
 | 
					//     }
 | 
				
			||||||
            while (!connected) {
 | 
					 | 
				
			||||||
                try {
 | 
					 | 
				
			||||||
                    this.log("Creating hue user. Push link button")
 | 
					 | 
				
			||||||
                    createdUser = await unauthenticatedApi.users.createUser("homebridge", "HueChase");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    this.hue = await v3.api.createLocal(this.config.ipAddress).connect(createdUser.username, createdUser.clientKey, undefined);
 | 
					//     private connectWiz = async () => {
 | 
				
			||||||
                    this.log("Connected to Hue Bridge");
 | 
					//         if (!this.config) {
 | 
				
			||||||
                    this.log(`UserName: ${createdUser.username}, ClientKey: ${createdUser.clientkey}`)
 | 
					//             return;
 | 
				
			||||||
                    connected = true;
 | 
					//         }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                } catch (err: any) {
 | 
					//         return await discover();
 | 
				
			||||||
                    if (err.getHueErrorType() === 101) {
 | 
					//     };
 | 
				
			||||||
                        this.log('The Link button on the bridge was not pressed. Please press the Link button and try again.');
 | 
					 | 
				
			||||||
                        Sleep(5000);
 | 
					 | 
				
			||||||
                    } else {
 | 
					 | 
				
			||||||
                        this.log(`Unexpected Error: ${err.message}`);
 | 
					 | 
				
			||||||
                        break;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                }
 | 
					//     private connectHue = async () => {
 | 
				
			||||||
            }
 | 
					//         if (!this.config) {
 | 
				
			||||||
        }
 | 
					//             return;
 | 
				
			||||||
    }
 | 
					//         }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					//         if (this.config.userName && this.config.clientKey) {
 | 
				
			||||||
     * Handler for didFinishLaunching
 | 
					//             this.hue = await v3.api
 | 
				
			||||||
     * Happens after constructor
 | 
					//                 .createLocal(this.config.ipAddress)
 | 
				
			||||||
     */
 | 
					//                 .connect(
 | 
				
			||||||
    private didFinishLaunching() {
 | 
					//                     this.config.userName,
 | 
				
			||||||
        this.log(`INFO - Done registering Flux platform`);
 | 
					//                     this.config.clientKey,
 | 
				
			||||||
    }
 | 
					//                     undefined
 | 
				
			||||||
 | 
					//                 );
 | 
				
			||||||
 | 
					//             this.log("Using existing connection info");
 | 
				
			||||||
 | 
					//         } else {
 | 
				
			||||||
 | 
					//             const unauthenticatedApi = await v3.api
 | 
				
			||||||
 | 
					//                 .createLocal(this.config.ipAddress)
 | 
				
			||||||
 | 
					//                 .connect(undefined, undefined, undefined);
 | 
				
			||||||
 | 
					//             let createdUser;
 | 
				
			||||||
 | 
					//             let connected = false;
 | 
				
			||||||
 | 
					//             while (!connected) {
 | 
				
			||||||
 | 
					//                 try {
 | 
				
			||||||
 | 
					//                     this.log("Creating hue user. Push link button");
 | 
				
			||||||
 | 
					//                     createdUser = await unauthenticatedApi.users.createUser(
 | 
				
			||||||
 | 
					//                         "homebridge",
 | 
				
			||||||
 | 
					//                         "HueChase"
 | 
				
			||||||
 | 
					//                     );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					//                     this.hue = await v3.api
 | 
				
			||||||
     * Called by homebridge to gather accessories.
 | 
					//                         .createLocal(this.config.ipAddress)
 | 
				
			||||||
     * @param callback 
 | 
					//                         .connect(
 | 
				
			||||||
     */
 | 
					//                             createdUser.username,
 | 
				
			||||||
    public accessories = async (callback: (accessories: Array<IAccessory>) => void) => {
 | 
					//                             createdUser.clientKey,
 | 
				
			||||||
        //Connect to hue bridge
 | 
					//                             undefined
 | 
				
			||||||
        await this.connectHue();
 | 
					//                         );
 | 
				
			||||||
 | 
					//                     this.log("Connected to Hue Bridge");
 | 
				
			||||||
 | 
					//                     this.log(
 | 
				
			||||||
 | 
					//                         `UserName: ${createdUser.username}, ClientKey: ${createdUser.clientkey}`
 | 
				
			||||||
 | 
					//                     );
 | 
				
			||||||
 | 
					//                     connected = true;
 | 
				
			||||||
 | 
					//                 } catch (err: any) {
 | 
				
			||||||
 | 
					//                     if (err.getHueErrorType() === 101) {
 | 
				
			||||||
 | 
					//                         this.log(
 | 
				
			||||||
 | 
					//                             "The Link button on the bridge was not pressed. Please press the Link button and try again."
 | 
				
			||||||
 | 
					//                         );
 | 
				
			||||||
 | 
					//                         Sleep(5000);
 | 
				
			||||||
 | 
					//                     } else {
 | 
				
			||||||
 | 
					//                         this.log(`Unexpected Error: ${err.message}`);
 | 
				
			||||||
 | 
					//                         break;
 | 
				
			||||||
 | 
					//                     }
 | 
				
			||||||
 | 
					//                 }
 | 
				
			||||||
 | 
					//             }
 | 
				
			||||||
 | 
					//         }
 | 
				
			||||||
 | 
					//     };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.accessoryList.push(new FluxAccessory({
 | 
					//     /**
 | 
				
			||||||
            api: this.api,
 | 
					//      * Handler for didFinishLaunching
 | 
				
			||||||
            log: this.log,
 | 
					//      * Happens after constructor
 | 
				
			||||||
            homebridge: Homebridge,
 | 
					//      */
 | 
				
			||||||
            hue: this.hue!,
 | 
					//     private didFinishLaunching() {
 | 
				
			||||||
            config: this.config
 | 
					//         this.log(`INFO - Done registering Flux platform`);
 | 
				
			||||||
        }));
 | 
					//     }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        callback(this.accessoryList);
 | 
					//     /**
 | 
				
			||||||
    }
 | 
					//      * Called by homebridge to gather accessories.
 | 
				
			||||||
}
 | 
					//      * @param callback
 | 
				
			||||||
 | 
					//      */
 | 
				
			||||||
 | 
					//     public accessories = async (
 | 
				
			||||||
 | 
					//         callback: (accessories: Array<IAccessory>) => void
 | 
				
			||||||
 | 
					//     ) => {
 | 
				
			||||||
 | 
					//         //Connect to hue bridge
 | 
				
			||||||
 | 
					//         await this.connectHue();
 | 
				
			||||||
 | 
					//         const wizBulbs = await this.connectWiz();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//         this.accessoryList.push(
 | 
				
			||||||
 | 
					//             new FluxAccessory({
 | 
				
			||||||
 | 
					//                 api: this.api,
 | 
				
			||||||
 | 
					//                 log: this.log,
 | 
				
			||||||
 | 
					//                 homebridge: Homebridge,
 | 
				
			||||||
 | 
					//                 hue: this.hue!,
 | 
				
			||||||
 | 
					//                 wizBulbs: wizBulbs ?? [],
 | 
				
			||||||
 | 
					//                 config: this.config,
 | 
				
			||||||
 | 
					//             })
 | 
				
			||||||
 | 
					//         );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//         callback(this.accessoryList);
 | 
				
			||||||
 | 
					//     };
 | 
				
			||||||
 | 
					// }
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										456
									
								
								src/models/hapNodeJS.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										456
									
								
								src/models/hapNodeJS.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -1,456 +0,0 @@
 | 
				
			|||||||
declare namespace HAPNodeJS {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    export interface uuid {
 | 
					 | 
				
			||||||
        generate(data: string): string;
 | 
					 | 
				
			||||||
        isValid(UUID: string): boolean;
 | 
					 | 
				
			||||||
        unparse(bug: string, offset: number): string;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    type EventService = "characteristic-change" | "service-configurationChange"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    export interface IEventEmitterAccessory {
 | 
					 | 
				
			||||||
        addListener(event: EventService, listener: Function): this;
 | 
					 | 
				
			||||||
        on(event: EventService, listener: Function): this;
 | 
					 | 
				
			||||||
        once(event: EventService, listener: Function): this;
 | 
					 | 
				
			||||||
        removeListener(event: EventService, listener: Function): this;
 | 
					 | 
				
			||||||
        removeAllListeners(event?: EventService): this;
 | 
					 | 
				
			||||||
        setMaxListeners(n: number): this;
 | 
					 | 
				
			||||||
        getMaxListeners(): number;
 | 
					 | 
				
			||||||
        listeners(event: EventService): Function[];
 | 
					 | 
				
			||||||
        emit(event: EventService, ...args: any[]): boolean;
 | 
					 | 
				
			||||||
        listenerCount(type: string): number;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    export interface Service extends IEventEmitterAccessory {
 | 
					 | 
				
			||||||
        new(displayName: string, UUID: string, subtype: string): Service;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        displayName: string;
 | 
					 | 
				
			||||||
        UUID: string;
 | 
					 | 
				
			||||||
        subtype: string;
 | 
					 | 
				
			||||||
        iid: string;
 | 
					 | 
				
			||||||
        characteristics: Characteristic[];
 | 
					 | 
				
			||||||
        optionalCharacteristics: Characteristic[];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        addCharacteristic(characteristic: Characteristic | Function): Characteristic;
 | 
					 | 
				
			||||||
        removeCharacteristic(characteristic: Characteristic): void;
 | 
					 | 
				
			||||||
        getCharacteristic(name: string | Function): Characteristic;
 | 
					 | 
				
			||||||
        testCharacteristic(name: string | Function): boolean;
 | 
					 | 
				
			||||||
        setCharacteristic(name: string | Function, value: CharacteristicValue): Service;
 | 
					 | 
				
			||||||
        updateCharacteristic(name: string | Function, value: CharacteristicValue): Service;
 | 
					 | 
				
			||||||
        addOptionalCharacteristic(characteristic: Characteristic | Function): void;
 | 
					 | 
				
			||||||
        getCharacteristicByIID(iid: string): Characteristic;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        toHAP(opt: any): JSON;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        AccessoryInformation: PredefinedService;
 | 
					 | 
				
			||||||
        AirPurifier: PredefinedService;
 | 
					 | 
				
			||||||
        AirQualitySensor: PredefinedService;
 | 
					 | 
				
			||||||
        BatteryService: PredefinedService;
 | 
					 | 
				
			||||||
        BridgeConfiguration: PredefinedService;
 | 
					 | 
				
			||||||
        BridgingState: PredefinedService;
 | 
					 | 
				
			||||||
        CameraControl: PredefinedService;
 | 
					 | 
				
			||||||
        CameraRTPStreamManagement: PredefinedService;
 | 
					 | 
				
			||||||
        CarbonDioxideSensor: PredefinedService;
 | 
					 | 
				
			||||||
        CarbonMonoxideSensor: PredefinedService;
 | 
					 | 
				
			||||||
        ContactSensor: PredefinedService;
 | 
					 | 
				
			||||||
        Door: PredefinedService;
 | 
					 | 
				
			||||||
        Doorbell: PredefinedService;
 | 
					 | 
				
			||||||
        Fan: PredefinedService;
 | 
					 | 
				
			||||||
        Fanv2: PredefinedService;
 | 
					 | 
				
			||||||
        Faucet: PredefinedService;
 | 
					 | 
				
			||||||
        FilterMaintenance: PredefinedService;
 | 
					 | 
				
			||||||
        GarageDoorOpener: PredefinedService;
 | 
					 | 
				
			||||||
        HeaterCooler: PredefinedService;
 | 
					 | 
				
			||||||
        HumidifierDehumidifier: PredefinedService;
 | 
					 | 
				
			||||||
        HumiditySensor: PredefinedService;
 | 
					 | 
				
			||||||
        InputSource: PredefinedService;
 | 
					 | 
				
			||||||
        IrrigationSystem: PredefinedService;
 | 
					 | 
				
			||||||
        LeakSensor: PredefinedService;
 | 
					 | 
				
			||||||
        LightSensor: PredefinedService;
 | 
					 | 
				
			||||||
        Lightbulb: PredefinedService;
 | 
					 | 
				
			||||||
        LockManagement: PredefinedService;
 | 
					 | 
				
			||||||
        LockMechanism: PredefinedService;
 | 
					 | 
				
			||||||
        Microphone: PredefinedService;
 | 
					 | 
				
			||||||
        MotionSensor: PredefinedService;
 | 
					 | 
				
			||||||
        OccupancySensor: PredefinedService;
 | 
					 | 
				
			||||||
        Outlet: PredefinedService;
 | 
					 | 
				
			||||||
        Pairing: PredefinedService;
 | 
					 | 
				
			||||||
        ProtocolInformation: PredefinedService;
 | 
					 | 
				
			||||||
        Relay: PredefinedService;
 | 
					 | 
				
			||||||
        SecuritySystem: PredefinedService;
 | 
					 | 
				
			||||||
        ServiceLabel: PredefinedService;
 | 
					 | 
				
			||||||
        Slat: PredefinedService;
 | 
					 | 
				
			||||||
        SmokeSensor: PredefinedService;
 | 
					 | 
				
			||||||
        Speaker: PredefinedService;
 | 
					 | 
				
			||||||
        StatefulProgrammableSwitch: PredefinedService;
 | 
					 | 
				
			||||||
        StatelessProgrammableSwitch: PredefinedService;
 | 
					 | 
				
			||||||
        Switch: PredefinedService;
 | 
					 | 
				
			||||||
        Television: PredefinedService;
 | 
					 | 
				
			||||||
        TelevisionSpeaker: PredefinedService;
 | 
					 | 
				
			||||||
        TemperatureSensor: PredefinedService;
 | 
					 | 
				
			||||||
        Thermostat: PredefinedService;
 | 
					 | 
				
			||||||
        TimeInformation: PredefinedService;
 | 
					 | 
				
			||||||
        TunneledBTLEAccessoryService: PredefinedService;
 | 
					 | 
				
			||||||
        Valve: PredefinedService;
 | 
					 | 
				
			||||||
        Window: PredefinedService;
 | 
					 | 
				
			||||||
        WindowCovering: PredefinedService;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    export interface PredefinedService {
 | 
					 | 
				
			||||||
        new(displayName: string, subtype: string): Service;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    export interface CameraSource {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    type EventAccessory = "service-configurationChange" | "service-characteristic-change" | "identify"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    export interface IEventEmitterAccessory {
 | 
					 | 
				
			||||||
        addListener(event: EventAccessory, listener: Function): this;
 | 
					 | 
				
			||||||
        on(event: EventAccessory, listener: Function): this;
 | 
					 | 
				
			||||||
        once(event: EventAccessory, listener: Function): this;
 | 
					 | 
				
			||||||
        removeListener(event: EventAccessory, listener: Function): this;
 | 
					 | 
				
			||||||
        removeAllListeners(event?: EventAccessory): this;
 | 
					 | 
				
			||||||
        setMaxListeners(n: number): this;
 | 
					 | 
				
			||||||
        getMaxListeners(): number;
 | 
					 | 
				
			||||||
        listeners(event: EventAccessory): Function[];
 | 
					 | 
				
			||||||
        emit(event: EventAccessory, ...args: any[]): boolean;
 | 
					 | 
				
			||||||
        listenerCount(type: string): number;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    export interface CharacteristicProps {
 | 
					 | 
				
			||||||
        format: Characteristic.Formats;
 | 
					 | 
				
			||||||
        unit: Characteristic.Units,
 | 
					 | 
				
			||||||
        minValue: number,
 | 
					 | 
				
			||||||
        maxValue: number,
 | 
					 | 
				
			||||||
        minStep: number,
 | 
					 | 
				
			||||||
        perms: Characteristic.Perms[]
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    type EventCharacteristic = "get" | "set"
 | 
					 | 
				
			||||||
    type CharacteristicValue = boolean | string | number
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    export type CharacteristicGetCallback<T = CharacteristicValue> = (error: Error | null, value: T) => void
 | 
					 | 
				
			||||||
    export type CharacteristicSetCallback = (error?: Error | null) => void
 | 
					 | 
				
			||||||
    export type CharacteristicCallback = CharacteristicGetCallback | CharacteristicSetCallback
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    export interface IEventEmitterCharacteristic {
 | 
					 | 
				
			||||||
        addListener(event: EventCharacteristic, listener: CharacteristicCallback): this;
 | 
					 | 
				
			||||||
        on(event: EventCharacteristic, listener: CharacteristicCallback): this;
 | 
					 | 
				
			||||||
        once(event: EventCharacteristic, listener: CharacteristicCallback): this;
 | 
					 | 
				
			||||||
        removeListener(event: EventCharacteristic, listener: CharacteristicCallback): this;
 | 
					 | 
				
			||||||
        removeAllListeners(event?: EventCharacteristic): this;
 | 
					 | 
				
			||||||
        setMaxListeners(n: number): this;
 | 
					 | 
				
			||||||
        getMaxListeners(): number;
 | 
					 | 
				
			||||||
        listeners(event: EventCharacteristic): CharacteristicCallback[];
 | 
					 | 
				
			||||||
        emit(event: EventCharacteristic, ...args: any[]): boolean;
 | 
					 | 
				
			||||||
        listenerCount(type: string): number;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    export interface Characteristic extends IEventEmitterCharacteristic {
 | 
					 | 
				
			||||||
        new(displayName: string, UUID: string, props?: CharacteristicProps): Characteristic;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Formats: typeof Characteristic.Formats;
 | 
					 | 
				
			||||||
        Units: typeof Characteristic.Units;
 | 
					 | 
				
			||||||
        Perms: typeof Characteristic.Perms;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        setProps(props: CharacteristicProps): Characteristic
 | 
					 | 
				
			||||||
        getValue(callback?: CharacteristicGetCallback, context?: any, connectionID?: string): void;
 | 
					 | 
				
			||||||
        setValue(newValue: CharacteristicValue, callback?: CharacteristicSetCallback, context?: any, connectionID?: string): Characteristic;
 | 
					 | 
				
			||||||
        updateValue(newValue: CharacteristicValue, callback?: () => void, context?: any): Characteristic;
 | 
					 | 
				
			||||||
        getDefaultValue(): CharacteristicValue;
 | 
					 | 
				
			||||||
        toHAP(opt: any): JSON;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        AccessoryFlags: Characteristic;
 | 
					 | 
				
			||||||
        AccessoryIdentifier: Characteristic;
 | 
					 | 
				
			||||||
        Active: Characteristic;
 | 
					 | 
				
			||||||
        ActiveIdentifier: Characteristic;
 | 
					 | 
				
			||||||
        AdministratorOnlyAccess: Characteristic;
 | 
					 | 
				
			||||||
        AirParticulateDensity: Characteristic;
 | 
					 | 
				
			||||||
        AirParticulateSize: Characteristic;
 | 
					 | 
				
			||||||
        AirQuality: Characteristic;
 | 
					 | 
				
			||||||
        AppMatchingIdentifier: Characteristic;
 | 
					 | 
				
			||||||
        AudioFeedback: Characteristic;
 | 
					 | 
				
			||||||
        BatteryLevel: Characteristic;
 | 
					 | 
				
			||||||
        Brightness: Characteristic;
 | 
					 | 
				
			||||||
        CarbonDioxideDetected: Characteristic;
 | 
					 | 
				
			||||||
        CarbonDioxideLevel: Characteristic;
 | 
					 | 
				
			||||||
        CarbonDioxidePeakLevel: Characteristic;
 | 
					 | 
				
			||||||
        CarbonMonoxideDetected: Characteristic;
 | 
					 | 
				
			||||||
        CarbonMonoxideLevel: Characteristic;
 | 
					 | 
				
			||||||
        CarbonMonoxidePeakLevel: Characteristic;
 | 
					 | 
				
			||||||
        Category: Characteristic;
 | 
					 | 
				
			||||||
        ChargingState: Characteristic;
 | 
					 | 
				
			||||||
        ClosedCaptions: Characteristic;
 | 
					 | 
				
			||||||
        ColorTemperature: Characteristic;
 | 
					 | 
				
			||||||
        ConfigureBridgedAccessory: Characteristic;
 | 
					 | 
				
			||||||
        ConfigureBridgedAccessoryStatus: Characteristic;
 | 
					 | 
				
			||||||
        ConfiguredName: Characteristic;
 | 
					 | 
				
			||||||
        ContactSensorState: Characteristic;
 | 
					 | 
				
			||||||
        CoolingThresholdTemperature: Characteristic;
 | 
					 | 
				
			||||||
        CurrentAirPurifierState: Characteristic;
 | 
					 | 
				
			||||||
        CurrentAmbientLightLevel: Characteristic;
 | 
					 | 
				
			||||||
        CurrentDoorState: Characteristic;
 | 
					 | 
				
			||||||
        CurrentFanState: Characteristic;
 | 
					 | 
				
			||||||
        CurrentHeaterCoolerState: Characteristic;
 | 
					 | 
				
			||||||
        CurrentHeatingCoolingState: Characteristic;
 | 
					 | 
				
			||||||
        CurrentHorizontalTiltAngle: Characteristic;
 | 
					 | 
				
			||||||
        CurrentHumidifierDehumidifierState: Characteristic;
 | 
					 | 
				
			||||||
        CurrentMediaState: Characteristic;
 | 
					 | 
				
			||||||
        CurrentPosition: Characteristic;
 | 
					 | 
				
			||||||
        CurrentRelativeHumidity: Characteristic;
 | 
					 | 
				
			||||||
        CurrentSlatState: Characteristic;
 | 
					 | 
				
			||||||
        CurrentTemperature: Characteristic;
 | 
					 | 
				
			||||||
        CurrentTiltAngle: Characteristic;
 | 
					 | 
				
			||||||
        CurrentTime: Characteristic;
 | 
					 | 
				
			||||||
        CurrentVerticalTiltAngle: Characteristic;
 | 
					 | 
				
			||||||
        CurrentVisibilityState: Characteristic;
 | 
					 | 
				
			||||||
        DayoftheWeek: Characteristic;
 | 
					 | 
				
			||||||
        DigitalZoom: Characteristic;
 | 
					 | 
				
			||||||
        DiscoverBridgedAccessories: Characteristic;
 | 
					 | 
				
			||||||
        DiscoveredBridgedAccessories: Characteristic;
 | 
					 | 
				
			||||||
        DisplayOrder: Characteristic;
 | 
					 | 
				
			||||||
        FilterChangeIndication: Characteristic;
 | 
					 | 
				
			||||||
        FilterLifeLevel: Characteristic;
 | 
					 | 
				
			||||||
        FirmwareRevision: Characteristic;
 | 
					 | 
				
			||||||
        HardwareRevision: Characteristic;
 | 
					 | 
				
			||||||
        HeatingThresholdTemperature: Characteristic;
 | 
					 | 
				
			||||||
        HoldPosition: Characteristic;
 | 
					 | 
				
			||||||
        Hue: Characteristic;
 | 
					 | 
				
			||||||
        Identifier: Characteristic;
 | 
					 | 
				
			||||||
        Identify: Characteristic;
 | 
					 | 
				
			||||||
        ImageMirroring: Characteristic;
 | 
					 | 
				
			||||||
        ImageRotation: Characteristic;
 | 
					 | 
				
			||||||
        InUse: Characteristic;
 | 
					 | 
				
			||||||
        InputDeviceType: Characteristic;
 | 
					 | 
				
			||||||
        InputSourceType: Characteristic;
 | 
					 | 
				
			||||||
        IsConfigured: Characteristic;
 | 
					 | 
				
			||||||
        LeakDetected: Characteristic;
 | 
					 | 
				
			||||||
        LinkQuality: Characteristic;
 | 
					 | 
				
			||||||
        LockControlPoint: Characteristic;
 | 
					 | 
				
			||||||
        LockCurrentState: Characteristic;
 | 
					 | 
				
			||||||
        LockLastKnownAction: Characteristic;
 | 
					 | 
				
			||||||
        LockManagementAutoSecurityTimeout: Characteristic;
 | 
					 | 
				
			||||||
        LockPhysicalControls: Characteristic;
 | 
					 | 
				
			||||||
        LockTargetState: Characteristic;
 | 
					 | 
				
			||||||
        Logs: Characteristic;
 | 
					 | 
				
			||||||
        Manufacturer: Characteristic;
 | 
					 | 
				
			||||||
        Model: Characteristic;
 | 
					 | 
				
			||||||
        MotionDetected: Characteristic;
 | 
					 | 
				
			||||||
        Mute: Characteristic;
 | 
					 | 
				
			||||||
        Name: Characteristic;
 | 
					 | 
				
			||||||
        NightVision: Characteristic;
 | 
					 | 
				
			||||||
        NitrogenDioxideDensity: Characteristic;
 | 
					 | 
				
			||||||
        ObstructionDetected: Characteristic;
 | 
					 | 
				
			||||||
        OccupancyDetected: Characteristic;
 | 
					 | 
				
			||||||
        On: Characteristic;
 | 
					 | 
				
			||||||
        OpticalZoom: Characteristic;
 | 
					 | 
				
			||||||
        OutletInUse: Characteristic;
 | 
					 | 
				
			||||||
        OzoneDensity: Characteristic;
 | 
					 | 
				
			||||||
        PM10Density: Characteristic;
 | 
					 | 
				
			||||||
        PM2_5Density: Characteristic;
 | 
					 | 
				
			||||||
        PairSetup: Characteristic;
 | 
					 | 
				
			||||||
        PairVerify: Characteristic;
 | 
					 | 
				
			||||||
        PairingFeatures: Characteristic;
 | 
					 | 
				
			||||||
        PairingPairings: Characteristic;
 | 
					 | 
				
			||||||
        PictureMode: Characteristic;
 | 
					 | 
				
			||||||
        PositionState: Characteristic;
 | 
					 | 
				
			||||||
        PowerModeSelection: Characteristic;
 | 
					 | 
				
			||||||
        ProgramMode: Characteristic;
 | 
					 | 
				
			||||||
        ProgrammableSwitchEvent: Characteristic;
 | 
					 | 
				
			||||||
        ProgrammableSwitchOutputState: Characteristic;
 | 
					 | 
				
			||||||
        Reachable: Characteristic;
 | 
					 | 
				
			||||||
        RelativeHumidityDehumidifierThreshold: Characteristic;
 | 
					 | 
				
			||||||
        RelativeHumidityHumidifierThreshold: Characteristic;
 | 
					 | 
				
			||||||
        RelayControlPoint: Characteristic;
 | 
					 | 
				
			||||||
        RelayEnabled: Characteristic;
 | 
					 | 
				
			||||||
        RelayState: Characteristic;
 | 
					 | 
				
			||||||
        RemainingDuration: Characteristic;
 | 
					 | 
				
			||||||
        RemoteKey: Characteristic;
 | 
					 | 
				
			||||||
        ResetFilterIndication: Characteristic;
 | 
					 | 
				
			||||||
        RotationDirection: Characteristic;
 | 
					 | 
				
			||||||
        RotationSpeed: Characteristic;
 | 
					 | 
				
			||||||
        Saturation: Characteristic;
 | 
					 | 
				
			||||||
        SecuritySystemAlarmType: Characteristic;
 | 
					 | 
				
			||||||
        SecuritySystemCurrentState: Characteristic;
 | 
					 | 
				
			||||||
        SecuritySystemTargetState: Characteristic;
 | 
					 | 
				
			||||||
        SelectedRTPStreamConfiguration: Characteristic;
 | 
					 | 
				
			||||||
        SerialNumber: Characteristic;
 | 
					 | 
				
			||||||
        ServiceLabelIndex: Characteristic;
 | 
					 | 
				
			||||||
        ServiceLabelNamespace: Characteristic;
 | 
					 | 
				
			||||||
        SetDuration: Characteristic;
 | 
					 | 
				
			||||||
        SetupEndpoints: Characteristic;
 | 
					 | 
				
			||||||
        SlatType: Characteristic;
 | 
					 | 
				
			||||||
        SleepDiscoveryMode: Characteristic;
 | 
					 | 
				
			||||||
        SmokeDetected: Characteristic;
 | 
					 | 
				
			||||||
        SoftwareRevision: Characteristic;
 | 
					 | 
				
			||||||
        StatusActive: Characteristic;
 | 
					 | 
				
			||||||
        StatusFault: Characteristic;
 | 
					 | 
				
			||||||
        StatusJammed: Characteristic;
 | 
					 | 
				
			||||||
        StatusLowBattery: Characteristic;
 | 
					 | 
				
			||||||
        StatusTampered: Characteristic;
 | 
					 | 
				
			||||||
        StreamingStatus: Characteristic;
 | 
					 | 
				
			||||||
        SulphurDioxideDensity: Characteristic;
 | 
					 | 
				
			||||||
        SupportedAudioStreamConfiguration: Characteristic;
 | 
					 | 
				
			||||||
        SupportedRTPConfiguration: Characteristic;
 | 
					 | 
				
			||||||
        SupportedVideoStreamConfiguration: Characteristic;
 | 
					 | 
				
			||||||
        SwingMode: Characteristic;
 | 
					 | 
				
			||||||
        TargetAirPurifierState: Characteristic;
 | 
					 | 
				
			||||||
        TargetAirQuality: Characteristic;
 | 
					 | 
				
			||||||
        TargetDoorState: Characteristic;
 | 
					 | 
				
			||||||
        TargetFanState: Characteristic;
 | 
					 | 
				
			||||||
        TargetHeaterCoolerState: Characteristic;
 | 
					 | 
				
			||||||
        TargetHeatingCoolingState: Characteristic;
 | 
					 | 
				
			||||||
        TargetHorizontalTiltAngle: Characteristic;
 | 
					 | 
				
			||||||
        TargetHumidifierDehumidifierState: Characteristic;
 | 
					 | 
				
			||||||
        TargetMediaState: Characteristic;
 | 
					 | 
				
			||||||
        TargetPosition: Characteristic;
 | 
					 | 
				
			||||||
        TargetRelativeHumidity: Characteristic;
 | 
					 | 
				
			||||||
        TargetSlatState: Characteristic;
 | 
					 | 
				
			||||||
        TargetTemperature: Characteristic;
 | 
					 | 
				
			||||||
        TargetTiltAngle: Characteristic;
 | 
					 | 
				
			||||||
        TargetVerticalTiltAngle: Characteristic;
 | 
					 | 
				
			||||||
        TargetVisibilityState: Characteristic;
 | 
					 | 
				
			||||||
        TemperatureDisplayUnits: Characteristic;
 | 
					 | 
				
			||||||
        TimeUpdate: Characteristic;
 | 
					 | 
				
			||||||
        TunnelConnectionTimeout: Characteristic;
 | 
					 | 
				
			||||||
        TunneledAccessoryAdvertising: Characteristic;
 | 
					 | 
				
			||||||
        TunneledAccessoryConnected: Characteristic;
 | 
					 | 
				
			||||||
        TunneledAccessoryStateNumber: Characteristic;
 | 
					 | 
				
			||||||
        VOCDensity: Characteristic;
 | 
					 | 
				
			||||||
        ValveType: Characteristic;
 | 
					 | 
				
			||||||
        Version: Characteristic;
 | 
					 | 
				
			||||||
        Volume: Characteristic;
 | 
					 | 
				
			||||||
        VolumeControlType: Characteristic;
 | 
					 | 
				
			||||||
        VolumeSelector: Characteristic;
 | 
					 | 
				
			||||||
        WaterLevel: Characteristic;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    module Characteristic {
 | 
					 | 
				
			||||||
        export enum Formats {
 | 
					 | 
				
			||||||
            BOOL,
 | 
					 | 
				
			||||||
            INT,
 | 
					 | 
				
			||||||
            FLOAT,
 | 
					 | 
				
			||||||
            STRING,
 | 
					 | 
				
			||||||
            ARRAY, // unconfirmed
 | 
					 | 
				
			||||||
            DICTIONARY, // unconfirmed
 | 
					 | 
				
			||||||
            UINT8,
 | 
					 | 
				
			||||||
            UINT16,
 | 
					 | 
				
			||||||
            UINT32,
 | 
					 | 
				
			||||||
            UINT64,
 | 
					 | 
				
			||||||
            DATA, // unconfirmed
 | 
					 | 
				
			||||||
            TLV8
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        export enum Units {
 | 
					 | 
				
			||||||
            // HomeKit only defines Celsius, for Fahrenheit, it requires iOS app to do the conversion.
 | 
					 | 
				
			||||||
            CELSIUS,
 | 
					 | 
				
			||||||
            PERCENTAGE,
 | 
					 | 
				
			||||||
            ARC_DEGREE,
 | 
					 | 
				
			||||||
            LUX,
 | 
					 | 
				
			||||||
            SECONDS
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        export enum Perms {
 | 
					 | 
				
			||||||
            READ,
 | 
					 | 
				
			||||||
            WRITE,
 | 
					 | 
				
			||||||
            NOTIFY,
 | 
					 | 
				
			||||||
            HIDDEN
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    export interface PublishInfo {
 | 
					 | 
				
			||||||
        port: number;
 | 
					 | 
				
			||||||
        username: string;
 | 
					 | 
				
			||||||
        pincode: string;
 | 
					 | 
				
			||||||
        category: number;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    export interface Accessory extends IEventEmitterAccessory {
 | 
					 | 
				
			||||||
        new(displayName: string, UUID: string): Accessory;
 | 
					 | 
				
			||||||
        displayName: string;
 | 
					 | 
				
			||||||
        username: string;
 | 
					 | 
				
			||||||
        pincode: string;
 | 
					 | 
				
			||||||
        UUID: string;
 | 
					 | 
				
			||||||
        aid: string;
 | 
					 | 
				
			||||||
        bridged: boolean;
 | 
					 | 
				
			||||||
        bridgedAccessories: Accessory[];
 | 
					 | 
				
			||||||
        reachable: boolean;
 | 
					 | 
				
			||||||
        category: Accessory.Categories;
 | 
					 | 
				
			||||||
        services: Service[];
 | 
					 | 
				
			||||||
        cameraSource: CameraSource;
 | 
					 | 
				
			||||||
        Categories: typeof Accessory.Categories
 | 
					 | 
				
			||||||
        addService(service: Service | Function): Service;
 | 
					 | 
				
			||||||
        removeService(service: Service): void;
 | 
					 | 
				
			||||||
        getService(name: string | Function): Service;
 | 
					 | 
				
			||||||
        updateReachability(reachable: boolean): void;
 | 
					 | 
				
			||||||
        addBridgedAccessory(accessory: Accessory, deferUpdate: boolean): Accessory;
 | 
					 | 
				
			||||||
        addBridgedAccessories(accessories: Accessory[]): void
 | 
					 | 
				
			||||||
        removeBridgedAccessory(accessory: Accessory, deferUpdate: boolean): void;
 | 
					 | 
				
			||||||
        removeBridgedAccessories(accessories: Accessory[]): void;
 | 
					 | 
				
			||||||
        getCharacteristicByIID(iid: string): Characteristic;
 | 
					 | 
				
			||||||
        getBridgedAccessoryByAID(aid: string): Accessory;
 | 
					 | 
				
			||||||
        findCharacteristic(aid: string, iid: string): Accessory;
 | 
					 | 
				
			||||||
        configureCameraSource(cameraSource: CameraSource): void;
 | 
					 | 
				
			||||||
        toHAP(opt: any): JSON;
 | 
					 | 
				
			||||||
        publish(info: PublishInfo, allowInsecureRequest: boolean): void;
 | 
					 | 
				
			||||||
        destroy(): void;
 | 
					 | 
				
			||||||
        setupURI(): string;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    module Accessory {
 | 
					 | 
				
			||||||
        export enum Categories {
 | 
					 | 
				
			||||||
            OTHER = 1,
 | 
					 | 
				
			||||||
            BRIDGE = 2,
 | 
					 | 
				
			||||||
            FAN = 3,
 | 
					 | 
				
			||||||
            GARAGE_DOOR_OPENER = 4,
 | 
					 | 
				
			||||||
            LIGHTBULB = 5,
 | 
					 | 
				
			||||||
            DOOR_LOCK = 6,
 | 
					 | 
				
			||||||
            OUTLET = 7,
 | 
					 | 
				
			||||||
            SWITCH = 8,
 | 
					 | 
				
			||||||
            THERMOSTAT = 9,
 | 
					 | 
				
			||||||
            SENSOR = 10,
 | 
					 | 
				
			||||||
            ALARM_SYSTEM = 11,
 | 
					 | 
				
			||||||
            SECURITY_SYSTEM = 11,
 | 
					 | 
				
			||||||
            DOOR = 12,
 | 
					 | 
				
			||||||
            WINDOW = 13,
 | 
					 | 
				
			||||||
            WINDOW_COVERING = 14,
 | 
					 | 
				
			||||||
            PROGRAMMABLE_SWITCH = 15,
 | 
					 | 
				
			||||||
            RANGE_EXTENDER = 16,
 | 
					 | 
				
			||||||
            CAMERA = 17,
 | 
					 | 
				
			||||||
            IP_CAMERA = 17,
 | 
					 | 
				
			||||||
            VIDEO_DOORBELL = 18,
 | 
					 | 
				
			||||||
            AIR_PURIFIER = 19,
 | 
					 | 
				
			||||||
            AIR_HEATER = 20,
 | 
					 | 
				
			||||||
            AIR_CONDITIONER = 21,
 | 
					 | 
				
			||||||
            AIR_HUMIDIFIER = 22,
 | 
					 | 
				
			||||||
            AIR_DEHUMIDIFIER = 23,
 | 
					 | 
				
			||||||
            APPLE_TV = 24,
 | 
					 | 
				
			||||||
            SPEAKER = 26,
 | 
					 | 
				
			||||||
            AIRPORT = 27,
 | 
					 | 
				
			||||||
            SPRINKLER = 28,
 | 
					 | 
				
			||||||
            FAUCET = 29,
 | 
					 | 
				
			||||||
            SHOWER_HEAD = 30,
 | 
					 | 
				
			||||||
            TELEVISION = 31,
 | 
					 | 
				
			||||||
            TARGET_CONTROLLER = 32
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    export interface HAPNodeJS {
 | 
					 | 
				
			||||||
        init(storagePath?: string): void,
 | 
					 | 
				
			||||||
        uuid: uuid,
 | 
					 | 
				
			||||||
        Accessory: Accessory,
 | 
					 | 
				
			||||||
        Service: Service,
 | 
					 | 
				
			||||||
        Characteristic: Characteristic
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
declare var hapNodeJS: HAPNodeJS.HAPNodeJS;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
declare module "hap-nodejs" {
 | 
					 | 
				
			||||||
    export = hapNodeJS;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,14 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Interface to describe homebridge required elements.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
export interface IAccessory {
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Required by homebridge.
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    name: string,
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Called by homebridge to gather services.
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    getServices(): Array<HAPNodeJS.Service>,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										137
									
								
								src/platform.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								src/platform.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,137 @@
 | 
				
			|||||||
 | 
					import discover from "@watsonb8/wiz-lib/build/discovery";
 | 
				
			||||||
 | 
					import {
 | 
				
			||||||
 | 
					    API,
 | 
				
			||||||
 | 
					    Characteristic,
 | 
				
			||||||
 | 
					    DynamicPlatformPlugin,
 | 
				
			||||||
 | 
					    Logger,
 | 
				
			||||||
 | 
					    Logging,
 | 
				
			||||||
 | 
					    PlatformAccessory,
 | 
				
			||||||
 | 
					    PlatformConfig,
 | 
				
			||||||
 | 
					    Service,
 | 
				
			||||||
 | 
					    UnknownContext,
 | 
				
			||||||
 | 
					} from "homebridge";
 | 
				
			||||||
 | 
					import { v3 } from "node-hue-api";
 | 
				
			||||||
 | 
					import Api from "node-hue-api/lib/api/Api";
 | 
				
			||||||
 | 
					import { FluxAccessory } from "./fluxAccessory";
 | 
				
			||||||
 | 
					import { IConfig } from "./models/iConfig";
 | 
				
			||||||
 | 
					import { PLATFORM_NAME, PLUGIN_NAME } from "./settings";
 | 
				
			||||||
 | 
					import { Sleep } from "./sleep";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export class Platform implements DynamicPlatformPlugin {
 | 
				
			||||||
 | 
					    private hue: Api | undefined;
 | 
				
			||||||
 | 
					    private accessory: PlatformAccessory | undefined = undefined;
 | 
				
			||||||
 | 
					    private config: IConfig;
 | 
				
			||||||
 | 
					    constructor(
 | 
				
			||||||
 | 
					        public readonly log: Logger,
 | 
				
			||||||
 | 
					        config: PlatformConfig,
 | 
				
			||||||
 | 
					        public readonly api: API
 | 
				
			||||||
 | 
					    ) {
 | 
				
			||||||
 | 
					        this.config = config as unknown as IConfig;
 | 
				
			||||||
 | 
					        this.log.info("INFO - Registering Flux platform");
 | 
				
			||||||
 | 
					        this.api.on("didFinishLaunching", this.didFinishLaunching.bind(this));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    async configureAccessory(accessory: PlatformAccessory<UnknownContext>) {
 | 
				
			||||||
 | 
					        this.log.info("Loading accessory from cache:", accessory.displayName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.accessory = accessory;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Handler for didFinishLaunching
 | 
				
			||||||
 | 
					     * Happens after constructor
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private async didFinishLaunching() {
 | 
				
			||||||
 | 
					        this.log.info(`INFO - Done registering Flux platform`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        await this.connectHue();
 | 
				
			||||||
 | 
					        const wizBulbs = await this.connectWiz();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.log.info("Registering accessory: " + this.config.name);
 | 
				
			||||||
 | 
					        const uuid = this.api.hap.uuid.generate(this.config.name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Load accessory if not cached
 | 
				
			||||||
 | 
					        if (!this.accessory) {
 | 
				
			||||||
 | 
					            this.accessory = new this.api.platformAccessory(
 | 
				
			||||||
 | 
					                this.config.name,
 | 
				
			||||||
 | 
					                uuid
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					            this.accessory.context["DeviceName"] = this.config.name;
 | 
				
			||||||
 | 
					            this.accessory.context["Type"] = typeof "Flux";
 | 
				
			||||||
 | 
					            this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [
 | 
				
			||||||
 | 
					                this.accessory,
 | 
				
			||||||
 | 
					            ]);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        new FluxAccessory({
 | 
				
			||||||
 | 
					            platform: this,
 | 
				
			||||||
 | 
					            accessory: this.accessory,
 | 
				
			||||||
 | 
					            hue: this.hue!,
 | 
				
			||||||
 | 
					            wizBulbs: wizBulbs ?? [],
 | 
				
			||||||
 | 
					            config: this.config,
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private connectWiz = async () => {
 | 
				
			||||||
 | 
					        if (!this.config) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return await discover();
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private connectHue = async () => {
 | 
				
			||||||
 | 
					        if (!this.config) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (this.config.userName && this.config.clientKey) {
 | 
				
			||||||
 | 
					            this.hue = await v3.api
 | 
				
			||||||
 | 
					                .createLocal(this.config.ipAddress)
 | 
				
			||||||
 | 
					                .connect(
 | 
				
			||||||
 | 
					                    this.config.userName,
 | 
				
			||||||
 | 
					                    this.config.clientKey,
 | 
				
			||||||
 | 
					                    undefined
 | 
				
			||||||
 | 
					                );
 | 
				
			||||||
 | 
					            this.log.info("Using existing connection info");
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            const unauthenticatedApi = await v3.api
 | 
				
			||||||
 | 
					                .createLocal(this.config.ipAddress)
 | 
				
			||||||
 | 
					                .connect(undefined, undefined, undefined);
 | 
				
			||||||
 | 
					            let createdUser;
 | 
				
			||||||
 | 
					            let connected = false;
 | 
				
			||||||
 | 
					            while (!connected) {
 | 
				
			||||||
 | 
					                try {
 | 
				
			||||||
 | 
					                    this.log.info("Creating hue user. Push link button");
 | 
				
			||||||
 | 
					                    createdUser = await unauthenticatedApi.users.createUser(
 | 
				
			||||||
 | 
					                        "homebridge",
 | 
				
			||||||
 | 
					                        "HueChase"
 | 
				
			||||||
 | 
					                    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    this.hue = await v3.api
 | 
				
			||||||
 | 
					                        .createLocal(this.config.ipAddress)
 | 
				
			||||||
 | 
					                        .connect(
 | 
				
			||||||
 | 
					                            createdUser.username,
 | 
				
			||||||
 | 
					                            createdUser.clientKey,
 | 
				
			||||||
 | 
					                            undefined
 | 
				
			||||||
 | 
					                        );
 | 
				
			||||||
 | 
					                    this.log.info("Connected to Hue Bridge");
 | 
				
			||||||
 | 
					                    this.log.info(
 | 
				
			||||||
 | 
					                        `UserName: ${createdUser.username}, ClientKey: ${createdUser.clientkey}`
 | 
				
			||||||
 | 
					                    );
 | 
				
			||||||
 | 
					                    connected = true;
 | 
				
			||||||
 | 
					                } catch (err: any) {
 | 
				
			||||||
 | 
					                    if (err.getHueErrorType() === 101) {
 | 
				
			||||||
 | 
					                        this.log.info(
 | 
				
			||||||
 | 
					                            "The Link button on the bridge was not pressed. Please press the Link button and try again."
 | 
				
			||||||
 | 
					                        );
 | 
				
			||||||
 | 
					                        Sleep(5000);
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        this.log.info(`Unexpected Error: ${err.message}`);
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										9
									
								
								src/settings.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/settings.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * This is the name of the platform that users will use to register the plugin in the Homebridge config.json
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					export const PLATFORM_NAME = "Flux";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * This must match the name of your plugin as defined the package.json
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					export const PLUGIN_NAME = "@watsonb8/homebridge-flux";
 | 
				
			||||||
@@ -2,18 +2,18 @@
 | 
				
			|||||||
    "compilerOptions": {
 | 
					    "compilerOptions": {
 | 
				
			||||||
        /* Basic Options */
 | 
					        /* Basic Options */
 | 
				
			||||||
        // "incremental": true,                   /* Enable incremental compilation */
 | 
					        // "incremental": true,                   /* Enable incremental compilation */
 | 
				
			||||||
        "target": "ESNext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
 | 
					        "target": "ESNext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
 | 
				
			||||||
        "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
 | 
					        "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
 | 
				
			||||||
        // "lib": [],                             /* Specify library files to be included in the compilation. */
 | 
					        // "lib": [],                             /* Specify library files to be included in the compilation. */
 | 
				
			||||||
        // "allowJs": true,                       /* Allow javascript files to be compiled. */
 | 
					        // "allowJs": true,                       /* Allow javascript files to be compiled. */
 | 
				
			||||||
        // "checkJs": true,                       /* Report errors in .js files. */
 | 
					        // "checkJs": true,                       /* Report errors in .js files. */
 | 
				
			||||||
        // "jsx": "preserve",                     /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
 | 
					        // "jsx": "preserve",                     /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
 | 
				
			||||||
        // "declaration": true,                   /* Generates corresponding '.d.ts' file. */
 | 
					        // "declaration": true,                   /* Generates corresponding '.d.ts' file. */
 | 
				
			||||||
        // "declarationMap": true,                /* Generates a sourcemap for each corresponding '.d.ts' file. */
 | 
					        // "declarationMap": true,                /* Generates a sourcemap for each corresponding '.d.ts' file. */
 | 
				
			||||||
        "sourceMap": true, /* Generates corresponding '.map' file. */
 | 
					        "sourceMap": true /* Generates corresponding '.map' file. */,
 | 
				
			||||||
        // "outFile": "./",                       /* Concatenate and emit output to single file. */
 | 
					        // "outFile": "./",                       /* Concatenate and emit output to single file. */
 | 
				
			||||||
        "outDir": "./bin", /* Redirect output structure to the directory. */
 | 
					        "outDir": "./bin" /* Redirect output structure to the directory. */,
 | 
				
			||||||
        // "rootDir": "./",                       /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
 | 
					        "rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
 | 
				
			||||||
        // "composite": true,                     /* Enable project compilation */
 | 
					        // "composite": true,                     /* Enable project compilation */
 | 
				
			||||||
        // "tsBuildInfoFile": "./",               /* Specify file to store incremental compilation information */
 | 
					        // "tsBuildInfoFile": "./",               /* Specify file to store incremental compilation information */
 | 
				
			||||||
        // "removeComments": true,                /* Do not emit comments to output. */
 | 
					        // "removeComments": true,                /* Do not emit comments to output. */
 | 
				
			||||||
@@ -22,7 +22,7 @@
 | 
				
			|||||||
        // "downlevelIteration": true,            /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
 | 
					        // "downlevelIteration": true,            /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
 | 
				
			||||||
        // "isolatedModules": true,               /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
 | 
					        // "isolatedModules": true,               /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
 | 
				
			||||||
        /* Strict Type-Checking Options */
 | 
					        /* Strict Type-Checking Options */
 | 
				
			||||||
        "strict": true, /* Enable all strict type-checking options. */
 | 
					        "strict": true /* Enable all strict type-checking options. */,
 | 
				
			||||||
        // "noImplicitAny": true,                 /* Raise error on expressions and declarations with an implied 'any' type. */
 | 
					        // "noImplicitAny": true,                 /* Raise error on expressions and declarations with an implied 'any' type. */
 | 
				
			||||||
        // "strictNullChecks": true,              /* Enable strict null checks. */
 | 
					        // "strictNullChecks": true,              /* Enable strict null checks. */
 | 
				
			||||||
        // "strictFunctionTypes": true,           /* Enable strict checking of function types. */
 | 
					        // "strictFunctionTypes": true,           /* Enable strict checking of function types. */
 | 
				
			||||||
@@ -36,14 +36,14 @@
 | 
				
			|||||||
        // "noImplicitReturns": true,             /* Report error when not all code paths in function return a value. */
 | 
					        // "noImplicitReturns": true,             /* Report error when not all code paths in function return a value. */
 | 
				
			||||||
        // "noFallthroughCasesInSwitch": true,    /* Report errors for fallthrough cases in switch statement. */
 | 
					        // "noFallthroughCasesInSwitch": true,    /* Report errors for fallthrough cases in switch statement. */
 | 
				
			||||||
        /* Module Resolution Options */
 | 
					        /* Module Resolution Options */
 | 
				
			||||||
        // "moduleResolution": "node",            /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
 | 
					        // "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
 | 
				
			||||||
        // "baseUrl": "./",                       /* Base directory to resolve non-absolute module names. */
 | 
					        // "baseUrl": "./",                       /* Base directory to resolve non-absolute module names. */
 | 
				
			||||||
        // "paths": {},                           /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
 | 
					        // "paths": {},                           /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
 | 
				
			||||||
        // "rootDirs": [],                        /* List of root folders whose combined content represents the structure of the project at runtime. */
 | 
					        // "rootDirs": [],                        /* List of root folders whose combined content represents the structure of the project at runtime. */
 | 
				
			||||||
        // "typeRoots": [],                       /* List of folders to include type definitions from. */
 | 
					        // "typeRoots": [],                       /* List of folders to include type definitions from. */
 | 
				
			||||||
        // "types": [],                           /* Type declaration files to be included in compilation. */
 | 
					        "types": [] /* Type declaration files to be included in compilation. */,
 | 
				
			||||||
        // "allowSyntheticDefaultImports": true,  /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
 | 
					        // "allowSyntheticDefaultImports": true,  /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
 | 
				
			||||||
        "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
 | 
					        "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
 | 
				
			||||||
        // "preserveSymlinks": true,              /* Do not resolve the real path of symlinks. */
 | 
					        // "preserveSymlinks": true,              /* Do not resolve the real path of symlinks. */
 | 
				
			||||||
        // "allowUmdGlobalAccess": true,          /* Allow accessing UMD globals from modules. */
 | 
					        // "allowUmdGlobalAccess": true,          /* Allow accessing UMD globals from modules. */
 | 
				
			||||||
        /* Source Map Options */
 | 
					        /* Source Map Options */
 | 
				
			||||||
@@ -55,6 +55,7 @@
 | 
				
			|||||||
        // "experimentalDecorators": true,        /* Enables experimental support for ES7 decorators. */
 | 
					        // "experimentalDecorators": true,        /* Enables experimental support for ES7 decorators. */
 | 
				
			||||||
        // "emitDecoratorMetadata": true,         /* Enables experimental support for emitting type metadata for decorators. */
 | 
					        // "emitDecoratorMetadata": true,         /* Enables experimental support for emitting type metadata for decorators. */
 | 
				
			||||||
        /* Advanced Options */
 | 
					        /* Advanced Options */
 | 
				
			||||||
        "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
 | 
					        "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
 | 
				
			||||||
 | 
					        "skipLibCheck": false
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user