GithubHelp home page GithubHelp logo

node-red-contrib-blynk's Introduction

node-red-contrib-blynk

Blynk app integration with Node Red

This contrib will no longer be updated. Please use the websockets version.

Websockets version

Due to some reliability issues reported by some users, together with some new features added by the Blynk team, I started another version of this based on websockets. https://github.com/tzapu/node-red-contrib-blynk-websockets

Normal Blynk Protocol version

NPM npm version

If you installed Node Red globally use this to install npm install --global node-red-contrib-blynk

Supports both SSL, non SSL connections to blynk-cloud.com and local server.

Supported events and widgets

  • read event
  • write event
  • write command
  • LCD widget (advanced mode)
  • push notifications

Blynk App Settings

Use Raspberry PI as hardware to access 64 virtual pins or Generic Board for 32.

How to use

LCD Widget LCD Print Widget Node

  • use advanced mode on LCD Widget in iOS/android Blynk App
  • set message.payload to the text you want displayed
  • set message.topic to the line you want it shown on (0 or 1, defaults to 0)
  • set message.payload to 'clear-lcd' if you want to clear it

Debug

Use the verbose -v flag when starting Node-Red to get more information

Available Nodes

Available Nodes

node-red-contrib-blynk's People

Contributors

aaddame avatar tzapu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-red-contrib-blynk's Issues

Does not recover when internet goes down

This may or may not be related to the two previous "Does not recover issues".
When the internet goes down I get an "Uncaught Exception".
My retreat is in the mountains which does not have a reliable internet connection!
I can sometimes recover by stopping and restarting node-red.
I am keen to persevere with this Blynk node in node-red because; the widgets are beautiful, it gives iOS cloud UI access and any data configuration can be accommodated by node-red.

Specifically, the error dialog is:
pi@RPi40:~ $ node-red-start
Once Node-RED has started, point a browser at http://192.168.1.102:1880
To stop Node-RED use the command node-red-stop
[ ok ] Starting nodered (via systemctl): nodered.service.
28 Dec 15:17:29 - [info] Server now running at http://127.0.0.1:1880/
28 Dec 15:17:29 - [info] Starting flows
Connecting to SSL: cloud.blynk.cc 8441
28 Dec 15:17:29 - [info] Started flows
Connecting to SSL: cloud.blynk.cc 8441
Connecting to SSL: cloud.blynk.cc 8441
28 Dec 15:17:44 - [red] Uncaught Exception:
28 Dec 15:17:44 - Error: getaddrinfo ENOTFOUND
at errnoException (dns.js:37:11)
at Object.onanswer as oncomplete

CACHEING ISSUE

Got a definite issue here... so - add a WRITE EVENT NODE.... button on the APP - say, on V1. So you have a button that when pressed sends out a signal to node-red.

Copy the button - PASTE - change V1 to V2. Add another button to your APP. You now have TWO buttons - one for ON (say), one for OFF.

Press on - the light comes on and immediately goes off. Until you REBOOT Node-Red, it seems unaware that you have changed the virtual input on the second (or third) input.

This needs fixing - rebooting Node-Red every time you add something is not good.

I think I had a similar issue when adding a second APP KEY.. again for it to work - I had to reboot node-red..

Ouestion/issue

When I make a new project in the blynk app it requires me to choose the Hardware Model, what effect does that ultimately have, do I need to choose the hardware node-red is running on ?

For example my current project was originally set-up to control a ESP8266 (with a couple of relays and a few sensors) so the hardware choice was setup as ESP8266 however now I reconfigured it so blynk talks to node-red which talks to mqtt which talks to the ESP it all work fine, but on some occasions like first connection in a morning blink cannot connect and says ESP8266 offline - actually the ESP is online, mqtt is on line and node-red is online its the blynk nodes that show no connection.

Would changing the hardware choice to Raspberry pi2 make a difference to this problem ?

Toshi

LCD node

Trying to use inject node (string) to send lcd.print(0,0,"hello"); to write event node virtual pin 27 (LCD widget) but its not working.

Am I doing something wrong or is this element not available yet ,(if not, do you plan to implement ?)

Toshi

LCD Widget Discussion

Short tips for lcd widget are:

