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

homebridge-rflink

Package Overview
Dependencies
Maintainers
0
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

homebridge-rflink - npm Package Compare versions

Comparing version 1.3.2-dev.0 to 1.3.2-dev.1

56

dist/index.js

@@ -185,3 +185,3 @@ "use strict";

});
var cachedCurrentPosition = this.storage.getItemSync(`${this.name}-current-position`);
var cachedCurrentPosition = this.storage.getItemSync(this.name);
if (typeof cachedCurrentPosition === "number") {

@@ -197,4 +197,5 @@ this.log(`got cached current position of ${this.config.type.toLowerCase()} '${this.config.name}' as ${cachedCurrentPosition}`);

return callback();
this.targetPosition = value > 0 ? 100 : 0;
this.storage.setItemSync(`${this.name}-target-position`, value);
this.targetPosition = value;
if (this.targetPosition === this.currentPosition)
return callback();
if (!this.config.devices) {

@@ -205,4 +206,4 @@ throw new Error("No device provided");

log(`positioning ${config.type.toLowerCase()} '${config.name}' (device = ${device}) to ${value}`);
this.updateCurrentPosition(value);
this.send(`10;${device};${value == 0 ? "DOWN" : "UP"}\r\n`, callback);
this.startMovingCurrentPosition();
this.send(`10;${device};${value < this.currentPosition ? "DOWN" : "UP"}\r\n`, callback);
})

@@ -212,8 +213,32 @@ .on("get" /* CharacteristicEventTypes.GET */, (callback) => {

});
var cachedTargetPosition = this.storage.getItemSync(`${this.name}-target-position`);
if (typeof cachedTargetPosition === "number") {
this.log(`got cached target position of ${this.config.type.toLowerCase()} '${this.config.name}' as ${cachedTargetPosition}`);
this.updateTargetPosition(cachedTargetPosition, false);
this.updateTargetPosition(this.currentPosition);
}
startMovingCurrentPosition() {
if (this.currentPosition == this.targetPosition) {
return;
}
if (!this.config.positioningTiming) {
// Set the current position to the target one right away if no timing information is provided
this.updateCurrentPosition(this.targetPosition);
return;
}
if (this.movingTimeout) {
clearTimeout(this.movingTimeout);
}
const dx = this.currentPosition < this.targetPosition ? 1 : -1;
const dt = this.config.positioningTiming / 100;
this.moveCurrentPositionBy(dx, dt * 1000);
}
moveCurrentPositionBy(dx, dt) {
const newCurrentPosition = this.currentPosition + dx;
if (newCurrentPosition == this.targetPosition) {
this.updateCurrentPosition(newCurrentPosition);
}
else {
this.updateCurrentPosition(newCurrentPosition, false);
this.movingTimeout = setTimeout(() => {
this.moveCurrentPositionBy(dx, dt);
}, dt);
}
}
onMessage(message) {

@@ -223,7 +248,7 @@ switch (message.command) {

this.updateTargetPosition(100);
this.updateCurrentPosition(100);
this.startMovingCurrentPosition();
break;
case "OFF":
case "DOWN":
this.updateTargetPosition(0);
this.updateCurrentPosition(0);
this.startMovingCurrentPosition();
break;

@@ -239,13 +264,10 @@ default:

if (cache) {
this.storage.setItemSync(`${this.name}-current-position`, value);
this.storage.setItemSync(this.name, value);
}
}
}
updateTargetPosition(value, cache = true) {
updateTargetPosition(value) {
this.log(`updated target position of ${this.config.type.toLowerCase()} '${this.config.name}' to ${value}`);
this.targetPosition = value;
this.service.setCharacteristic(hap.Characteristic.TargetPosition, value);
if (cache) {
this.storage.setItemSync(`${this.name}-target-position`, value);
}
}

@@ -252,0 +274,0 @@ getServices() {

{
"name": "homebridge-rflink",
"version": "1.3.2-dev.0",
"version": "1.3.2-dev.1",
"description": "RFLink support for Homebridge",

@@ -5,0 +5,0 @@ "license": "MIT",

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