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

Integration with nodejs-poolController #61

Closed tagyoureit closed 1 year ago

tagyoureit commented 1 year ago

Hey @parnic! This is long overdue, but I'm finally at a place where I can integrate direct Screenlogic control into nodejs-poolController. I've been wanting to dig into this for quite a while.

To that end, I've gone through and converted all of your code to Typescript + Promises. It still supports the events, too. I've published this up to my repo at https://github.com/tagyoureit/node-screenlogic/tree/typescript. I've changed quite a bit (event names, data structure, return values, etc etc). I can keep this as a separate repo if that makes more sense. I haven't updated the docs yet but the example.ts shows how to use all of the methods.

First question is whether or not you are ok with moving to Typescript + Promises or you would rather keep the plain 'ole Javascript.

Second question is do you have any bandwidth to flush out more of the commands?

I'll also be able to help debugging/decoding many of the other aspects as I've got in-depth knowledge of how the RS485 packets work.

I've got a short list of items that I've compiled so far, but haven't gone through everything to validate it yet. Need to put it through a fine tooth comb.

  1. Equipment config - I see you have a separate thread on this... will try to dig into what I can find.
  2. Do you know how often a ping needs to be sent to keep a connection to the server?
  3. What's the difference between the clientId and senderId?
  4. I'm getting bad parameters trying to run the following: set circuit state, set circuit run time, delete schedule by id, set schedule
  5. 12504 is async message that the intellibrite is changing colors (~16s)
  6. I have not yet tested the local connection; I'm currently working remotely and also need to replace a fried chip on my transceiver
tagyoureit commented 1 year ago

Hey, I'm real close. Curiosity got the best of me and I got proficient at using Wireshark to help decode some more packets. I couldn't just leave the configuration side alone so I've been adding a few more API's (get circuit name, set circuit names, and more). I've also decoded quite a bit more of the Equipment Configuration packet (12566) and the final part is setting the equipment configuration (12568) back to the controller

parnic commented 1 year ago

Awesome, sounds super useful!

tagyoureit commented 1 year ago

Can you give the latest code a try? Specifically the "set equipment" message. Pull both njsPC and the new node-screenlogic code with the method I outlined above (https://github.com/parnic/node-screenlogic/issues/61#issuecomment-1356326406)

I have it set so it's not actually wired up to change anything on the OCP, yet. I just have a flag set because I don't want to mess anything up due to a lack of testing. (See below.)

If you startup the app with the DEBUG=sl* you will see the same types of debug code that you previously used.
The following are the items which can be set via ScreenLogic and the config packet. Some of them we don't really handle today in njsPC and I'll note that below:

When you run the code you'll see the debug statements as below. It is indicating which bit in which array is changing.

sl:unit Difference at miscData[4]. prev: 0 (00000000)-> new: 1 (00000001) +0ms

If/when you want to try changing actual values, do the following:

  1. take screenshots of EVERY page/option/button/etc in screenlogic. I'm pretty sure I won't be arbitrarily changing anything but best to be safe. (No bits will be changed that are not affected.)
  2. if node-screenlogic/dist/index.js#1153 you can change the let ready=false; to be true; This will send the command to the screenlogic unit. (This file is the compiled version.)

lmk if you have any questions.

parnic commented 1 year ago

I think we're all set here? Let me know if that's not the case.