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

Unable to set salt level for pool or spa individually #42

Closed bwoodworth closed 4 years ago

bwoodworth commented 4 years ago

The setSaltCellOutput function sets the pool and spa levels so you can't just send one level. Would it be possible to either create distinct functions for pool and spa or add the ability to pass null values to the existing function like this:

exports.SLSetSaltCellConfigMessage = class SLSetSaltCellConfigMessage extends SLMessage {
  constructor(controllerIndex, poolOutput, spaOutput) {
    super(0, MSG_ID);
    this.controllerIndex = controllerIndex;
    if(poolOutput != null){
      this.poolOutput = poolOutput;
    }
    if(spaOutput != null){
      this.spaOutput = spaOutput;
    }
  }
  encode() {
    this.writeInt32LE(this.controllerIndex || 0);
    this.writeInt32LE(this.poolOutput || 0);
    this.writeInt32LE(this.spaOutput || 0);
    this.writeInt32LE(0);
    this.writeInt32LE(0);
    super.encode();
  }
  static getResponseId() {
    return MSG_ID + 1;
  }
};

I'm not sure how the messages are sent to SL so this might not be possible, but it would make sense to allow just setting one at a time.

parnic commented 4 years ago

I don't have the ability to change things on the ScreenLogic side, so no, this is not possible. The message that gets sent to SL must have both pool and spa specified.

You can emulate this on your side by first getting the salt cell levels with getSaltCellConfig(), then using the existing level1 or level2 values in that message to pass along for pool or spa, respectively.

bwoodworth commented 4 years ago

Thanks. We must work within the SL constraints.