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

@nzws/homebridge-mlru1-light

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nzws/homebridge-mlru1-light - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

127

dist/index.js

@@ -34,5 +34,3 @@ "use strict";

this.currentStatus = true;
this.updatingStatus = true;
this.currentBrightness = 100;
this.updatingBrightness = 100;
this.log = log;

@@ -80,3 +78,2 @@ this.config = config;

.setCharacteristic(this.Characteristic.SerialNumber, 'ho-me-br-id-ge');
void this.initializeQueue();
}

@@ -90,6 +87,2 @@ /**

}
async initializeQueue() {
const PQueue = await import('p-queue');
this.queue = new PQueue.default({ concurrency: 1 });
}
handleOnGet() {

@@ -100,36 +93,19 @@ this.log.debug('handleOnGet');

async handleOnSet(value) {
if (!this.queue) {
this.log.error('queue is not initialized');
if (value === this.currentStatus) {
return;
}
return this.queue.add(async () => {
if (value === this.updatingStatus) {
return;
}
this.updatingStatus = value;
this.log.debug('handleOnSet:', value);
if (this.statusTimeout) {
clearTimeout(this.statusTimeout);
}
let isOutdated = false;
try {
if (!value) {
await this._toggleLight();
}
this.log.debug('handleOnSet:', value);
this.currentStatus = value;
try {
if (!value) {
await this._toggleLight();
isOutdated = value !== this.updatingStatus;
if (!isOutdated) {
this.statusTimeout = setTimeout(() => {
this.currentStatus = value;
this.OnCharacteristic.updateValue(this.currentStatus);
}, 1000);
}
}
catch (e) {
if (!isOutdated) {
this.updatingStatus = !value;
}
throw e;
await this._toggleLight();
}
catch (e) {
if (this.currentStatus === value) {
this.currentStatus = !value;
}
});
throw e;
}
}

@@ -141,56 +117,39 @@ handleBrightnessGet() {

async handleBrightnessSet(value) {
if (!this.queue) {
this.log.error('queue is not initialized');
if (!this.currentStatus) {
this.log.warn('handleBrightnessSet: light is off');
return;
}
return this.queue.add(async () => {
if (!this.currentStatus) {
this.log.warn('handleBrightnessSet: light is off');
return;
}
const prevPercent = this.updatingBrightness;
const newPercent = value;
const prevCount = this._percentToBrightness(prevPercent);
const newCount = this._percentToBrightness(newPercent);
const diff = Math.abs(newCount - prevCount);
const isBright = newCount > prevCount;
this.log.debug('handleBrightnessSet', {
value,
prevCount,
newCount,
diff,
isBright,
});
if (diff < 0) {
return;
}
this.updatingBrightness = newPercent;
if (this.brightnessTimeout) {
clearTimeout(this.brightnessTimeout);
}
let isOutdated = false;
try {
for (let i = 0; i < diff; i++) {
if (isBright) {
await this._brightnessUp();
}
else {
await this._brightnessDown();
}
const prevPercent = this.currentBrightness;
const newPercent = value;
const prevCount = this._percentToBrightness(prevPercent);
const newCount = this._percentToBrightness(newPercent);
const diff = Math.abs(newCount - prevCount);
const isBright = newCount > prevCount;
this.log.debug('handleBrightnessSet', {
value,
prevCount,
newCount,
diff,
isBright,
});
if (diff < 0) {
return;
}
this.currentBrightness = newPercent;
try {
for (let i = 0; i < diff; i++) {
if (isBright) {
await this._brightnessUp();
}
isOutdated = newPercent !== this.updatingBrightness;
if (!isOutdated) {
this.brightnessTimeout = setTimeout(() => {
this.currentBrightness = newPercent;
this.BrightnessCharacteristic.updateValue(newPercent);
}, 1000);
else {
await this._brightnessDown();
}
}
catch (e) {
if (!isOutdated) {
this.updatingBrightness = prevPercent;
}
throw e;
}
catch (e) {
if (this.currentBrightness === newPercent) {
this.currentBrightness = prevPercent;
}
});
throw e;
}
}

@@ -197,0 +156,0 @@ _percentToBrightness(percent) {

{
"displayName": "MLRU1 Light with Nature Remo",
"name": "@nzws/homebridge-mlru1-light",
"version": "1.2.3",
"version": "1.2.4",
"description": "アイリスオーヤマ製「ML-RU1」リモコンを使用する照明を操作するプラグイン",

@@ -30,7 +30,6 @@ "license": "Apache-2.0",

"dependencies": {
"nature-remo": "^2.0.0",
"p-queue": "8.0.1"
"nature-remo": "^2.0.0"
},
"devDependencies": {
"@types/node": "^22.5.2",
"@types/node": "^22.5.3",
"@typescript-eslint/eslint-plugin": "^8.4.0",

@@ -37,0 +36,0 @@ "@typescript-eslint/parser": "^8.4.0",

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