node-red-contrib-blynk-ws
Advanced tools
Comparing version 0.5.2 to 0.6.0
@@ -9,2 +9,6 @@ # Changelog | ||
## [0.6.0] - 2018-05-07 | ||
### Added | ||
- Node - *zeRGBa* - New node to simplify the use of this widget in merge mode | ||
## [0.5.2] - 2018-04-27 | ||
@@ -98,3 +102,4 @@ ### Fixed | ||
[Unreleased]: https://github.com/gablau/node-red-contrib-blynk-ws/compare/0.5.2...HEAD | ||
[Unreleased]: https://github.com/gablau/node-red-contrib-blynk-ws/compare/0.6.0...HEAD | ||
[0.6.0]: https://github.com/gablau/node-red-contrib-blynk-ws/compare/0.5.2...0.6.0 | ||
[0.5.1]: https://github.com/gablau/node-red-contrib-blynk-ws/compare/0.5.1...0.5.2 | ||
@@ -101,0 +106,0 @@ [0.5.1]: https://github.com/gablau/node-red-contrib-blynk-ws/compare/0.5.0...0.5.1 |
@@ -7,3 +7,3 @@ module.exports = function(RED) { | ||
var LIBRARY_INFO = "0.5.2 2018-04-27"; | ||
var LIBRARY_INFO = "0.6.0 2018-05-07"; | ||
@@ -802,15 +802,64 @@ /* ##### BLYNK STUFF ###### */ | ||
} | ||
//const util = require('util'); | ||
for (var i = 0; i < this._inputNodes.length; i++) { | ||
if (this._inputNodes[i].nodeType == "write" && (this._inputNodes[i].pin == command.pin || this._inputNodes[i].pin_all ) ) { | ||
//this.log(util.inspect(this._inputNodes[i], false, 1)) | ||
if ((this._inputNodes[i].nodeType == "write" || this._inputNodes[i].nodeType == "zergba") && | ||
(this._inputNodes[i].pin == command.pin || this._inputNodes[i].pin_all ) ) { | ||
var msg; | ||
msg = { | ||
payload: command.value, | ||
pin: command.pin, | ||
}; | ||
switch (this._inputNodes[i].nodeType){ | ||
case 'write': | ||
if (command.array) { | ||
msg.arrayOfValues = command.array; | ||
msg = { | ||
payload: command.value, | ||
pin: command.pin, | ||
}; | ||
if (command.array) { | ||
msg.arrayOfValues = command.array; | ||
} | ||
break; | ||
case 'zergba': | ||
function rgbToHex(r, g, b) { | ||
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); | ||
} | ||
function hexToRgb(hex) { | ||
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") | ||
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; | ||
hex = hex.replace(shorthandRegex, function(m, r, g, b) { | ||
return r + r + g + g + b + b; | ||
}); | ||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); | ||
return result ? { | ||
r: parseInt(result[1], 16), | ||
g: parseInt(result[2], 16), | ||
b: parseInt(result[3], 16) | ||
} : null; | ||
} | ||
msg = { | ||
payload: command.value, | ||
pin: command.pin, | ||
}; | ||
msg.hex = rgbToHex(parseInt(command.array[0]), parseInt(command.array[1]), parseInt(command.array[2])); | ||
var color = hexToRgb(msg.hex); | ||
msg.r = color.r; | ||
msg.g = color.g; | ||
msg.b = color.b; | ||
msg.rgb = color.r+";"+color.g+";"+color.b; | ||
msg.payload = [color.r, color.g, color.b]; | ||
this._inputNodes[i].status({ | ||
fill: "green", | ||
shape: "dot", | ||
text: this._inputNodes[i].connected_label + " ["+color.r+", "+color.g+", "+color.b+"]", | ||
}); | ||
break; | ||
} | ||
if(this.dbg_all || this.dbg_write || this.isLogPin(command.pin)){ | ||
@@ -817,0 +866,0 @@ this.log("writeEvent: -> output " + JSON.stringify(msg)); |
{ | ||
"name": "node-red-contrib-blynk-ws", | ||
"version": "0.5.2", | ||
"version": "0.6.0", | ||
"description": "Node Red integration with Blynk App and Server through websockets", | ||
@@ -43,5 +43,6 @@ "scripts": { | ||
"blynk-ws-out-notify": "nodes/blynk-ws-out-notify.js", | ||
"blynk-ws-out-table": "nodes/blynk-ws-out-table.js" | ||
"blynk-ws-out-table": "nodes/blynk-ws-out-table.js", | ||
"blynk-ws-zergba": "nodes/blynk-ws-zergba.js" | ||
} | ||
} | ||
} |
@@ -47,2 +47,3 @@ [![npm version](https://img.shields.io/npm/v/node-red-contrib-blynk-ws.svg)](https://www.npmjs.com/package/node-red-contrib-blynk-ws) | ||
- Table widget | ||
- zeRGBa widget | ||
@@ -49,0 +50,0 @@ ### Changelog |
130384
50
1975
106