parnic / node-screenlogic

Pentair ScreenLogic Javascript library using Node.JS
https://www.npmjs.com/package/node-screenlogic
MIT License
53 stars 15 forks source link

Talking to screen logic #1

Closed tielur closed 6 years ago

tielur commented 6 years ago

Hey there, I'm not sure if you want to have discussions like this over GitHub issues or else where but let me know if this should be some where else.

I recently had a new pool installed that has a pentair screen logic, intellibrite( lights ), intellichem and I also have my backyard lights wired into a relay.

I'd love to be able to talk to the system to both read and change state ( turning off water features, turn on lights, turn on the high speed circuit...ect)

Ideally I would be able to integrate into into my home automation (https://www.home-assistant.io/).

So questions:

  1. I see that I can read a bunch of data but am I able to turn on circuits?
tielur commented 6 years ago

I was able to answer this myself. I can turn on circuits via the new setCircuitState command. The only hangup I had was that the controllerId I was getting back from the status is 100 but I needed to use 0. Otherwise that works well.

Thanks!

parnic commented 6 years ago

Sorry, I didn't see a notification come in for this issue. Yeah I'm slowly making progress on building the library and adding "write" controls. Glad to hear the new circuit state stuff worked for you!

tielur commented 6 years ago

Yea it's working well, I was able to get the pool temperature into my home assistant and the ability to turn on or off my pool lights and landscape lights.

iDevo commented 6 years ago

Hi @tielur Can you share some information how you added your pentair screen logic to HomeAssistant with this great plugin? I'd love to control the basics like light, jets or even the temperature using HomeAssistant. Thank you both so much!

dustinww commented 5 years ago

Just wondering if this is still being worked on.? I'd love to be able to get my pool connected to my Home Assistant.

krk628 commented 5 years ago

I have HA talking to pentair via the Screenlogic interface: turn on/off pool/spa/cleaner, feed pool and spa temp into sensors, etc. It's a hack as nodejs is doing the heavy lifting bit it works. What is your setup?

dustinww commented 5 years ago

Sounds like you've got the same setup. I've got a Home Assistant system setup and have a Pentair Screenlogic connected to the pool and online. I don't know how to build the driver or interface or whatever you call it for the HA to talk to the node. Any direction would be appreciated. Thanks

On Sun, Feb 17, 2019, 11:30 AM krk628 <notifications@github.com wrote:

I have HA talking to pentair via the Screenlogic interface: turn on/off pool/spa/cleaner, feed pool and spa temp into sensors, etc. It's a hack as nodejs is doing the heavy lifting bit it works. What is your setup?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/parnic/node-screenlogic/issues/1#issuecomment-464484883, or mute the thread https://github.com/notifications/unsubscribe-auth/AHjLpm1nnxEU73WbUJtVba0VRsulMh4jks5vOZHFgaJpZM4TcXD6 .

krk628 commented 5 years ago

No problem, just give me till Tuesday...traveling at the moment. Tell me what operating system you are running in the meantime. Running Ubuntu or raspian or what?

parnic commented 5 years ago

Afraid I can't be any help. I don't use Home Assistant.

dustinww commented 5 years ago

I all using hass.io so I don't know if there is any way to get to the OS. I do have samba and ssh access and a number of other RPI devicesthat have rasbpian installed, so I could use one of those if I don't need it to be on the local HA device.

On Sun, Feb 17, 2019, 1:20 PM krk628 <notifications@github.com wrote:

No problem, just give me till Tuesday...traveling at the moment. Tell me what operating system you are running in the meantime. Running Ubuntu or raspian or what?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/parnic/node-screenlogic/issues/1#issuecomment-464497525, or mute the thread https://github.com/notifications/unsubscribe-auth/AHjLpmWwrIb3pKOkOfQm2S6nsXUlBvu0ks5vOaubgaJpZM4TcXD6 .

krk628 commented 5 years ago

I'll post what I do on Tuesday but you'll have to install nodejs on one of those raspians and then use SSH to get from your hassio to the other Pi. Straightforward really

sergeleo commented 5 years ago

I've been looking into this, tested this code and it works, drawback, it must run on your home network to be able to discover ScreenLogic interface, so you must run service inside of your home network and then create proxy API for HA consumption and make it available though internet. I was thinking to create a skill for Google Assistant, but since there a lot of dependencies on home network setup, it will not be a repeatable solution. I know that Pentair has internet facing APIs that ScreenLogic app consumes, but I wasn't able to find it.

parnic commented 5 years ago

@sergeleo I hadn't gotten around to implementing the internet part since I didn't need it. I'd gladly accept a pull request for that. It requires the Pentair server, your device's ID, and a light encryption routine that can be pulled from the official Android app.

sergeleo commented 5 years ago

@sergeleo I hadn't gotten around to implementing the internet part since I didn't need it. I'd gladly accept a pull request for that. It requires the Pentair server, your device's ID, and a light encryption routine that can be pulled from the official Android app.

Do you happen to know Pentair server details and APIs?

parnic commented 5 years ago

@sergeleo I pulled this app code from the Android app. I'd have to do the same thing for internet connectivity. I don't have it already ready.

sergeleo commented 5 years ago

@sergeleo I pulled this app code from the Android app. I'd have to do the same thing for internet connectivity. I don't have it already ready.

Feel free to share it with me, I'd like to take a look at the code and see what they are doing, maybe I will be able to replicate that.

pgregg88 commented 5 years ago

Gent's, I too have HA (Hass.io on RPi), Pentair, screenlogic, etc. I'm looking for the same solution and I'm happy to contribute. My code skills are limited, but I know Linux, familiar with node.js, very strong with HA, networking and I'm an excellent troubleshooter.

I was about to pull the trigger on https://github.com/tagyoureit/nodejs-poolController and go straight to the serial connection before a ran across this gem. Please keep me posted. Happy to assist.

parnic commented 5 years ago

Here's the official Android app decompiled: https://www.mediafire.com/file/z2bteu3dunh6wm5/com.app.pentair.zip/file

sergeleo commented 5 years ago

Here's the official Android app decompiled: https://www.mediafire.com/file/z2bteu3dunh6wm5/com.app.pentair.zip/file

Excellent! Thank you. Looking into this.

parnic commented 5 years ago

https://gist.github.com/de92ddc5e3dcd55ebed193167c26fa14

This is an attempt at remote logins using C# 7.3 on .net core 2.2. It finds the device from the internet, connects to it, and goes through the initial connection process. When it tries to send the password, it gets rejected. I don't know why yet, but am still looking into it. I assume the encryption routine didn't cleanly decompile. I also don't know what happens if your system has no password.

Once this is all working I will port it to js for this library.

Edit: gist updated with successful remote connection code. I made a dumb mistake. Will continue working on this.

krk628 commented 5 years ago

@dustinww So yeah...the hassio is a bit of a rub as it doesn't support the command_line sensor or switch. Ideally you'd want a custom hass.io addon w/nodejs and mqtt so you can bridge this code into HA. i can probably whip something up but it'll take a week. Can you confirm this code can see your Pool in the meantime? (do this on a raspian that's on the network w/your screenlogic controller)

