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

iobroker.amazon-dash

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iobroker.amazon-dash - npm Package Compare versions

Comparing version 0.2.9 to 0.3.1

admin/index_m.html

8

admin/words.js

@@ -10,7 +10,11 @@ systemDictionary = {

"de": "PCAP Interface (lasse leer wenn default)",
"ru": ""
"ru": "Интерфейс PCAP (оставить пустыми по умолчанию)"
},
"name": {"en": "Name", "de": "Name", "ru": "Имя"},
"mac": {"en": "MAC Address format first xx:xx:xx", "de": "MAC Adresse die ersten xx:xx:xx", "ru": "MAC Адрес xx:xx:xx"},
"mac": {
"en": "MAC Address format first xx:xx:xx",
"de": "MAC Adresse die ersten xx:xx:xx",
"ru": "MAC Адрес xx:xx:xx"
},
};

@@ -0,0 +0,0 @@ // converts a numeric array: [ 143, 63, 32, 51, 84, 68 ]

{
"common": {
"name": "amazon-dash",
"version": "0.2.9",
"version": "0.3.1",
"title": "Amazon Dash-Button",

@@ -11,2 +11,11 @@ "desc": {

},
"authors": [
"Patrick Arns <npm@patrick-arns.de>"
],
"news": {
"0.3.0": {
"en": "materialize ui and minor fixes, dash buttons now of type device",
"de": "Materialize Oberfläche und kleine Änderungen, Dash Buttons sind nun vom Typ Device"
}
},
"platform": "Javascript/Node.js",

@@ -17,2 +26,3 @@ "license": "MIT",

"enabled": true,
"materialize": true,
"extIcon": "https://raw.githubusercontent.com/PArns/ioBroker.amazon-dash/master/admin/amazon-dash.png",

@@ -19,0 +29,0 @@ "keywords": [

@@ -1,28 +0,45 @@

var controllerDir;
'use strict';
// Get js-controller directory to load libs
const fs = require('fs');
const path = require('path');
let controllerDir;
let appName;
/**
* returns application name
*
* The name of the application can be different and this function finds it out.
*
* @returns {string}
*/
function getAppName() {
const parts = __dirname.replace(/\\/g, '/').split('/');
return parts[parts.length - 2].split('.')[0];
}
/**
* looks for js-controller home folder
*
* @param {boolean} isInstall
* @returns {string}
*/
function getControllerDir(isInstall) {
var fs = require('fs');
// Find the js-controller location
var controllerDir = __dirname.replace(/\\/g, '/');
controllerDir = controllerDir.split('/');
if (controllerDir[controllerDir.length - 3] == 'adapter') {
controllerDir.splice(controllerDir.length - 3, 3);
controllerDir = controllerDir.join('/');
} else if (controllerDir[controllerDir.length - 3] == 'node_modules') {
controllerDir.splice(controllerDir.length - 3, 3);
controllerDir = controllerDir.join('/');
if (fs.existsSync(controllerDir + '/node_modules/iobroker.js-controller')) {
controllerDir += '/node_modules/iobroker.js-controller';
} else if (fs.existsSync(controllerDir + '/node_modules/ioBroker.js-controller')) {
controllerDir += '/node_modules/ioBroker.js-controller';
} else if (!fs.existsSync(controllerDir + '/controller.js')) {
if (!isInstall) {
console.log('Cannot find js-controller');
process.exit(10);
} else {
process.exit();
const possibilities = [
'iobroker.js-controller',
'ioBroker.js-controller',
];
/** @type {string} */
let controllerPath;
for (const pkg of possibilities) {
try {
const possiblePath = require.resolve(pkg);
if (fs.existsSync(possiblePath)) {
controllerPath = possiblePath;
break;
}
}
} else {
} catch (e) { /* not found */ }
}
if (controllerPath == null) {
if (!isInstall) {

@@ -35,13 +52,33 @@ console.log('Cannot find js-controller');

}
return controllerDir;
// we found the controller
return path.dirname(controllerPath);
}
// Read controller configuration file
function getConfig() {
return JSON.parse(fs.readFileSync(controllerDir + '/conf/iobroker.json'));
/**
* reads controller base settings
*
* @alias getConfig
* @returns {object}
*/
function getConfig() {
let configPath;
if (fs.existsSync(
configPath = path.join(controllerDir, 'conf', appName + '.json')
)) {
return JSON.parse(fs.readFileSync(configPath, 'utf8'));
} else if (fs.existsSync(
configPath = path.join(controllerDir, 'conf', + appName.toLowerCase() + '.json')
)) {
return JSON.parse(fs.readFileSync(configPath, 'utf8'));
} else {
throw new Error('Cannot find ' + controllerDir + '/conf/' + appName + '.json');
}
}
controllerDir = getControllerDir(typeof process != 'undefined' && process.argv && process.argv.indexOf('--install') != -1);
appName = getAppName();
controllerDir = getControllerDir(typeof process !== 'undefined' && process.argv && process.argv.indexOf('--install') !== -1);
const adapter = require(path.join(controllerDir, 'lib/adapter.js'));
exports.controllerDir = controllerDir;
exports.getConfig = getConfig;
exports.adapter = require(controllerDir + '/lib/adapter.js');
exports.Adapter = adapter;
exports.appName = appName;

@@ -5,8 +5,8 @@ /* jshint -W097 */// jshint strict:false

var utils = require(__dirname + '/lib/utils');
var adapter = utils.adapter('amazon-dash');
var int_array_to_hex = require('./helpers.js').int_array_to_hex;
var pcap = require('pcap');
const utils = require(__dirname + '/lib/utils');
const adapter = utils.Adapter('amazon-dash');
const int_array_to_hex = require('./helpers.js').int_array_to_hex;
const pcap = require('pcap');
var MACs = [
let MACs = [
"747548",

@@ -33,7 +33,8 @@ "F0D2F1",

"2C3AE8",
"6C5697"
"6C5697",
"38F73D"
];
String.prototype.replaceAll = function (search, replacement) {
var target = this;
const target = this;
return target.replace(new RegExp(search, 'g'), replacement);

@@ -48,3 +49,3 @@ };

// is called when adapter shuts down - callback has to be called under any circumstances!
adapter.on('unload', function (callback) {
adapter.on('unload', (callback) => {
try {

@@ -59,7 +60,6 @@ adapter.log.info('cleaned everything up...');

function main() {
var k;
if (adapter.config.devices && adapter.config.devices.length) {
for (k = 0; k < adapter.config.devices.length; k++) {
var mac = adapter.config.devices[k].mac;
var macOK = mac.replaceAll(":", "");
for (let k = 0; k < adapter.config.devices.length; k++) {
let mac = adapter.config.devices[k].mac;
let macOK = mac.replaceAll(":", "");

@@ -82,13 +82,13 @@ if (macOK.length > 5) {

var pcap_session = pcap.createSession(adapter.config.interface, "arp");
let pcap_session = pcap.createSession(adapter.config.interface, "arp");
pcap_session.on('packet', function (raw_packet) {
var packet = pcap.decode.packet(raw_packet);
const packet = pcap.decode.packet(raw_packet);
if (packet.payload.ethertype === 2054) {
var mac = packet.payload.payload.sender_ha.addr;
let mac = packet.payload.payload.sender_ha.addr;
mac = int_array_to_hex(mac);
var nice_mac = mac.replaceAll(":", "-");
var needle = mac.slice(0, 8).toString().toUpperCase().split(':').join('');
const nice_mac = mac.replaceAll(":", "-");
const needle = mac.slice(0, 8).toString().toUpperCase().split(':').join('');

@@ -98,2 +98,14 @@ adapter.log.debug('needle MAC : ' + needle);

if (MACs.indexOf(needle) > -1) {
adapter.getObject(nice_mac, (err, obj) => {
// if non existent or not type device
if (!obj || obj.type !== 'device') {
adapter.setObject(nice_mac, {
type: "device",
common: {},
native: {}
});
} // endIf
});
adapter.setObjectNotExists(nice_mac + ".pressed", {

@@ -112,3 +124,3 @@ type: "state",

setTimeout(function () {
setTimeout(() => {
adapter.setState(nice_mac + ".pressed", {val: false, ack: true});

@@ -141,7 +153,7 @@ }, 5000);

adapter.getState(nice_mac + ".switch", function (err, state) {
adapter.getState(nice_mac + ".switch", (err, state) => {
if (!state || err)
adapter.setState(nice_mac + ".switch", {val: false, ack: true});
else {
var now = new Date();
const now = new Date();
if (now.getTime() - state.lc > 5000) {

@@ -158,8 +170,8 @@ adapter.setState(nice_mac + ".switch", {val: !state.val, ack: true});

function remove_duplicates(arr) {
var obj = {};
var ret_arr = [];
for (var i = 0; i < arr.length; i++) {
let obj = {};
let ret_arr = [];
for (let i = 0; i < arr.length; i++) {
obj[arr[i]] = true;
}
for (var key in obj) {
for (let key in obj) {
ret_arr.push(key);

@@ -166,0 +178,0 @@ }

{
"name": "iobroker.amazon-dash",
"version": "0.2.9",
"description": "ioBroker amazon-dash Adapter",
"author": {
"name": "Patrick Arns",
"email": "npm@patrick-arns.de"
},
"contributors": [
{
"name": "Patrick Arns",
"email": "npm@patrick-arns.de"
"name": "iobroker.amazon-dash",
"version": "0.3.1",
"description": "ioBroker amazon-dash Adapter",
"author": {
"name": "Patrick Arns",
"email": "npm@patrick-arns.de"
},
"contributors": [
{
"name": "Patrick Arns",
"email": "npm@patrick-arns.de"
}
],
"homepage": "https://github.com/PArns/ioBroker.amazon-dash",
"license": "MIT",
"keywords": [
"ioBroker",
"amazon-dash",
"Smart Home",
"home automation"
],
"repository": {
"type": "git",
"url": "https://github.com/PArns/ioBroker.amazon-dash"
},
"dependencies": {
"pcap": "^2.1.0"
},
"devDependencies": {
"gulp": "^3.9.1",
"mocha": "^4.1.0",
"chai": "^4.1.2"
},
"bugs": {
"url": "https://github.com/PArns/ioBroker.amazon-dash/issues"
},
"readmeFilename": "README.md",
"scripts": {
"preinstall": "apt install libpcap-dev -y || true",
"test": "node node_modules/mocha/bin/mocha --exit"
}
],
"homepage": "https://github.com/PArns/ioBroker.amazon-dash",
"license": "MIT",
"keywords": [
"ioBroker",
"amazon-dash",
"Smart Home",
"home automation"
],
"repository": {
"type": "git",
"url": "https://github.com/PArns/ioBroker.amazon-dash"
},
"dependencies": {
"pcap": "https://github.com/mranney/node_pcap/tarball/master"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-replace": "^0.9.3",
"grunt-contrib-jshint": "^0.11.2",
"grunt-jscs": "^2.0.0",
"grunt-http": "^1.6.0",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-compress": "^0.13.0",
"grunt-contrib-copy": "^0.8.0",
"grunt-exec": "^0.4.6"
},
"bugs": {
"url": "https://github.com/PArns/ioBroker.amazon-dash/issues"
},
"readmeFilename": "README.md",
"scripts": {
"preinstall": "apt-get install libpcap-dev -y || true"
}
}

@@ -26,4 +26,16 @@ ![Logo](admin/amazon-dash.png)

## HELP WANTED!
As this project is developed during my spare time, I*m actively looking for help to maintain and extend this lib! If you're willing to help, drop me a line!
## Changelog
### 0.3.1
+ (PArns) Added new Amazon MAC family
### 0.3.0
+ (foxriver76) materialize ui
+ (foxriver76) dash buttons are now of type device
### 0.2.9

@@ -30,0 +42,0 @@ + (cernst1980) Ignore duplicate ARPs for 5 seconds

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