parnic / node-screenlogic

Pentair ScreenLogic Javascript library using Node.JS

Home Page:https://www.npmjs.com/package/node-screenlogic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Server crashes out

jiggi21 opened this issue · comments

Firstly, thank you so much for this code. I have set everything up and I am assuming that I run example.js? When i run it, it does connect to my unit but then exits with: controller is in celsius=false because of the client.close(). How do I keep this running? If I comment out that line, it runs for a little while and then crashes after a few seconds with:
Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:111:27)
Emitted 'error' event at:
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
at process._tickCallback (internal/process/next_tick.js:63:19)

The example script is there to show you how to code against this library. It's not intended to run forever. You'd need to write your own script for that.

The ScreenLogic device cannot run with a continuous connection itself, so you'd need to write a loop of some sort that queried the pool equipment however frequently you wanted it to.

The ScreenLogic device cannot run with a continuous connection itself, so you'd need to write a loop of some sort that queried the pool equipment however frequently you wanted it to.

Could you give me some examples of this? I have tried a bunch of things but none of them work

The ScreenLogic device cannot run with a continuous connection itself, so you'd need to write a loop of some sort that queried the pool equipment however frequently you wanted it to.

Could you give me some examples of this? I have tried a bunch of things but none of them work

If you can provide more info about what you've tried, perhaps. This isn't really a node.js support board, but conceptually, you would be looking for something that just ran on a loop. This would request and print pool status every 5 seconds forever.

const ScreenLogic = require('./index');

let x = function() {
  var finder = new ScreenLogic.FindUnits();
  finder.on('serverFound', function(server) {
    finder.close();
    connect(new ScreenLogic.UnitConnection(server));
  });

  finder.search();

  function connect(client) {
    client.on('loggedIn', function() {
      this.getPoolStatus();
    }).on('poolStatus', function(status) {
      console.log(' pool ok=' + status.ok);
      console.log(' pool temp=' + status.currentTemp[0]);
      console.log(' air temp=' + status.airTemp);
      console.log(' salt ppm=' + status.saltPPM);
      console.log(' pH=' + status.pH);
      console.log(' saturation=' + status.saturation);
      console.log(' spa active=' + status.isSpaActive());
      console.log(' pool active=' + status.isPoolActive());
      client.close();
    });

    client.connect();
  }
}

setInterval(x, 5000);
x();