sudo apt-get install -y nodejs npm cd /var/tmp git clone https://github.com/parnic/node-screenlogic.git cd node-screenlogic.git npm install smart-buffer node ./example.js

it should give you the details on your pool like so...

[root@home node-screenlogic]# node example.js version=POOL: 5.2 Build 736.0 Rel pool ok=1 pool temp=51 air temp=54 salt ppm=0 pH=0 saturation=0 spa active=false pool active=true calcium=0 cyanuric acid=0 alkalinity=0 salt cell installed=false controller is in celsius=false

krk628 commented 5 years ago

@dustinww if you want to help test this below it might work for you. it should get your pentair circuit/temperature state and let you control your pool and spa pump.

https://github.com/krk628/hassio-screenlogic-addon 2019-02-20 19_13_33-home assistant

dustinww commented 5 years ago

Great, I'll check it out tomorrow and let you know how it goes.

pgregg88 commented 5 years ago

@krk628 I had partial success.

  1. I followed your instructions and successfully connected to my SL controller from Raspi with node.js
  2. I added the referenced switches and sensors into the appropriate HA .yaml files on my hassio instance.
  3. I successfully cloned and installed your Pentair Local Add-on within HA.
  4. I can view the new mqtt queues (/pentair/pooltemp/state, etc.) and they are receiving frequent messages. Sweet!

However, I'm failing to pick up the sensors within HA.

Historically, I've been bypassing the internal HA broker and using an external MQTT broker. I glanced through your code, but didn't see an obvious way to reference an external mqtt broker.

I did a quick test of removing my external mqtt broker config and enabling the HA local broker. No luck. I suspect I've overlooking something simple. I'll take another run at it tomorrow after some sleep.

The hard parts are working! Thanks for getting this rolling.

krk628 commented 5 years ago

@pgregg88 @dustinww hey guys; if you can pick up here that would probably be best: https://github.com/krk628/hassio-screenlogic-addon/issues/1

parnic commented 5 years ago

@sergeleo I've added remote + password support in v1.2.0

tomblevins commented 4 years ago

@parnic First I want to say I love this Library! totally awesome. Not sure if this is where I should be posting this but I was wondering about a Set Control for the Salt Cell Output. You wouldn't happen to have that on your near roadmap, by chance? I have both an IntelliChem and an IntelliChlor. I have noticed that the IntelliChem control for my SaltCell isn't very intelligent. It's set up so that if the SaltCell can't keep up with the Chlorine output then it adds Chlorine from the tank. The issue is that it doesn't just attempt to increase the Setting on the Salt Cell first. The problem is that I don't find out that the salt cell is set too low until I get an error that my ORP Tank is empty... I am feeding ORP Stats into an AI now using your library (Awesome)! and I would like that system to be able to control my SaltCell based on the results. Was just wondering if you had that coming by chance.

parnic commented 4 years ago

@tomblevins feel free to open a new issue for that. I don't know if there's an existing api to control salt cell output but I can look into it. I have the same experience as you (IntelliChem doesn't do an awesome job of keeping the intellichlor running at an appropriate level).