Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

homebridge-inio

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

homebridge-inio - npm Package Compare versions

Comparing version 0.7.0 to 0.7.1--canary.6.4211410014.0

17

dist/accessory.d.ts

@@ -10,5 +10,7 @@ import type { AccessoryConfig, AccessoryPlugin, API, CharacteristicValue, Logging, Service } from 'homebridge';

};
type EstimationItem = {
power: LampPowers;
temperature: LampTemperature;
type Mode = 'OFF' | 'CONNECTED' | 'STATIC';
type Addon = 'NONE' | 'BOOST' | 'RELAX' | 'SCENARIO';
type Status = {
mode: Mode;
addon: Addon;
};

@@ -24,11 +26,8 @@ export declare class InioAccessoryPlugin implements AccessoryPlugin {

apiUrl(suffix: string): string;
pushUpdate(): Promise<void>;
getStatus(): Promise<Status>;
setToMode(mode: Mode): Promise<void>;
handleModeGet(): Promise<CharacteristicValue>;
handleModeSet(value: CharacteristicValue): Promise<void>;
/**
* 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

@@ -35,0 +34,0 @@ */

@@ -8,3 +8,2 @@ "use strict";

const axios_1 = __importDefault(require("axios"));
const fs_1 = __importDefault(require("fs"));
const data_packed_json_1 = __importDefault(require("./data-packed.json"));

@@ -32,3 +31,6 @@ const estimationMap = data_packed_json_1.default.map((it) => ({

this.modeSwitch = new this.api.hap.Service.Switch('Inio Light Mode');
// this.modeSwitch.setCharacteristic(this.api.hap.Characteristic.Name, 'Inio Light Mode');
// this.modeSwitch.setCharacteristic(this.api.hap.Characteristic.Model, 'Inio Light Mode');
this.modeSwitch.getCharacteristic(this.api.hap.Characteristic.On)
// .setProps({ description: "Turn on/off the 'connected' mode"})
.onGet(this.handleModeGet.bind(this))

@@ -45,2 +47,3 @@ .onSet(this.handleModeSet.bind(this));

this.lightBulb.getCharacteristic(this.api.hap.Characteristic.ColorTemperature)
.setProps({ minValue: 153, maxValue: 370 })
.onGet(this.handleColorTemperatureGet.bind(this))

@@ -52,62 +55,49 @@ .onSet(this.handleColorTemperatureSet.bind(this));

}
async handleModeGet() {
async pushUpdate() {
// this.lightBulb.updateCharacteristic(this.api.hap.Characteristic.On, await this.handleOnGet());
// this.lightBulb.updateCharacteristic(this.api.hap.Characteristic.Brightness, await this.handleBrightnesGet());
// this.lightBulb.updateCharacteristic(this.api.hap.Characteristic.ColorTemperature, await this.handleColorTemperatureGet());
//
// this.modeSwitch.updateCharacteristic(this.api.hap.Characteristic.On, await this.handleModeGet());
}
async getStatus() {
const response = await (0, axios_1.default)(this.apiUrl('/api/app/status'));
return response.data.mode === 'CONNECTED';
return response.data;
}
async handleModeSet(value) {
const response = await (0, axios_1.default)(this.apiUrl('/api/app/status'));
const mode = response.data.mode;
try {
if (value) {
switch (mode) {
case 'CONNECTED':
return;
case 'OFF':
await (0, axios_1.default)(this.apiUrl('/api/interface/btn_short_manual'), {
method: 'PUT',
});
// we actually want to fall through here
// eslint-disable-next-line no-fallthrough
case 'SCENARIO':
case 'STATIC':
await (0, axios_1.default)(this.apiUrl('/api/interface/btn_short_connect'), {
method: 'PUT',
});
break;
default:
this.log.error('Unknown mode: ' + mode);
break;
async setToMode(mode) {
const status = await this.getStatus();
if (status.mode === mode) {
return;
}
switch (mode) {
case 'OFF':
await (0, axios_1.default)(this.apiUrl('/api/interface/btn_short_manual'), { method: 'PUT' });
break;
case 'CONNECTED':
if (status.mode === 'OFF') {
await (0, axios_1.default)(this.apiUrl('/api/interface/btn_short_manual'), { method: 'PUT' });
}
}
else {
if (mode === 'OFF') {
return;
await (0, axios_1.default)(this.apiUrl('/api/interface/btn_short_connect'), { method: 'PUT' });
break;
case 'STATIC':
if (status.mode === 'OFF') {
await (0, axios_1.default)(this.apiUrl('/api/interface/btn_short_manual'), { method: 'PUT' });
}
await (0, axios_1.default)(this.apiUrl('/api/interface/btn_short_manual'), {
method: 'PUT',
});
}
else if (status.mode === 'CONNECTED') {
await (0, axios_1.default)(this.apiUrl('/api/interface/btn_short_connect'), { method: 'PUT' });
}
break;
default:
this.log.error('Unknown mode: ' + mode);
}
catch (e) {
this.log.error('got an error', e);
}
await this.pushUpdate();
}
/**
* 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() {
const packed = JSON.parse(fs_1.default.readFileSync('data-packed.json', 'utf-8'));
return packed.map(it => ({
temperature: {
brightness: it[0],
kelvin: it[1],
},
power: {
warm: it[2],
cold: it[3],
},
}));
async handleModeGet() {
const status = await this.getStatus();
return status.mode === 'CONNECTED';
}
async handleModeSet(value) {
this.log.debug('handleModeSet', value);
await this.setToMode(value ? 'CONNECTED' : 'OFF');
}
/**

@@ -129,4 +119,6 @@ * euclidian distance

let settled = false;
this.log.debug('Getting lamp status');
while (!settled) {
await sleep(10);
this.log.debug('Waiting for lamp to settle');
await sleep(100);
const current = (await (0, axios_1.default)(this.apiUrl('/api/app/pwm_duty_get'))).data;

@@ -136,2 +128,3 @@ settled = current.cold === response.cold && current.warm === response.warm;

}
this.log.debug('settled on ' + JSON.stringify(response));
return response;

@@ -163,2 +156,3 @@ }

try {
await this.setToMode('STATIC');
const temperature = await this.getEstimatedTemperature();

@@ -172,2 +166,3 @@ await (0, axios_1.default)(this.apiUrl('/api/app/light_color'), {

});
void this.pushUpdate();
}

@@ -185,2 +180,3 @@ catch (e) {

try {
await this.setToMode('STATIC');
const temperature = await this.getEstimatedTemperature();

@@ -197,2 +193,3 @@ // We need to clamp the value because the lamp does not support all values

});
void this.pushUpdate();
}

@@ -204,27 +201,9 @@ catch (e) {

async handleOnGet() {
const response = await (0, axios_1.default)(this.apiUrl('/api/app/status'));
return response.data.mode !== 'OFF';
const status = await this.getStatus();
return status.mode !== 'OFF';
}
async handleOnSet(value) {
try {
const status = await this.handleOnGet();
if (status === value) {
return;
}
if (value) {
if (status) {
return;
}
await (0, axios_1.default)(this.apiUrl('/api/interface/btn_short_manual'), {
method: 'PUT',
});
await (0, axios_1.default)(this.apiUrl('/api/interface/btn_short_connect'), {
method: 'PUT',
});
}
else {
await (0, axios_1.default)(this.apiUrl('/api/interface/btn_short_manual'), {
method: 'PUT',
});
}
await this.setToMode(value ? 'STATIC' : 'OFF');
void this.pushUpdate();
}

@@ -231,0 +210,0 @@ catch (e) {

{
"displayName": "Inio",
"name": "homebridge-inio",
"version": "0.7.0",
"version": "0.7.1--canary.6.4211410014.0",
"description": "A plugin for inio light lamps",

@@ -32,2 +32,3 @@ "license": "Apache-2.0",

"@typescript-eslint/parser": "^5.0.0",
"all-contributors-cli": "^6.24.0",
"auto": "^10.42.0",

@@ -34,0 +35,0 @@ "eslint": "^8.0.1",

@@ -37,2 +37,9 @@ # Homebridge plugin for [inio](https://inio-light.com) lights

<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/reckter"><img src="https://avatars.githubusercontent.com/u/1771450?v=4?s=100" width="100px;" alt="Hannes Güdelhöfer"/><br /><sub><b>Hannes Güdelhöfer</b></sub></a><br /><a href="https://github.com/reckter/homebridge-inio/commits?author=reckter" title="Code">💻</a> <a href="#ideas-reckter" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-reckter" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-reckter" title="Maintenance">🚧</a></td>
</tr>
</tbody>
</table>

@@ -42,2 +49,14 @@ <!-- markdownlint-restore -->

<!-- ALL-CONTRIBUTORS-LIST:END -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc