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

getNumPumps() returns number of available pump slots, not actual number of pumps #58

Closed michaelmaston closed 2 years ago

michaelmaston commented 2 years ago

As always, thanks for this work!

On my system I have one filter pump configured in the controller and it has pump circulation settings for the pool and spa set for it. If you call getNumPumps() you (at least I) get 8 back always as the result. Looking at the data coming back from the controller and adding a phantom 2nd pump to see how the data changed, I believe I see where the issue is. Currently the code in getNumPumps() loops through the 45 byte record for each pump record and checks the 3rd byte in the array to see if it's non-zero. For me this value is always 2 no matter what I do so every record in the list (all 8) are seen as a pump and the counter incremented.

Looking at the data, particularly the first 3 bytes of each 45 byte record, I get the following for the first record (where my IntelliFlo VSF pump is):

0x40, 0x0,0x2

For all the remaining records where I have no pump, each one starts with:

0x0,0xF,0x2

When I created my phantom pump, only byte 0 changed, depending on what pump type I chose in SLConfig. Byte 1 and 2 didn't change from 0xF and 0x2. Not sure what byte 1 represents but given it's 0 for my real pump and 0xF for the phantom one, it's probably some sort of status about the pump that the controller can't get from my fake pump.

Byte 0 took the following values: 0 = None selected in SLConfig for pump type 0x6 = IntelliFlo VF 0x40 = IntelliFlo VSF 0x80 = IntelliFlo VS

So I think the code in getNumPumps should be looking at byte 0 rather than byte 2 for whether there's a pump there (unless it is really intended to return the number of potential slots vs. actual pumps). The values for the various pump models shown above don't seem to match the values returned by the GetPumpStatus msg but my VSF reports 3 so I think that mapping is accurate otherwise. The values above for pump type track repeatedly to what is set in SLConfig.

Can anyone confirm that they get 8 pumps from getNumPumps()? I don't see a way to get rid of the unused pump slots so I assume that the controller just always has 8 slots no matter how many pumps you may actually have and you have to see if a pump is actually set for that slot before counting it.

parnic commented 2 years ago

Yeah, this message is still undocumented for a lot of reasons ;).

My system returns 2 pumps from getNumPumps() (which is accurate). I have 2 IntelliFlo VS pumps, byte 0 is 128, byte 45 is 128, and bytes 90-350 are all 0.

But yeah, feel free to open a PR to improve this message. Maybe some day we can get it all figured out and add it to the documentation.

parnic commented 2 years ago

What is your system firmware version? I've got an EasyTouch 2 8, firmware 2.140, adapter version 5.2 build 738.

michaelmaston commented 2 years ago

Interesting. On my system bytes 90-360 have non-zero data in them (the first 3 bytes as I mentioned as well as pump circulation data that is not zero (but default values of some sort)). As you say, lots of mysterious stuff in there. That makes me think that there's a way to delete unused pump records so that that data is zeroed out vs. having defaults. But I think the fact you get the right number is a fluke of the way your system is set up as the third byte in each record is only set for the actual pumps you have but I don't think that particular byte is meant to indicate a pump is there. If you went into SLConfig it would be interesting to see if you only have 2 pumps showing there. I have 8 but only the first is populated. All of it was set up by my pool builder and I haven't wanted to mess with it too much.

I think the improvement would be to use byte0 in each record as the way to know if a pump is configured rather than byte 2. As the pump type is already determined elsewhere and seems to be reporting correctly, I don't think leveraging that info that comes back is helpful as it is repetitive and has different values representing the different models.

If you agree I can do a PR for that.

Thanks!

parnic commented 2 years ago

Sure, that would be fine.

michaelmaston commented 2 years ago

What is your system firmware version? I've got an EasyTouch 2 8, firmware 2.140, adapter version 5.2 build 738.

IntelliTouch i9+3 Firmware 1.180 Adapter Ver 5.2 Build 736.0

I believe there is 1.190 for my IntelliTouch, not sure about the adapter having an update. So far I've left all as it was installed.

parnic commented 2 years ago

TIL this library works with an IntelliTouch system 😄

Could explain the difference in bytes.

michaelmaston commented 2 years ago

Yep, works great. It might explain it. Perhaps they keep the same message format but limit the maximum pumps? I don't know much about the different controller products capabilities but if EasyTouch allows max 2 pumps that would add up.

parnic commented 2 years ago

You are probably right about that. I had never checked before, but my slconfig app indeed only offers me two pump slots right now.