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: 682
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!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests