Button press Duplicates write NodeJS

I am finding that that any button in the blink app is writing twice to my webserver. When i set the button to push button, i get four state outputs(two times 1, and two times 0).
Rpi running nodejs server, ethernet
Samsung Galaxy S10 Android 9.0
• Blynk server
• Blynk Library version 0.5.4

var Blynk = require('blynk-library');
var AUTH = '%TOKEN%';
var blynk = new Blynk.Blynk(AUTH);

var v1 = new blynk.VirtualPin(3);

v1.on('write', function(param) {

[ ‘1’ ]
[ ‘1’ ]
[ ‘0’ ]
[ ‘0’ ]
[ ‘1’ ]
[ ‘1’ ]
[ ‘0’ ]
[ ‘0’ ]

Assistance would be appreciated.

Each Button widget action (press or release) triggers the Blynk function, so you need extra code to differentiate between the press and the release.

v1.on('write', function(param) {
if (param == 1) {  // If Button ON
		// Do ON stuff
        console.log("Button Pressed")
		} else  if (param == 0) {  // If Button OFF
		     // Do OFF stuff
             console.log("Button Released")

As for the “duplication” of each action… your code shows no reason for it, so no idea.

BTW, How are you connecting to your Local Server with that code?

Or have you manually edited your library?

This is merely a snippet of my code. i do call the blynk library prior to this.

Thanks for the reply.

I will apply this going forward. However the duplication of [1] or [0] is where my issue comes in. As you’ve stated, this is not happening on my server, as it is a state returned from the app on my phone.

In order to narrow down this issue’s scope, you will need to do more tests on your end to see if this duplication is consistent across other sketches, applies with only some or with ALL control widgets, etc.

I have created a new sketch from scratch. I have tried both the plain and styled button. I have changed both buttons from push to switch. I have also changed the virtual pin used.

All of the above renders the same result.

I recommend testing with other libraries like the primary C+ with Arduino/ESP and Python on the RPi.

Then determine if this issue only occurs when using the NodeJS library? If so, then the only other thing I can suggest is to search for and remove all instances (in case you have it installed multiple times) and do a clean reinstall. You may have to Google how to do this on the RPi as I don’t recall the commands :innocent: But I do recall needing to search for the file blynk-node.js to see where it resided… this is how I determined I had multiple copies at one time (but not your issue)