Sunday, October 25, 2020

Setting up and configuring nodejs-poolController

Over the last year, the Hubitat has proven itself more powerful every day and I've looked at integrating more of my devices into it, because... why not?  This will be a two part blog post for setting up and configuring nodejs-poolController and then integrating it into Hubitat.

Since the pool went in a few years back, we've been monitoring and managing it using EasyTouch and ScreenLogic, by extension.  It's served its purpose for being able to turn lights on and off, controlling the heater, and checking the water temperature.  The interface is serviceable, but can be a bit confusing if you don't know that 'Booster Pump' == 'Pool Cleaner' and you have to go to Features to turn on the lights rather than the section that says Lighting.  So, a small learning curve, but still a standalone app that begs to be integrated.


Enter nodeJS-poolController.  This amazing piece of code replicates the existing system and gives you significantly more options than the native controller, plus the ability to integrate it with Hubitat, SmartThings, Vera, or by MQTT. 

In order to interact with my pool controller, a ScreenLogic2, I purchased a RS-485 USB adapter for my Raspberry Pi 3 which will run the nodeJS server.  This one was $7 on Amazon and recommended by the developer and works out of the box with RaspiOS, or whatever they're calling Buster these days.



Pulling up the ScreenLogic2 manual, I was able to identify which two screw terminals I needed to connect to (DT+ and DT-) and I was well on my way.


The process to setup the poolController was not really that daunting.  I had it completed in under an hour.  Generally here's the steps I went through:

root@poolcontroller:~# apt-get update && upgrade

root@poolcontroller:~# apt install npm node


This installs nodeJS 10 (at least with my build) and the author recommends 12) which was installed using nvm in the following steps.


root@poolcontroller:~# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

root@poolcontroller:~# nvm install 12


Install build-essentials and git to pull down code.


root@poolcontroller:~# apt install git

root@poolcontroller:~# apt install build-essential


Clone both projects down.


nodejs-poolController:

root@poolcontroller:~# git clone https://github.com/tagyoureit/nodejs-poolController.git


nodejs-poolcontroller-webClient:

root@poolcontroller:~# git clone https://github.com/tagyoureit/nodejs-poolController-webClient.git

Install both node packages with npm i.

root@poolcontroller:~/nodejs-poolController#npm i

root@poolcontroller:~/nodejs-poolController-webClient# npm i


Run the nodejs-poolControler. 


root@poolcontroller:~/nodejs-poolController# npm start


After it's running for the first time, you can edit the config.json file with your specifics.


Run the nodejs-poolController-webClient


root@poolcontroller:~/nodejs-poolController-webClient# npm start


Assuming everything went well, you should be able to browse to that IP address on port 8080.



I took the extra step to setup pm2 to allow the services to startup on reboot.


root@poolcontroller:~/nodejs-poolController# npm install -g pm2

root@poolcontroller:~/nodejs-poolController# pm2 start npm --name="poolController" -- start

root@poolcontroller:~/nodejs-poolController# cd ../nodejs-poolController-webClient

root@poolcontroller:~/nodejs-poolController-webClient# pm2 start npm --name="webClient" -- start

After the processes are runnning, you can have pm2 start on boot and run these processes automatically.

root@poolcontroller:~# pm2 startup
root@poolcontroller:~# pm2 save

With this part complete, we can now move on to integrating nodejs-poolController into Hubitat!

No comments:

Post a Comment