Nodejs change property not working and how to read from devices

Hi everyone!

I’ve been recently creating a new dash for my ongoing blynk home automation project (it’s been running now for over three years now) and I’m starting to integrate my computer with it.

I’m running a nodejs script which reads (from now) reads data from the system and display it on the blynk app.

My “problem” is that i’m not able to change widget properties within the code:


var Blynk = require('blynk-library');
const si = require('systeminformation');

var AUTH = 'xxxx';

var blynk = new Blynk.Blynk(AUTH);

var vTemp = new blynk.VirtualPin(1);
var vMem = new blynk.VirtualPin(2);

blynk.on('connect', function() {
  console.log("Blynk ready.");
});
setInterval(function() {
    getTemp()
    getMem()

}, 5000);

function getTemp(){
    si.cpuTemperature()
    .then(tmp=>{
        vTemp.write(tmp.main)
        blynk.setProperty(vTemp,"color","#D3435C")
    });
}

function getMem(){
    si.mem()
    .then(mem=>{
        var used = mem.used
        var total = mem.total
        var percent = used/total*100;
        vMem.write(percent)
    });
}

So, as you can see, in line:

 blynk.setProperty(vTemp,"color","#D3435C")

I pass the pin, the parameter and the blynk red color to the setProperty function, which is on blynk.js source code (@ line 667 btw). and I’m not getting any errors here. Maybe I’m missing something.

Also, would love to know if there is any way for reading data from other devices besides using the bridge functionality.

You could use the API.

Also, have you looked at Node-Red with the Blynk plugin?
Node-Red has its own dashboard as well, but I’m not really a fan of that aspect of Node-Red.

Pete.

but node-red is a graphical “programming” enviroment, right? Don’t looking for a solution like that actually.

when you talk about the api you mean this? https://blynkapi.docs.apiary.io/#

Yes, but it’s more than that. I use it primarily as an integration hub.

Yes.

Pete.

1 Like

Thanks Pete,

I was reading your linked topic about your proyects, looks really interesting and I’d take a depper look at it.