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

homebridge-rflink

Package Overview
Dependencies
Maintainers
1
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.1.0 to 1.1.1

58

dist/index.cjs.js

@@ -8,3 +8,3 @@ 'use strict';

const Readline = SerialPort.parsers.Readline;
let Service, Characteristic;
let Service, Characteristic; // TODO: types
function index (homebridge) {

@@ -21,22 +21,17 @@ Service = homebridge.hap.Service;

let device = config.device || "/dev/ttyACM0";
try {
this.port = new SerialPort(device, {
baudRate: 57600,
});
this.port.on("error", (err) => {
log(`error opening port: ${err.message}`);
});
this.parser = this.port.pipe(new Readline({ delimiter: "\r\n" }));
this.parser.on("data", s => {
this.log(`received ${s}`);
const m = s.match(/^20;\d+;(?<proto>[^;]+);ID=(?<address>[^;]+);SWITCH=(?<button>[^;]+);CMD=(?<command>[^;]+);/);
if (m) {
const { proto, address, button, command } = m.groups;
this.notify({ proto, command, device: `${address};${button}` });
}
});
}
catch (e) {
throw Error(`Unable to open port '${device}': ${e.message}`);
}
this.port = new SerialPort(device, {
baudRate: 57600,
});
this.port.on("error", (err) => {
log(`error opening port: ${err.message}`);
});
const parser = this.port.pipe(new Readline({ delimiter: "\r\n" }));
parser.on("data", s => {
this.log(`received ${s}`);
const m = s.match(/^20;\d+;(?<proto>[^;]+);ID=(?<address>[^;]+);SWITCH=(?<button>[^;]+);CMD=(?<command>[^;]+);/);
if (m) {
const { proto, address, button, command } = m.groups;
this.notify({ device: `${proto};${address};${button}`, command });
}
});
}

@@ -65,3 +60,3 @@ subscribe(callback) {

}
this.log(`adding ${acc.type.toLowerCase()} '${acc.name}' (proto=${acc.proto}, devices= ${acc.devices})`);
this.log(`adding ${acc.type.toLowerCase()} '${acc.name}' (devices = ${acc.devices})`);
return new RFLinkAccessory(acc, this.port, this.log, this.subscribe.bind(this));

@@ -73,7 +68,6 @@ }));

constructor(config, port, log, subscribe) {
this.name = config.name;
this.config = config;
this.port = port;
this.log = log;
this.service = new Service[config.type](config.name);
this.log = log;
this.config = config;
subscribe((message) => {

@@ -111,4 +105,7 @@ if (!config.devices) {

const device = this.config.devices[0];
log(`switching ${config.type.toLowerCase()} '${config.name}' (proto=${config.proto}, device = ${device}) ${value ? "on" : "off"}`);
this.port.write(`10;${config.proto};${device};${value ? "ON" : "OFF"}\r\n`, callback);
log(`switching ${config.type.toLowerCase()} '${config.name}' (device = ${device}) ${value ? "on" : "off"}`);
this.port.write(`10;${device};${value ? "ON" : "OFF"}\r\n`, callback);
})
.on("get", (callback) => {
callback(null, this.currentValue);
});

@@ -128,4 +125,7 @@ if (config.dimmable) {

const device = this.config.devices[0];
log(`dimming ${config.type.toLowerCase()} '${config.name}' (proto=${config.proto}, device = ${device}) to level ${level}`);
this.port.write(`10;${config.proto};${device};${level}\r\n`, callback);
log(`dimming ${config.type.toLowerCase()} '${config.name}' (device = ${device}) to level ${level}`);
this.port.write(`10;${device};${level}\r\n`, callback);
})
.on("get", (callback) => {
callback(null, this.currentLevel);
});

@@ -132,0 +132,0 @@ }

import SerialPort from 'serialport';
const Readline = SerialPort.parsers.Readline;
let Service, Characteristic;
let Service, Characteristic; // TODO: types
function index (homebridge) {

@@ -16,22 +16,17 @@ Service = homebridge.hap.Service;

let device = config.device || "/dev/ttyACM0";
try {
this.port = new SerialPort(device, {
baudRate: 57600,
});
this.port.on("error", (err) => {
log(`error opening port: ${err.message}`);
});
this.parser = this.port.pipe(new Readline({ delimiter: "\r\n" }));
this.parser.on("data", s => {
this.log(`received ${s}`);
const m = s.match(/^20;\d+;(?<proto>[^;]+);ID=(?<address>[^;]+);SWITCH=(?<button>[^;]+);CMD=(?<command>[^;]+);/);
if (m) {
const { proto, address, button, command } = m.groups;
this.notify({ proto, command, device: `${address};${button}` });
}
});
}
catch (e) {
throw Error(`Unable to open port '${device}': ${e.message}`);
}
this.port = new SerialPort(device, {
baudRate: 57600,
});
this.port.on("error", (err) => {
log(`error opening port: ${err.message}`);
});
const parser = this.port.pipe(new Readline({ delimiter: "\r\n" }));
parser.on("data", s => {
this.log(`received ${s}`);
const m = s.match(/^20;\d+;(?<proto>[^;]+);ID=(?<address>[^;]+);SWITCH=(?<button>[^;]+);CMD=(?<command>[^;]+);/);
if (m) {
const { proto, address, button, command } = m.groups;
this.notify({ device: `${proto};${address};${button}`, command });
}
});
}

@@ -60,3 +55,3 @@ subscribe(callback) {

}
this.log(`adding ${acc.type.toLowerCase()} '${acc.name}' (proto=${acc.proto}, devices= ${acc.devices})`);
this.log(`adding ${acc.type.toLowerCase()} '${acc.name}' (devices = ${acc.devices})`);
return new RFLinkAccessory(acc, this.port, this.log, this.subscribe.bind(this));

@@ -68,7 +63,6 @@ }));

constructor(config, port, log, subscribe) {
this.name = config.name;
this.config = config;
this.port = port;
this.log = log;
this.service = new Service[config.type](config.name);
this.log = log;
this.config = config;
subscribe((message) => {

@@ -106,4 +100,7 @@ if (!config.devices) {

const device = this.config.devices[0];
log(`switching ${config.type.toLowerCase()} '${config.name}' (proto=${config.proto}, device = ${device}) ${value ? "on" : "off"}`);
this.port.write(`10;${config.proto};${device};${value ? "ON" : "OFF"}\r\n`, callback);
log(`switching ${config.type.toLowerCase()} '${config.name}' (device = ${device}) ${value ? "on" : "off"}`);
this.port.write(`10;${device};${value ? "ON" : "OFF"}\r\n`, callback);
})
.on("get", (callback) => {
callback(null, this.currentValue);
});

@@ -123,4 +120,7 @@ if (config.dimmable) {

const device = this.config.devices[0];
log(`dimming ${config.type.toLowerCase()} '${config.name}' (proto=${config.proto}, device = ${device}) to level ${level}`);
this.port.write(`10;${config.proto};${device};${level}\r\n`, callback);
log(`dimming ${config.type.toLowerCase()} '${config.name}' (device = ${device}) to level ${level}`);
this.port.write(`10;${device};${level}\r\n`, callback);
})
.on("get", (callback) => {
callback(null, this.currentLevel);
});

@@ -127,0 +127,0 @@ }

{
"name": "homebridge-rflink",
"version": "1.1.0",
"version": "1.1.1",
"description": "RFLink support for Homebridge: https://github.com/nfarina/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