use advanced mode on ios
set message.payload to the text you want displayed
set message.topic to the line you want it shown on (0,1)
set message.payload to 'clear-lcd' if you want to clear it
short example using an inject node
[{"id":"23f12591.81dfba","type":"blynk-server","key":"","usessl":true,"host":"","port":""},{"id":"f629c0bd.775d","type":"blynk-lcd-print","name":"","server":"23f12591.81dfba","pin":"20","x":288,"y":825,"z":"1ed41123.5fece7","wires":[]},{"id":"d31bb3f7.206a2","type":"inject","name":"","topic":"1","payload":"5","payloadType":"string","repeat":"","crontab":"","once":false,"x":92,"y":406,"z":"1ed41123.5fece7","wires":[["a431d5da.26d288","f629c0bd.775d"]]}]

please note that is just something i threw together. any suggestions on how to better do it are more than welcome

Problem each time I when I press deploy in node-red

Hi
I am getting the following on my ssh window each time I press deploy in node-red after I modify my flows ๐Ÿ‘

pi@raspberrypi ~ $ (node) warning: possible EventEmitter memory leak detected. 11 connect listeners added.
Use emitter.setMaxListeners() to increase limit.
Trace
at addListener (events.js:179:15)
at setupStatusEvents (/home/pi/.node-red/node_modules/node-red-contrib-blynk /blynk.js:14:24)
at new BlynkWriteNode (/home/pi/.node-red/node_modules/node-red-contrib-blynk/blynk.js:83:3)
at createNode (/usr/lib/node_modules/node-red/red/nodes/Flow.js:35:18)
at Flow.start (/usr/lib/node_modules/node-red/red/nodes/Flow.js:392:44)
at Object.module.exports.startFlows (/usr/lib/node_modules/node-red/red/nodes/flows.js:141:24)
at /usr/lib/node_modules/node-red/red/nodes/flows.js:121:77
at tryCatchReject (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:845:30)
at runContinuation1 (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:804:4)
at Fulfilled.when (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:592:4)
(node) warning: possible EventEmitter memory leak detected. 11 disconnect listeners added.
Use emitter.setMaxListeners() to increase limit.

The guys over at node-red suggest the problem could be :
Possibly "not closing down the event listeners properly during the redeploy. Should be using the on close method to clean up."

Toshi

Problem with write event node

