From 55c65dac8478d32b252b9c0507c713a6a78d1b3f Mon Sep 17 00:00:00 2001 From: Brandon Watson Date: Mon, 3 Jan 2022 13:13:50 -0500 Subject: [PATCH] Fixing issue where flux was unresponsive --- .vscode/launch.json | 33 ++++++++++++++++++--------------- .vscode/tasks.json | 33 +++++++++++++++++---------------- package-lock.json | 2 +- package.json | 2 +- src/fluxAccessory.ts | 11 +++++++---- 5 files changed, 44 insertions(+), 37 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 76b1657..ee206d5 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,16 +1,19 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "Launch Program", - "preLaunchTask": "build and install", - "program": "/Users/brandonwatson/.npm-global/bin/homebridge", - "sourceMaps": true, - } - ] -} \ No newline at end of file + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "preLaunchTask": "build", + "program": "/Users/brandonwatson/.nvm/versions/node/v14.15.0/lib/node_modules/homebridge/bin/homebridge", + "env": { + "HOMEBRIDGE_OPTS": "/Users/brandonwatson/.homebridge" + }, + "sourceMaps": true + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index ad92e87..ab4213d 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,17 +1,18 @@ { - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "type": "npm", - "script": "build", - "problemMatcher": [] - }, - { - "type": "shell", - "label": "build and install", - "command": "npm run build&&sudo npm install -g --unsafe-perm ." - } - ] -} \ No newline at end of file + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "build", + "label": "build", + "problemMatcher": [] + }, + { + "type": "shell", + "label": "build and install", + "command": "npm run build&&sudo npm install -g --unsafe-perm ." + } + ] +} diff --git a/package-lock.json b/package-lock.json index 1068824..2c64eb7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@watsonb8/homebridge-flux", - "version": "1.1.1", + "version": "1.1.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index bca2073..3d29f81 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@watsonb8/homebridge-flux", - "version": "1.1.1", + "version": "1.1.2", "description": "", "main": "bin/index.js", "publishConfig": { diff --git a/src/fluxAccessory.ts b/src/fluxAccessory.ts index 507e15e..73436c7 100644 --- a/src/fluxAccessory.ts +++ b/src/fluxAccessory.ts @@ -8,7 +8,6 @@ import { IConfig } from "./models/iConfig"; import { GetTimesResult, getTimes } from "suncalc"; import HueError = require("node-hue-api/lib/HueError"); import cron from "node-cron"; -import { callbackify } from "util"; let Service: HAPNodeJS.Service; let Characteristic: HAPNodeJS.Characteristic; @@ -102,6 +101,7 @@ export class FluxAccessory implements IAccessory { .getCharacteristic(Characteristic.On) //@ts-ignore .on("set", this.onSetEnabled) + //@ts-ignore .on("get", this.onGetEnabled); } @@ -134,9 +134,12 @@ export class FluxAccessory implements IAccessory { * Handler for switch get event * @param callback The callback function to call when complete */ - private onGetEnabled = (): boolean => { - return this._isActive; - }; + private onGetEnabled( + callback: (error: Error | null, value: boolean) => void + ): void { + callback(null, this._isActive); + // return this._isActive; + } /** * Called by homebridge to gather services.