homebridge-inio
Advanced tools
Comparing version 0.7.0--canary.4.4198803560.0 to 0.7.0--canary.4.4198854344.0
@@ -21,3 +21,2 @@ import type { AccessoryConfig, AccessoryPlugin, API, CharacteristicValue, Logging, Service } from 'homebridge'; | ||
private readonly modeSwitch; | ||
private estimationMap; | ||
constructor(log: Logging, config: AccessoryConfig, api: API); | ||
@@ -28,20 +27,20 @@ apiUrl(suffix: string): string; | ||
/** | ||
* Loads a packed version of the estimation map | ||
* This was created using srcipt/create-estimation-map.ts | ||
* Basically this is a huge rainbow table and we just search for the best match | ||
*/ | ||
* Loads a packed version of the estimation map | ||
* This was created using srcipt/create-estimation-map.ts | ||
* Basically this is a huge rainbow table and we just search for the best match | ||
*/ | ||
loadResultPacked(): Promise<Array<EstimationItem>>; | ||
/** | ||
* euclidian distance | ||
*/ | ||
* euclidian distance | ||
*/ | ||
distance(a: LampPowers, b: LampPowers): number; | ||
/** | ||
* Gets the current lamp power | ||
* This is a bit tricky because the lamp takes some time to settle | ||
* So we wait until the values are stable | ||
*/ | ||
* Gets the current lamp power | ||
* This is a bit tricky because the lamp takes some time to settle | ||
* So we wait until the values are stable | ||
*/ | ||
getLampPower(): Promise<LampPowers>; | ||
/** | ||
* Gets the estimated temperature based on the current power | ||
*/ | ||
* Gets the estimated temperature based on the current power | ||
*/ | ||
getEstimate(power: LampPowers): LampTemperature; | ||
@@ -48,0 +47,0 @@ getEstimatedTemperature(): Promise<LampTemperature>; |
@@ -9,2 +9,13 @@ "use strict"; | ||
const fs_1 = __importDefault(require("fs")); | ||
const data_packed_json_1 = __importDefault(require("./data-packed.json")); | ||
const estimationMap = data_packed_json_1.default.map((it) => ({ | ||
temperature: { | ||
brightness: it[0], | ||
kelvin: it[1], | ||
}, | ||
power: { | ||
warm: it[2], | ||
cold: it[3], | ||
}, | ||
})); | ||
class InioAccessoryPlugin { | ||
@@ -35,6 +46,2 @@ constructor(log, config, api) { | ||
.onSet(this.handleColorTemperatureSet.bind(this)); | ||
this.estimationMap = []; | ||
this.loadResultPacked().then(it => { | ||
this.estimationMap = it; | ||
}); | ||
} | ||
@@ -87,6 +94,6 @@ apiUrl(suffix) { | ||
/** | ||
* Loads a packed version of the estimation map | ||
* This was created using srcipt/create-estimation-map.ts | ||
* Basically this is a huge rainbow table and we just search for the best match | ||
*/ | ||
* Loads a packed version of the estimation map | ||
* This was created using srcipt/create-estimation-map.ts | ||
* Basically this is a huge rainbow table and we just search for the best match | ||
*/ | ||
async loadResultPacked() { | ||
@@ -106,4 +113,4 @@ const packed = JSON.parse(fs_1.default.readFileSync('data-packed.json', 'utf-8')); | ||
/** | ||
* euclidian distance | ||
*/ | ||
* euclidian distance | ||
*/ | ||
distance(a, b) { | ||
@@ -115,6 +122,6 @@ const coldDistance = Math.abs(a.cold - b.cold); | ||
/** | ||
* Gets the current lamp power | ||
* This is a bit tricky because the lamp takes some time to settle | ||
* So we wait until the values are stable | ||
*/ | ||
* Gets the current lamp power | ||
* This is a bit tricky because the lamp takes some time to settle | ||
* So we wait until the values are stable | ||
*/ | ||
async getLampPower() { | ||
@@ -132,8 +139,8 @@ let response = (await (0, axios_1.default)(this.apiUrl('/api/app/pwm_duty_get'))).data; | ||
/** | ||
* Gets the estimated temperature based on the current power | ||
*/ | ||
* Gets the estimated temperature based on the current power | ||
*/ | ||
getEstimate(power) { | ||
let best = this.estimationMap[0]; | ||
let best = estimationMap[0]; | ||
let bestDistance = this.distance(power, best.power); | ||
this.estimationMap.forEach(it => { | ||
estimationMap.forEach(it => { | ||
if (this.distance(it.power, power) < bestDistance) { | ||
@@ -140,0 +147,0 @@ best = it; |
{ | ||
"displayName": "Inio", | ||
"name": "homebridge-inio", | ||
"version": "0.7.0--canary.4.4198803560.0", | ||
"version": "0.7.0--canary.4.4198854344.0", | ||
"description": "A plugin for inio light lamps", | ||
@@ -42,3 +42,3 @@ "license": "Apache-2.0", | ||
"dist", | ||
"data-packed.json" | ||
"src/data-packed.json" | ||
], | ||
@@ -45,0 +45,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2254398
17
4363
1