Hi (Thanks, by the way for resolving #3 works nice now) however I came across another problem, if I use the write node to toggle (send 1 then 0) to a LED on a virtual pin say v10 it works fine, if I then replace the LED with a BUTTON on v10 I expected the button to toggle On then Off but it doesn't work, am I missing something ?
Toshi

Problem each time I when I press deploy in node-red ( ssl connection )

Regarding issue #3 (Problem each time I when I press deploy in node-red) Your fix appeared to work as I didn't get the warning: possible EventEmitter memory leak detected, however I now tested ssl connection and each time I deploy my flow which uses 28 blynk nodes, I get

Trace
at addListener (events.js:179:15)
at /home/pi/.node-red/node_modules/node-red-contrib-blynk/node_modules/blynk-library/blynk.js:487:17
at Socket. (/home/pi/.node-red/node_modules/node-red-contrib-blynk/node_modules/blynk-library/blynk-node.js:51:7)
at Socket.g (events.js:199:16)
at Socket.emit (events.js:129:20)
at TCPConnectWrap.afterConnect as oncomplete
(node) warning: possible EventEmitter memory leak detected. 11 end listeners added. Use emitter.setMaxListeners() to increase limit.

So it seams you need to do a similar fix with a higher value in max event listeners on ssl connections

regards Toshi

Node-Red crash

I had deployed a number of blynk nodes in node-red and they were all working fine then BOOM node-red crashed I have no idea why but when I try to restart node-red now I get the same error

Welcome to Node-RED

20 Oct 11:07:24 - [info] Node-RED version: v0.11.2
20 Oct 11:07:24 - [info] Node.js version: v0.12.7
20 Oct 11:07:24 - [info] Loading palette nodes
20 Oct 11:07:33 - [info] Settings file : /usr/lib/node_modules/node-red/settings.js
20 Oct 11:07:33 - [info] User directory : /home/pi/.node-red
20 Oct 11:07:33 - [info] Flows file : /home/pi/.node-red/new_file.json
20 Oct 11:07:33 - [info] Server now running at http://127.0.0.1:1880/
20 Oct 11:07:33 - [info] Starting flows
blynk server init f7669ec9296b4ff08b88220a4464df61
New Blynk connection with key f7669ec9296b4ff08b88220a4464df61 false
OnOff mode
Connecting to TCP: cloud.blynk.cc 8442
blynk virtual pin write init 5
20 Oct 11:07:35 - [info] Started flows
20 Oct 11:07:35 - [red] Uncaught Exception:
20 Oct 11:07:35 - Error: getaddrinfo ENOTFOUND cloud.blynk.cc
at errnoException (dns.js:44:10)
at GetAddrInfoReqWrap.onlookup as oncomplete

The only way I can get node-red to run is by using node-red new_file.json to start a new blank canvas, if I then use a blynk node it crashes with above error, so now I cannot use any blynk nodes.

Not reconnecting.

Got latest Node-Red updates yesterday and latest BLYNK node updated. All was fine until this evening - the App said my generic board was not connected. Sure enough I looked into Node-Red and all the BLINK uses were disconnected. A reset of Node-Red and they all came back on. I can only assume it is still NOT recovering from temporary disconnected local Blynk server.

Happy to do any tests.

In editor, set default server value.

Not a bug, more of a suggestion in line with core module behavior. Probably also applies to the websocket version.
In a similar global-config case, in mqtt nodes, the first set up broker is automatically active in all new nodes added from the pallet.
In blynk, even with exactly one server set up, the default value is still Add new blynk-server...

Another cacheing issue

At least I think it is... but firstly - this new node ie the LCD node (I already control the LCD)... is there a description somewhere of what it does? Sorry, might just be me being thick.

Right - to my issue... see the code below - very simple - a single button toggles a control between auto, on and off- and only does it on the downward stroke of the button. On the App is a button and one of those rectangular displays that can show a few characters - ie the result "on", "off" or "auto".

I had this on my main page in Node-Red. I hit control-X to delete it - and went to another page where I now keep all my BLYNK stuff - and PASTED it in. I SAVED everything. I made sure the original was not still there.

When pressing a button (you have to look carefully) I noted that the message was jumping and not in the right order, that is - the symptoms of the function being called TWICE in very quick succession - as if BOTH versions were running.

I checked again that the original was no longer there. I restarted Node-Red. The problem went away.

Pete.

if (msg.payload=="1")
{
switch (context.global.pergola_override)
{
case 2: msg.payload="off"; context.global.pergola_override=1; break;
case 1: msg.payload="auto"; context.global.pergola_override=0; break;
case 0: msg.payload="on"; context.global.pergola_override=2; break;
default: context.global.pergola_override=0; msg.payload="auto"; break;
}
return msg;
}
else
{
switch (context.global.pergola_override)
{
case 0: msg.payload="auto"; break;
case 1: msg.payload="off"; break;
case 2: msg.payload="on"; break;
default: context.global.pergola_override=0; msg.payload="auto";break;
}
return msg;
}

Issue after loss of internet

Here's another issue: can be replicated as follows:
simple node-red flow - inject node with string 101 and blynk write node to v6 value widget , deploy.

remove internet connection to , press inject node , reconnect internet connection , node-red crashes as follows:

24 Oct 21:21:14 - [info] Node-RED version: v0.11.2
24 Oct 21:21:14 - [info] Node.js version: v0.12.7
24 Oct 21:21:14 - [info] Loading palette nodes
24 Oct 21:21:23 - [info] Settings file : /usr/lib/node_modules/node-red/settings.js
24 Oct 21:21:23 - [info] User directory : /home/pi/.node-red
24 Oct 21:21:23 - [info] Flows file : /home/pi/.node-red/new_file.json
24 Oct 21:21:23 - [info] Server now running at http://127.0.0.1:1880/
24 Oct 21:21:23 - [info] Starting flows
blynk server init bla bla
New Blynk connection with key bla bla false
Connecting to TCP: cloud.blynk.cc 8442
blynk virtual pin write init 9
24 Oct 21:21:23 - [info] Started flows
Connected
Authorized
Blynk ready. bla bla
Blynk connect event on node.
input on virtual write
24 Oct 21:22:37 - [red] Uncaught Exception:
24 Oct 21:22:38 - Error: read ECONNRESET
at exports._errnoException (util.js:746:11)
at TCP.onread (net.js:559:26)

Toshi

snip

Wrong credentials

I'm looking for ideas as I don't really know where the problem is.

I installed BLYNK on my Raspberry Pi 2. I have blynk and node-red talking no problem using your excellent nodes... however.... so I started up my local BLYNK server - changed the settings in the APP and registered. Local Blynk accepted that. I made a new app - no problem - with a simple flashing LED - similar to what I have as a test on the real BLYNK server. I put in the new KEY - my local PI address and port 8442. No matter how many times I try this - for the local version, I get the red polo indicator in Node-Red and if I'm running Node-red locally as against a service, so I'm watching it's output - it says "Could not login: INVALID TOKEN". I've checked the key over and over and it's the one I'm being given by the local BLYNK server. Any thoughts?

Bridge node

I wanted to tr the bridge node but I cannot seem to get it to work.
To test a have 2 inject nodes they send 0 / 255 to a bridge node and I have a led on my second project on v0.
In the bridge node I put in the server details of my second project and 0 for virtual pin, when I deploy it says connected but pressing either of the inject nodes 0 or 255 has no effect on the led widget on my second project.

What am I doing wrong ? and what is the Target dialog space for ? also should having a read node on virtual pin 0 in node-red on my second project mirror the led 0 or 255 ?
Please advise
capture

Another uncaught error causing node-red crash

input on virtual write
26 Oct 16:23:18 - [red] Uncaught Exception:
26 Oct 16:23:18 - Error: write EPIPE
at exports._errnoException (util.js:746:11)
at WriteWrap.afterWrite (net.js:775:14)

contrib blynk does not recover if mqtt broker goes down

As title, needed to reboot node-red to fix the issue.

One point because I am testing Node.js version: v0.10.36 re: #18 issue, my mqtt broker is not on the same pi as this node-red instance. I stopped the mqtt broker nothing related to contrib-blynk.

Welcome to Node-RED

5 Dec 22:36:38 - [info] Node-RED version: v0.12.2
5 Dec 22:36:38 - [info] Node.js version: v0.10.36
5 Dec 22:36:38 - [info] Loading palette nodes
5 Dec 22:37:00 - [info] Settings file : /home/pi/.node-red/settings.js
5 Dec 22:37:00 - [info] User directory : /home/pi/.node-red
5 Dec 22:37:00 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
5 Dec 22:37:00 - [info] Server now running at http://127.0.0.1:1880/
5 Dec 22:37:01 - [info] Starting flows
Connecting to SSL: cloud.blynk.cc 8441
Connecting to SSL: cloud.blynk.cc 8441
Connecting to SSL: cloud.blynk.cc 8441
Connecting to SSL: cloud.blynk.cc 8441
5 Dec 22:37:05 - [info] Started flows
5 Dec 22:37:05 - [info] [mqtt-broker:8084e98a.7f7b18] Connected to broker: mqtt://192.168.0.98:1883
Connected
Connected
Connected
Connected
Authorized
5 Dec 22:37:05 - [info] [blynk-server:39b0b4e1.c64f4c] key: Bla bla connected
Authorized
5 Dec 22:37:05 - [info] [blynk-server:c3307c50.3ccf8] key: bla bla connected
Authorized
5 Dec 22:37:05 - [info] [blynk-server:c1c8f31f.3e371] key: bla bla connected
Connecting to SSL: cloud.blynk.cc 8441
Connected
Authorized
5 Dec 22:37:09 - [info] [blynk-server:7f2dce8b.80d23] key: bla bla connected
6 Dec 06:04:10 - [info] [mqtt-broker:8084e98a.7f7b18] Disconnected from broker: mqtt://192.168.0.98:1883
6 Dec 06:04:47 - [info] [mqtt-broker:8084e98a.7f7b18] Connection failed to broker: mqtt://192.168.0.98:1883
6 Dec 06:04:55 - [info] [mqtt-broker:8084e98a.7f7b18] Connection failed to broker: mqtt://192.168.0.98:1883
6 Dec 06:05:14 - [info] [mqtt-broker:8084e98a.7f7b18] Connection failed to broker: mqtt://192.168.0.98:1883
6 Dec 06:05:20 - [info] [mqtt-broker:8084e98a.7f7b18] Connection failed to broker: mqtt://192.168.0.98:1883
6 Dec 06:05:29 - [info] [mqtt-broker:8084e98a.7f7b18] Connection failed to broker: mqtt://192.168.0.98:1883
6 Dec 06:05:44 - [info] [mqtt-broker:8084e98a.7f7b18] Connected to broker: mqtt://192.168.0.98:1883
6 Dec 06:56:33 - [info] Stopping flows <--- Note* left it for 50 minutes before rebooting nr

node-red deploy issue

I have had this problem for about a week now but didn't say anything because I hoped the resolution of #16 may have also resolved this problem but it doesn't...and I am not even sure its a node-red-contib-blynk issue, just wondering if you have any idea what's going on..?

The problem .. I have 4 blynk server connections, when I fully re-deploy node-red, 3 of the servers from connecting to connect take about 2 seconds but the 4th always takes ages like 3-4 minutes, its always the same server connection that has this problem and its every time I deploy nr here's the log:

1 Dec 10:43:16 - [info] Starting flows
Connecting to SSL: cloud.blynk.cc 8441
Connecting to SSL: cloud.blynk.cc 8441
Connecting to SSL: cloud.blynk.cc 8441
Connecting to SSL: cloud.blynk.cc 8441
1 Dec 10:43:46 - [info] Started flows
Connecting to SSL: cloud.blynk.cc 8441
Connecting to SSL: cloud.blynk.cc 8441
1 Dec 10:43:46 - [info] [mqtt-broker:8084e98a.7f7b18] Connected to broker: mqtt://192.168.0.98:1883
Connected
Authorized
1 Dec 10:43:47 - [info] [blynk-server:c1c8f31f.3e371] key: 0cc7 bla bla connected
Authorized
1 Dec 10:43:47 - [info] [blynk-server:39b0b4e1.c64f4c] key: 2972 bla bla connected
Connecting to SSL: cloud.blynk.cc 8441
Connected
Authorized
1 Dec 10:43:49 - [info] [blynk-server:c3307c50.3ccf8] key: f165 bla bla connected
Connecting to SSL: cloud.blynk.cc 8441
Connected
Connecting to SSL: cloud.blynk.cc 8441
Connected

same same repeated for in this case nearly 3 minutes until

Connecting to SSL: cloud.blynk.cc 8441
Connected
Authorized
1 Dec 10:46:11 - [info] [blynk-server:7f2dce8b.80d23] key: adf0 bla bla connected

As you can appreciate its very frustrating having to wait 3-4 minutes for node-red to be working when you are developing a flow,

To ensure its not a problem with my code, I deleted the flow and pasted it into another instance of node-red on a pizero in this case the 3 remaining flows still load within seconds and the flow on the pizero also loads within seconds ...

Its almost like Blynk gets confused/overloaded when connecting to multiple server instances.

Doesn't recover from server down

It SEEMS that the only way this recovers from the Blynk server being temporarily down - is to restart node-red... any chance of working on that?

Using MYSQL DB data for Auth Key

Hi There,
I'm fairly new to Node-Red and was hoping you could help me (I'm not sure where else to go for help and can't find anything on the web to answer my question).

I have a few people whom are using a project in the Blynk app, and each of them have a Hardware Device.

I was looking at routing the data (that is communicated using MQTT for legacy reasons) from their hardware device through to the relevant Blynk App and although I could just use a function in Node-Red, It makes it difficult to add more devices in the future.

I was thinking of having Node-Red run a SQL Query based on the users Hardware ID and retrieve their Auth Key, however, I'm not sure how to set using the Blynk Node this Auth Key as a variable.

Does what I'm trying to say make sense? lol. Is there a Node-Red specific way to do this?

Thanks heaps for your help.

P.S. I love what you've done with the Blynk Nodes and can't wait to see the Websockets version with the same functions. :P

using this node to read values

hello,

can this node allow me to read the values of may gauges .
as my project has two gauges for temperature and Humidity.
i add this node to my node-red and add my running dashboard Token and assign it to read V4 and V5
but i am getting this from debug

msg : Object
{ "pin": "4", "payload": "4", "_msgid": "f3254624.0cdab8" }

also i get that my device not in network notification once node-red connected to the system and the connection return after some time.
any idea can help.

node-red log

Hi tzapu

Regarding node_red-contrib-blink logging, is there anyway to suppress what is logged to the node-red-log, for example I am currently using 35 nodes and the node-red log has a line "input on virtual write" 472,414 times in the last 12 hours in reality it useless info: I would like to see in there when blynk gets authorised and connected etc (with time stamps) and if something goes wrong but a file full of "input on virtual write" with no indication of time/date is pretty un-helpfully and over a week the file will be huge not to mention the stress on the sd card of all these writes.
Thanks as always for you fast responses and commitment despite the teething problems these nodes are superb and in my view a much better/flexible way to use the blynk app.

Regards Toshi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.