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

iobroker.wifilight

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iobroker.wifilight - npm Package Compare versions

Comparing version 0.0.17 to 0.0.18

2

io-package.json
{
"common": {
"name": "wifilight",
"version": "0.0.17",
"version": "0.0.18",
"title": "WiFi Light",

@@ -6,0 +6,0 @@ "desc": {

{
"name": "iobroker.wifilight",
"version": "0.0.17",
"version": "0.0.18",
"description": "WiFi Light Adapter",

@@ -5,0 +5,0 @@ "author": {

"use strict";
var //utils = require(__dirname + '/lib/utils'),
discovery = require(__dirname + '/lib/discovery'),
var discovery = require(__dirname + '/lib/discovery'),
colors = require(__dirname + '/lib/colors'),

@@ -16,2 +15,6 @@ soef = require('soef'),

Number.prototype.toHex = function () {
return ('0' + this.toString(16)).substr(-2);
};
function hex(ar, len) {

@@ -21,3 +24,3 @@ var s = "";

for (var i=0; i<len; i++) {
s += ('0' + ar[i].toString(16)).substr(-2) + ' ';
s += ar[i].toHex() + ' ';
}

@@ -54,38 +57,4 @@ return s;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//var utils = require(__dirname + '/lib/utils');
//
//var adapter = utils.adapter({
// name: 'wifilight',
//
// unload: function (callback) {
// try {
// for (var i in wifi) {
// wifi[i].close();
// }
// callback();
// } catch (e) {
// callback();
// }
// },
// //discover: function (callback) {
// //},
// //install: function (callback) {
// //},
// //uninstall: function (callback) {
// //},
// objectChange: function (id, obj) {
// },
// stateChange: function (id, state) {
// if (state && !state.ack) {
// onStateChange(id, state);
// }
// },
// message: onMessage,
// ready: function () {
// soef.main(adapter, main);
// }
//});
//
function onMessage (obj) {

@@ -127,3 +96,2 @@ if (!obj) return;

var usedStateNames = {

@@ -147,3 +115,5 @@ online: { n: 'reachable', val: 0, common: { write: false, min: false, max: true }},

transition: { n: 'trans', val: 30, common: { unit: '\u2152 s', desc: 'in 10th seconds'} },
command: { n: 'command', val: 'r:0, g:0, b:0, on:true, transition:30', desc: 'r:0, g:0, b:0, on:true, transition:2' }
command: { n: 'command', val: 'r:0, g:0, b:0, on:true, transition:30', desc: 'r:0, g:0, b:0, on:true, transition:2' },
rgb: { n: 'rgb', val: '', common: { desc: '000000..ffffff' }}
};

@@ -154,8 +124,21 @@

function parseHexColors(val) {
val = val.toString();
var ar = val.split('.');
if (ar && ar.length > 1) val = ar[0];
if (val[0] === '#') val = val.substr(1);
var co = {
r: parseInt(val.substr(1, 2), 16),
g: parseInt(val.substr(3, 2), 16) || 0,
b: parseInt(val.substr(5, 2), 16) || 0,
w: val.length > 7 ? parseInt(val.substr(7, 2), 16) : undefined
r: parseInt(val.substr(0, 2), 16),
g: parseInt(val.substr(2, 2), 16) || 0,
b: parseInt(val.substr(4, 2), 16) || 0 //,
};
if (val.length > 7) {
co.w = parseInt(val.substr(6, 2), 16);
}
if (ar && ar.length > 1) {
var m = Number('.' + ar[1]);
for (var i in co) {
co[i] *= m;
}
roundRGB(co);
}
return co;

@@ -178,2 +161,7 @@ }

break;
case 'rgbw':
case 'rgb':
var co = parseHexColors(state.val);
device.color(channel, co);
break;
case 'r':

@@ -184,10 +172,10 @@ case 'g':

case 'sat':
var co;
if (typeof state.val == 'string' && state.val[0] == '#') {
var co = parseHexColors(state.val);
device.color(channel, co);
break;
co = parseHexColors(state.val);
} else {
co = device.getRGBStates(channel);
co[stateName] = state.val >> 0;
}
var colors = device.getRGBStates(channel);
colors[stateName] = state.val >> 0;
device.color(channel, colors);
device.color(channel, co);
break;

@@ -198,3 +186,2 @@ case usedStateNames.refresh.n:

device.dev.update();
//devices.update();
break;

@@ -228,6 +215,5 @@ case usedStateNames.bri.n:

case usedStateNames.command.n:
//var v = state.val.replace(/^on$|red|green|blue|transition|bri|off|#/g, function(match) { return { '#': '#', of:'off:1', on:'on:1', red:'r', green:'g', blue:'b', white: 'w', transition:'x', bri:'l', off:'on:0'}[match] });
//v = v.replace(/\s|\"|;$|,$/g, '').replace(/=/g, ':').replace(/;/g, ',').replace(/true/g, 1).replace(/#((\d|[a-f]|[A-F])*)/g, 'h:"$1"').replace(/(r|g|b|w|x|l|sat|of|on|ct|h)/g, '"$1"').replace(/^\{?(.*?)\}?$/, '{$1}');
var v = state.val.replace(/(^on$|red|green|blue|transition|bri|off)/g, function(match, p) { return { '#': '#', off:'off:1', on:'on:1', red:'r', green:'g', blue:'b', white: 'w', transition:'x', bri:'l'/*, off:'on:0'*/} [match] });
v = v.replace(/\s|\"|;$|,$/g, '').replace(/=/g, ':').replace(/;/g, ',').replace(/true/g, 1).replace(/((on|off),{1})/g, '$2:1,').replace(/#((\d|[a-f]|[A-F])*)/g, 'h:"$1"').replace(/(r|g|b|w|x|l|sat|off|on|ct|h)/g, '"$1"').replace(/^\{?(.*?)\}?$/, '{$1}');
//v = v.replace(/\s|\"|;$|,$/g, '').replace(/=/g, ':').replace(/;/g, ',').replace(/true/g, 1).replace(/((on|off),{1})/g, '$2:1,').replace(/#((\d|[a-f]|[A-F])*)/g, 'h:"$1"').replace(/(r|g|b|w|x|l|sat|off|on|ct|h)/g, '"$1"').replace(/^\{?(.*?)\}?$/, '{$1}');
v = v.replace(/\s|\"|;$|,$/g, '').replace(/=/g, ':').replace(/;/g, ',').replace(/true/g, 1).replace(/((on|off),{1})/g, '$2:1,').replace(/#((\d|[a-f]|[A-F]|[.])*)/g, 'h:"$1"').replace(/(r|g|b|w|x|l|sat|off|on|ct|h)/g, '"$1"').replace(/^\{?(.*?)\}?$/, '{$1}');
try {

@@ -241,3 +227,6 @@ var colors = JSON.parse(v);

var co = parseHexColors('#'+colors.h);
colors.r = co.r; colors.g = co.g; colors.b = co.b;
//colors = Object.assign(colors, co);
for (var i in co) {
colors[i] = co[i];
}
delete colors.h;

@@ -255,5 +244,2 @@ }

}
//if(o.of !== undefined) {
// device.color(channel, {r:0, g:0, b:0, w: o.w != undefined ? 0 : undefined});
//}
if (o['on'] !== undefined) {

@@ -330,3 +316,3 @@ device.on_off(channel, o.on >> 0 ? true : false);

timeout = cb;
cb = unknown;
cb = undefined;
}

@@ -381,7 +367,2 @@ if (this.client) {

//self.client.on('connect', function(error) {
// wifi[self.dev.getFullId()] = self;
// self.log(self.config.ip + ' connected');
// self.setOnline(true);
// self.runUpdateTimer();
// if (cb) cb();
//});

@@ -582,24 +563,2 @@

//wifiLight.prototype.dim = function (channel, level, time) {
// var co = { r:0, g:0, b:0 };
//
// var max = parseInt(level*255/100);
// var steps = parseInt(max * 54 / 100);
// var delay = parseInt(time*1000 / steps);
// var dif = 1;
//
// for (var i = 0; i<steps; i++) {
// this.color(channel, co.r, co.g, co.b, { delay:delay });
// co.r += dif;
// co.g += dif;
// co.b += dif;
// if (co.r > max || co.g > max || co.b > max) {
// break;
// }
// var p = parseInt(i*5 / steps);
// if (p>dif) dif = p;
// }
// //this.ad(channel, state ? this.cmds.on : this.cmds.off);
//};
wifiLight.prototype.fade = function (channel, rgbw, transitionTime) {

@@ -685,5 +644,2 @@ if (!transitionTime) {

{
//var buf = this.dataBuffer.subarray(0, this.cmds.responseLen);
//var buf = new Buffer(this.dataBuffer, 0, this.cmds.responseLen);
//var states = this.cmds.decodeResponse(buf);
var states = this.cmds.decodeResponse(this.dataBuffer);

@@ -706,2 +662,5 @@ this.log('onData: raw: ' + hex(this.dataBuffer, this.cmds.responseLen));

this.dev.set(usedStateNames.white.n, this.states.white);
var rgb = '#' + this.states.red.toHex() + this.states.green.toHex() + this.states.blue.toHex();
if (this.states.white != undefined) rgb += this.states.white.toHex();
this.dev.set(usedStateNames.rgb.n, rgb);
devices.update();

@@ -732,3 +691,4 @@ }

adapter.subscribeStates('*');
adapter.subscribeObjects('*');
}
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