Closed bwoodworth closed 4 years ago
When I call getPumpStatus(pumpID) I get the same values coming back regardless of the pumpID I use. It is possible I am doing something wrong.
So, your example code is making some incorrect assumptions about how javascript/node work. The program doesn't execute in order like that, at least not the way you're expecting. This:
.on('getPumpStatus', function(status) {
...
})
is registering a callback for the getPumpStatus
event. So your code is registering callbacks for that same event over and over again. I don't honestly know how js/node handles this, but I believe only one of those will actually "win" in the end. The example code in the repo is hooking a bunch of unique events, and when each one is called it calls a function which will fire a different event. That's why the example code functions the way it does.
For your case, you'd want some variable external to the .on()
chain that tracks which pump you've called for the pump status of, then increment it when you get the event and call the same function with the new id for however long is appropriate.
Does that help?
Also, how many pumps does ScreenLogic support?
I believe the answer is 8, but I don't know this for sure off the top of my head.
Is there any way to see how many pumps are installed
You can check how many pumps are in your system a few different ways:
getEquipmentConfiguration()
function will fire the equipmentConfiguration
event and pass an object which contains a member function getNumPumps()
pumpCircArray
member of the object passed by getControllerConfig()
/ the controllerConfig
event and see how many indices are not 0.Note that calling getPumpStatus()
with an invalid pump id will fire the badParameter
event, so if you don't have that hooked your program will probably appear to hang.
with pumpIDs or do we just need to iterate through them to get details?
Pump IDs, in my experience, start at 0 and go up 1 for each pump in the system. The aforementioned pumpCircArray
will have non-zero values in each index that has a pump. I don't know what the non-zero numbers represent, though.
This library uses the debug library, so you can define DEBUG=sl:*
in your environment before running example
to get more information about what's going on, if that helps.
When I call getPumpStatus(pumpID) I get the same values coming back regardless of the pumpID I use. It is possible I am doing something wrong. Here is my example:
function connect(client) { client.on('loggedIn', function() { this.getVersion(); }).on('version', function(version) { this.getSaltCellConfig(); }).on('saltCellConfig', function(saltCellConfig) { this.getPumpStatus(0); console.log('pentair/saltcellstatus/state,' + saltCellConfig.status); console.log('pentair/saltcelllevel1/state,' + saltCellConfig.level1); console.log('pentair/saltcelllevel2/state,' + saltCellConfig.level2); }).on('getPumpStatus', function(status) { this.getPumpStatus(2); console.log('pentair/pump/0/watts/state,' + status.pumpWatts); console.log('pentair/pump/0/rpm/state,' + status.pumpRPMs); console.log('pentair/pump/0/gpm/state,' + status.pumpGPMs); }).on('getPumpStatus', function(status) { this.getPumpStatus(3); console.log('pentair/pump/2/watts/state,' + status.pumpWatts); console.log('pentair/pump/2/rpm/state,' + status.pumpRPMs); console.log('pentair/pump/2/gpm/state,' + status.pumpGPMs); }).on('getPumpStatus', function(status) { this.getPumpStatus(4); console.log('pentair/pump/3/watts/state,' + status.pumpWatts); console.log('pentair/pump/3/rpm/state,' + status.pumpRPMs); console.log('pentair/pump/3/gpm/state,' + status.pumpGPMs); }).on('getPumpStatus', function(status) { this.getPumpStatus(5); console.log('pentair/pump/4/watts/state,' + status.pumpWatts); console.log('pentair/pump/4/rpm/state,' + status.pumpRPMs); console.log('pentair/pump/4/gpm/state,' + status.pumpGPMs); }).on('getPumpStatus', function(status) { this.getPumpStatus(6); console.log('pentair/pump/5/watts/state,' + status.pumpWatts); console.log('pentair/pump/5/rpm/state,' + status.pumpRPMs); console.log('pentair/pump/5/gpm/state,' + status.pumpGPMs); }).on('getPumpStatus', function(status) { this.getPumpStatus(7); console.log('pentair/pump/6/watts/state,' + status.pumpWatts); console.log('pentair/pump/6/rpm/state,' + status.pumpRPMs); console.log('pentair/pump/6/gpm/state,' + status.pumpGPMs); }).on('getPumpStatus', function(status) { this.getPumpStatus(1); console.log('pentair/pump/7/watts/state,' + status.pumpWatts); console.log('pentair/pump/7/rpm/state,' + status.pumpRPMs); console.log('pentair/pump/7/gpm/state,' + status.pumpGPMs); }).on('getPumpStatus', function(status) { this.getPumpStatus(8); console.log('pentair/pump/1/watts/state,' + status.pumpWatts); console.log('pentair/pump/1/rpm/state,' + status.pumpRPMs); console.log('pentair/pump/1/gpm/state,' + status.pumpGPMs); }).on('getPumpStatus', function(status) { console.log('pentair/pump/8/watts/state,' + status.pumpWatts); console.log('pentair/pump/8/rpm/state,' + status.pumpRPMs); console.log('pentair/pump/8/gpm/state,' + status.pumpGPMs); client.close(); });
Also, how many pumps does ScreenLogic support? Is there any way to see how many pumps are installed with pumpIDs or do we just need to iterate through them to get details?