Plugin: nodejs-poolController Pi for Swimmin Pools

Posted on
Sun Nov 21, 2021 8:27 am
ar26pt2 offline
Posts: 25
Joined: Jan 23, 2014

Plugin: nodejs-poolController Pi for Swimmin Pools

I recently set up a raspberry pi with nodejs-poolController and nodejs-poolController-dashPanel to control my Pentair EasyTouch panel. It seems to work pretty well. I did this because my Autelis device is fairly old and for some reason I can't get it do receive an IP from my new router. Also autelis now looks fairly unsupported and new devices not available. This implementation needs a raspberry pi and a cheap usb to serial adapter. It claims to support a wide variety of pool hardware, even standalone equip.

https://github.com/tagyoureit/nodejs-poolController

There are some other home automation system interfaces made for this raspberry solution already (vera, hubitat, homebridge). Maybe someone more clever than me could try this for their system and make an Indigo plugin ? the nodejs-poolController has a simple url based API that lets you query device state and interact. Next I was going to write some python scripts to parse that data so I can use indigo (that's pretty much what i did with the autelis device anyway). Presently it looks like the nodejs-poolController has no authentication btw.

Thanks for the time!
ar

Posted on
Tue Nov 23, 2021 8:16 pm
jltnol offline
Posts: 989
Joined: Oct 15, 2013

Re: Plugin: nodejs-poolController Pi for Swimmin Pools

wish I was better with all the tech stuff like this. I have an Easy Touch panel and thought I could hook it up to indigo, but nothing worked with my particular pool panel. Might look into this after the holidays. I already have a RaspberryPi.

Posted on
Sun Nov 28, 2021 2:15 pm
ar26pt2 offline
Posts: 25
Joined: Jan 23, 2014

Re: Plugin: nodejs-poolController Pi for Swimmin Pools

Python Example interacting with server JSON's: Python 2.7
For those n00bs wanting to try things out, here are scripts I have written to let indigo communicate with the PoolController raspberry server. I import some key data from the poolcontroller into variables. Second example below pushes commands. My self taught coding etiquette is pretty raunchy, please withhold criticism.

Code: Select all
indigo.server.log('Performing routine query for Pool status', type='njs-Pool')

import urllib, datetime, json, time
errr='no rPi pool server errors' #using a variable to try and track pool controller errors
er='False'

#CIRCUITS
try:
 jfile = urllib.urlopen('http://192.168.X.X:4200/state/circuits/') #replace the Xs with your proper local ip
 jfile=jfile.read()
 jfile_dict=json.loads(jfile) #this particular circuits json lists the circuits in order as an array I had to read the output and determine which of my circuits is which
 circ0=jfile_dict[0]['isOn']
 circ1=jfile_dict[1]['isOn']
 circ2=jfile_dict[2]['isOn']
 circ4=jfile_dict[4]['isOn']
 indigo.variable.updateValue('pCircuitMed', str(circ0))
 indigo.variable.updateValue('pCircuitCleaner', str(circ1))
 indigo.variable.updateValue('pCircuitHi', str(circ2))
 indigo.variable.updateValue('pCircuitPool', str(circ4))
 if str(circ0)+str(circ1)+str(circ2)+str(circ4) == 'FalseFalseFalseFalse': circ='False' #Some logic to determine all my circuits are off and therfore the pool is totally off
 else: circ='True'
 indigo.variable.updateValue('pCircuitANY', str(circ))

except:
 indigo.server.log('Could not access circuits JSON from 192.168.X.X:4200', type='njs-Pool', isError=True)
 errr='/circuits '
 er='True'


#TEMPS
try:
 jfile = urllib.urlopen('http://192.168.X.X:4200/state/temps/') #again update the Xs with your ip
 jfile=jfile.read()
 jfile_dict=json.loads(jfile)
 Tair=str(jfile_dict['air'])
 Twater=str(jfile_dict['waterSensor1'])
 indigo.variable.updateValue('pTempAir', Tair)
 indigo.variable.updateValue('pTempWater', Twater)

except:
 indigo.server.log('Could not access temps JSON from 192.168.X.X:4200', type='njs-Pool', isError=True)
 errr=errr+'/state/temps '
 er='True'

#CHLORINATOR
try:
 jfile = urllib.urlopen('http://192.168.X.X:4200/state/chlorinator/1/')
 jfile=jfile.read()
 jfile_dict=json.loads(jfile)
 Cpct=str(jfile_dict['targetOutput'])
 Csalt=str(jfile_dict['saltLevel'])
 Cstatus=str(jfile_dict['status']['desc'])
 if Cstatus=='Communication Lost': er='True'
 Coutput=str(jfile_dict['currentOutput'])
 ClastComm=(jfile_dict['lastComm'])/1000
  Ctime=(datetime.datetime.fromtimestamp(ClastComm)-datetime.timedelta(hours=5)).strftime("%Y-%m-%d %H:%M:%S")
 now=time.time()
 since=now-ClastComm #trying to trap whether the update from the server is recent, in my case ive had my chlorinator off for a week now and want to indicate that the update on the server is dated
 if since>600:
  pChlorOK='False'
  er='True'
 else: pChlorOK='True'
 indigo.variable.updateValue('pChlorComm',str(Ctime))
 indigo.variable.updateValue('pChlorOK',pChlorOK)
 if circ4=='True': indigo.variable.updateValue('pChlorPct', Cpct) #for some reason the data for chlorinator setting is 0 if the pool circuit is OFF
 indigo.variable.updateValue('pSalt', Csalt)
 indigo.variable.updateValue('pChlorStatus', str(Cstatus))
 indigo.variable.updateValue('pChlorOutput', str(Coutput))

except:
 indigo.server.log('Could not access chlorinator JSON from 192.168.X.X:4200', type='njs-Pool', isError=True)
 errr=errr+'/state/chlorinator/1'
 er='True'

indigo.variable.updateValue('pErrorJSONserver', errr)
if er=='False':er='True' #after i wrote i decided i wanted to flip logic on my anyerror variable-so now i have an AllOK variable that is false when there is error
else: er='False'
indigo.variable.updateValue('pAllOK', er)


And an example of pushing a command from python script to the poolController server...
This one turns CIRCUIT 6 on, which is my my master pool circuit. I have made action groups for various circuit commands and then can use these in control pages, virtual devices and alexa integrations...

Code: Select all
import requests
ip = str((indigo.variables[196756837].value)) #got wise and made variable with my poolcontroller server ip
ip = ip+'/state/circuit/setState/'
circuitid=6 #there is confusing matter of the circuits json array output of cricuit values and the circuit id used here
setting='on'

try:
 r= requests.put(ip, json={'id': circuitid, 'isOn': setting})

 if str(r.status_code)=='200': indigo.server.log('Pool command successful', type='njs-PiPool')
 else: indigo.server.log('Pool command to njs-poolController failed!', type='njs-PiPool', isError=True)

except:
 indigo.server.log('Pool command to njs-poolController failed!', type='njs-PiPool', isError=True)


Will keep you updated!

Posted on
Mon May 02, 2022 9:03 pm
ar26pt2 offline
Posts: 25
Joined: Jan 23, 2014

Re: Plugin: nodejs-poolController Pi for Swimmin Pools

Updates:
1. the raspberry pi nodejs-poolController app has continued to work great. Unfortunately though I left some debug log settings on and the pi filled up and crashed the app. Wasn’t sure what was going on so I did a delete and reinstall and all better now.

2. TroubleFreePool.com has a great step by step post on how to install this with a pentair system: https://www.troublefreepool.com/threads ... de.218514/

3. Not in the guide above, I used the ‘pm2’ npm/JavaScript manager on the pi to ensure auto loading of the applications on the raspberry without user intervention. When power flickers or whatever auto restarts.

4. I run the raspberry pi headless ethernet wired to a UniFi pro access point that wirelessly uplinks to my house UniFi AP. The raspberry and unifi are in a waterproof box in the pool pump area.

5. I have found this device and software much more reliable than the autelis device I had before.

Posted on
Fri May 13, 2022 12:54 pm
jltnol offline
Posts: 989
Joined: Oct 15, 2013

Re: Plugin: nodejs-poolController Pi for Swimmin Pools

Hey there

So as you know I've been successful with getting the PI to control my EasyTouch panel.
Now on to Indigo. Can you give just a brief explanation of where your first script goes? where does it live? and how does Indigo interact with it.

The 2nd script, I'm assuming, can be an Action Group, where you change certain parameters for each of the pool devices you'd like to control.. yes?

Posted on
Sat May 14, 2022 2:55 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Plugin: nodejs-poolController Pi for Swimmin Pools

I suspect that's an Indigo schedule with an external script; the script can live anywhere you like but there's a default /Scripts folder within your Indigo installation.

/Library/Application Support/Perceptive Automation/Indigo 2022.1/Scripts

(Well, there used to be - if I browse back to my Indigo 7.4 folder! If you don't have one in 2022.1 then maybe make one!)
Last edited by howartp on Sat May 14, 2022 5:46 am, edited 1 time in total.

Posted on
Sat May 14, 2022 5:24 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Plugin: nodejs-poolController Pi for Swimmin Pools

Apologies

The scripts folder was moved to /Library/Application Support/Perceptive Automation/Scripts so that you don't have to keep moving/changing links to them with each version.

Posted on
Tue May 17, 2022 11:17 am
jltnol offline
Posts: 989
Joined: Oct 15, 2013

Re: Plugin: nodejs-poolController Pi for Swimmin Pools

Got it.

Will give this a spin.

Posted on
Thu Nov 17, 2022 8:32 pm
jstewart30 offline
Posts: 28
Joined: Jul 03, 2014

Re: Plugin: nodejs-poolController Pi for Swimmin Pools

Just wanted to echo that I've been successfully using this same Raspberry Pi setup with the nodeJSPoolController to control and read various functions on my Pentair Suntouch (an extra crappy controller but it's what was installed when I bought the house). Can turn the hot tub on/off, and pool lights on/off, which is mainly all I wanted it for. Also it's easy to read the various data and stick those into variables for seeing what's running, temperatures, current pump status (RPM/GPM/Watts/etc), and so on (it's all JSON formatted).

Most functions are done with a very simple Python script. The code below will turn on Circuit 1 (my hot tub) (change the URL to your Raspberry Pi's IP address and port):

Code: Select all
import requests
url = "http://192.168.0.xx:3000/circuit/1/set/1"
data = requests.get(url).json

(change the 2nd line to end with 0 instead of 1 to turn off the hot tub)

I've recently been using the GhostXML plugin to read the status, as it's a bit easier than using a Python script. You can set it to URL path http://192.168.0.xx:3000/all to read everything, and then just make a Trigger to update the variables. If you want to use a Python script instead, here's an example to read the pool temperature:

Code: Select all
import requests
import json
url = "http://192.168.0.xx:3000/temperature"
data = requests.get(url)
jsonData = json.loads(data.text)

poolT = jsonData["temperature"]["poolTemp"]

poolTemp = indigo.variables[12345] # "poolTemp"

indigo.variable.updateValue(poolTemp, value=str(poolT))


Happy to try and answer any questions if anyone needs help with this setup...I'm not much of a Python guy but have managed to get things working satisfactorily, and will echo the other comments that this setup has been pretty rock solid.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests

cron