parnic / node-screenlogic

Pentair ScreenLogic Javascript library using Node.JS
https://www.npmjs.com/package/node-screenlogic
MIT License
52 stars 14 forks source link

Calling getPumpStatus() is timing out. #45

Closed tjblevins closed 3 years ago

tjblevins commented 3 years ago

Hi Parnic, I have created a REST webservice using your Library and I love it!

Recently, I have been asked to expand to capture more Pump info and I noticed you added Pump Functions to the library.

I created a copy of example.js and added the get getPumpStatus(). It seems to be timing out on that one function.

Any ideas?

}).on('saltCellConfig', function(saltCellConfig) { this.getControllerConfig(); console.log(' salt cell installed=' + saltCellConfig.installed); //Adding Pump }).on('pumpStatus', function(pumpStatus) { this.getPumpStatus(0); console.log(' Pump Status =' + pumpStatus.isRunning); //Pump End }).on('controllerConfig', function(config) { console.log(' controller is in celsius=' + config.degC); client.close();

parnic commented 3 years ago

Several things jump out at me, but it's hard to say what exactly your problem is based on the partial code you've provided.

The main, most likely, issue is that the event is named getPumpStatus, not pumpStatus. However, the code you provided doesn't ever appear to be calling getPumpStatus() anywhere except in response to a pumpStatus event, which won't ever get hit. If you'd like to provide a full gist of or link to your code, I'd be happy to help further, but right now it looks like you've just got the wrong event name.

By the way, if you set the environment variable DEBUG to sl:*, you can see behind-the-scenes of what the library is doing. It's likely that it's emitting logs of some kind about the event that's firing, but since you never capture the event, your calling code seems to hang, waiting for an event that will never come.

tjblevins commented 3 years ago

Sorry you are correct I messed up when I adding the call to getPumpStatus(), thanks for pointing that out. I fixed that Screen Shot 2020-10-06 at 1 11 49 PM Screen Shot 2020-10-06 at 1 12 45 PM

I am getting an error now...

parnic commented 3 years ago

Does that error happen immediately or after some delay? You're still not hooking the correct event name (getPumpStatus), so an ECONNRESET would indicate that the connection is resetting due to, perhaps, a timeout.

tjblevins commented 3 years ago

Sorry... I am such an idiot. It was the event. I must have been drunk when I was typing that and even missed it again after you pointed it out earlier. Sorry... works like a champ now. image