Pool Controller with nodejs-poolController via MQTT

Just setup pentair easytouch pool control in HA using the great work at https://github.com/tagyoureit/nodejs-poolController/
with a ~$20 wifi-to-RS485 (Elfin EW11) adapter.

Wanted to share my sensors and switch with the default setup (this is my first MQTT - HA project, so probably ugly…). Let me know if you have any suggestions. Thanks!

  - platform: mqtt
    name: pool_pooltemp
    state_topic: "easytouch2-8/state/temps/bodies/1/pool/temp"
    unit_of_measurement: '°F'
    value_template: "{{ value_json.temp }}"
  - platform: mqtt
    name: pool_spatemp
    state_topic: "easytouch2-8/state/temps/bodies/2/spa/temp"
    unit_of_measurement: '°F'
    value_template: "{{ value_json.temp }}"
  - platform: mqtt
    name: pool_airtemp
    state_topic: "easytouch2-8/state/temps/air"
    unit_of_measurement: '°F'
    value_template: "{{ value_json.temp }}"
  - platform: mqtt
    name: pool_spa
    state_topic: easytouch2-8/state/circuits/1/spa
    value_template: "{{ value_json.isOn }}"

  - platform: mqtt
    name: pool_spa
    state_topic: easytouch2-8/state/circuits/1/spa
    value_template: "{{ value_json.isOn }}"
    command_topic: easytouch2-8/state/circuits/toggleState
    payload_on: '{"id": 1}'
    payload_off: '{"id": 1}'
    state_on: "on"
    state_off: "off"
  - platform: mqtt
    name: pool_cleaner
    state_topic: easytouch2-8/state/circuits/2/cleaner
    value_template: "{{ value_json.isOn }}"
    command_topic: easytouch2-8/state/circuits/toggleState
    payload_on: '{"id": 2}'
    payload_off: '{"id": 2}'
    state_on: "on"
    state_off: "off"

One confusing thing was the state_on and state_off being required or else the switch state did not reflect the state_topic - maybe due to capitalization or string vs. boolean…

1 Like

Thank you for sharing this! This was really helpful and made setting up my Pentair control over RS485 so much easier.

One question: the “on/off” toggle works well for most features on my pool, but is there a way to control the temperature of the spa over MQTT?

For my setup the spa temperature seems to sit at: pool/state/temps/bodies/2/spa/setPoint

But (as a HA and MQTT beginner) I’m having trouble figuring out how to configure HA to communicate/set the temperature value for that topic? Would I still set it up as a “switch:” entity in HA, or is there another type that should be used here?

Following examples from this link, I was able to setup the temperature control too!

Had to do a special automation (in automations.yaml) to output the correct JSON to MQTT setpoint (see temperature_command_topic: pool/setpoint in climate below)

  - platform: mqtt
    name: "Pool"
    min_temp: 40
    max_temp: 104
      - "off"
      - "heat"
    current_temperature_topic: easytouch2-8/state/temps/bodies/1/pool/temp
    value_template: "{{ value_json.temp }}"
    mode_state_topic: easytouch2-8/state/temps/bodies/1/pool/heatMode
    mode_state_template: "{{ value_json['heatMode']['val'] }}"
    temperature_command_topic: pool/setpoint
    temperature_state_topic: easytouch2-8/state/temps/bodies/1/pool/setPoint
    temperature_state_template: "{{ value_json.setPoint }}"

Then, in automations.yaml I have:

- alias: "setpoint converter"
    platform: mqtt
    topic: pool/setpoint
    service: mqtt.publish
      topic: easytouch2-8/state/body/setPoint # <-- from https://github.com/tagyoureit/nodejs-poolController/wiki/Bindings-Integrations-in-2.0#mqtt
      payload: '{"id":1,"setPoint":{{trigger.payload | int}}}' # <-- id sets body/circuit

Works great!

Very nice, thank you again for sharing.

I think I might be having an issue with the formatting in that automations.yaml line to set up the payload id and temperature. When I look at the MQTT debug log, I’m seeing:

2020-11-14 15:02:57 DEBUG (MainThread) [homeassistant.components.mqtt] Transmitting message on pool/setPoint: '88.0', mid: 142

2020-11-14 15:02:57 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on pool/setPoint: b'88.0'

2020-11-14 15:02:57 ERROR (MainThread) [homeassistant.components.automation.setpoint_converter] setpoint converter: Error executing script. Unexpected error for call_service at pos 1: payload must be a string, bytearray, int, float or None.

Is there something in my single or double quotes that could be causing that payload to not be recognized as a string?

Looks like you might have a typo somewhere in the converter with the b'88.0':

2020-11-14 15:02:57 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on pool/setPoint: b’88.0’

Maybe post your yaml here.

Of course, here’s what I have for my automations.yaml:

  GNU nano 4.8                                                             automations.yaml                                                                       
- alias: setpoint converter
    platform: mqtt
    topic: pool/setPoint
    service: mqtt.publish
      topic: easytouch2-8/state/body/setPoint
      payload: '{  "id": 1, "setPoint": {{trigger.payload | int }}   }'

Hmmm… I do not see any obvious problems. Maybe there are some spacing issues or quotes issues. I know I had to tweak the double vs. single quotes to get it working right for me. I would try to figure out the b'88.0' error message to see if there is some formatting issue there.

@loopy1 - thanks for sharing your success with the njsPC integration. I am attempting to follow in your footsteps these days, thus I would like to ask for your advice as I’m running into some socket errors between njsPC and my MQTT broker.

I’m currently trying to solve the problem with the developers, yet wanted to see if you perhaps ran into the same per chance? I presume you’re running the 6.1.1/next build of njsPC with a Mosquitto broker inbetween that and HA.

Hardware: stand-alone Intelliflo VS pump connected directly to a RS485 USB adapter on a Pi. All that is working well. On the Pi I’m running

  • Mosquitto MQTT broker
  • OpenZwave ozwdaemon (talking to a Sillicon Labs UZB stick)
  • NodeJS poolcontroller and web-interface packages

I know my MQTTT broker works fine as I’ve got the ozwdaemon talking nicely to HA through it, however I’m not getting any love from njsPC having enabled MQTT in it’s config.json file. Setting it’s logs to silly-level I get messages such as:

[1/9/2021, 13:55:09] silly: MQTT send:
topic: pool/state/pumps/1/intelliflovs/rpm
message: {“rpm”:0}

I know it’s trying to talk to the Mosquitto broker, yet I keep getting multiple of these log entries on the broker when that happens and the pool topic never shows up in the MQTT explorer.

1610229310: New connection from on port 1883.
1610229310: Socket error on client , disconnecting.
1610229311: New connection from on port 1883.
1610229311: Socket error on client , disconnecting.

It should be said I’m currently running the MQTT broker in anonymous mode, not requiring authentication.

UPDATE: Figured out what the problem was in the mean-time: Turns out that I had a left-over line in my /etc/mosquitto/mosquitto.conf file:

password_file /etc/mosquitto/mosusers.conf

Even though I had a ‘allow_anonymous false’ right above it, somehow Mosquitto still thinks it needs to process the user/password file specified. Knocking it out and running it in anon-mode made it work

I was just looking for a way to integrate njsPC to HA while watching my pool get built. Thought I had to create an addon or integration myself. (which I have no clue to do)

@loopy1 can you share how you set yours up in more detail.

There is a pretty detailed description of getting it running using a raspberry-pi here: https://www.troublefreepool.com/threads/pentair-intellicenter-pool-control-dashboard-instructional-guide.218514/

My setup uses a this device (Elfin EW11, maybe go for antenna model if wifi is weak) which puts the RS485 on my wifi, then a linux box runs nodejs-poolcontroller (which talks to the device over wifi) and relays it all via MQTT to homeassistant using my sensors/swtich shown in the first post of this thread.

It is quite easy and great for tinkerers, but definitely not as simple as the commercial Pentair wifi/app setup, but that was ~$1000 vs. my $25.

Would care to share how you got nodejs-poolController to talk to the WiFi-rs485? I am wanting to set this up to control my salt system.

The wifi-rs485 (in the pool box connected to and powered from the com board) was configured via the web interface to: listen on port 9801 which is routed to the serial port also configured via web interface with settings 9600/8/1/none, flow control disabled - very easy.

After installing nodejs-poolcontroller on a separate server, modify the default config.json to set netConnect: true, netHost: IP_of_wifi_rs485, netPort: 9801, and check portSettings are same as serial port above (9600/8/1/none, flow off). In the same config.json is also where you enter the MQTT host,user,password details which puts into HA.

That is it for getting the two to communicate.

1 Like

I have the WiFi adapter hooked up and I can access it but I am having issues receiving data from my SWG. I have the A/B terminals connected but I am not sure if it’s right. Does the A to the A on the SWG and the B goes to the B on the SWG or is it switch switched. I am getting voltage on the A/B connections but I am not getting any data showing up on the WiFi adapter.

Not sure what SWG A/B are in your case, but in my Easytouch controller box (which has a wiring diagram on the backside of the door to help locate the following), the wifi-rs485 is wired to the “EasyTouch Screw Terminal COM PORT (J20)” which has 4 terminals: GND, -DT, +DT, +15. I correspondingly connected these 4 terminals to GND, B-, A+ , VCC on the wifi-rs485 device.

Thanks so much for posting this! I moved from using the nodes-poolController REST interface to MQTT this weekend. First time installing the MQTT broker.

Your guide, plus MQTT Explorer, was very helpful. I pretty much have everything working, including adding the climate configs for the pool and spa.

Everything is much snappier with a messaging system instead of polling. Also, I’m hoping that this will cut down my history database size (which is huge now due I think to all the polling I was doing with the REST interface).

The only problem I’m running into is that if I use the header toggle to turn all entities in a Lovelace card on or off, it only affects the first entity. For example, I have an entity card with the pool and spa lights. When I click the toggle in the header, it only affects the first entity.

But I don’t think this is an MQTT issue. I saw the same thing with REST.

In any case, I’ve enabled MQTT debug logging and see the messages being sent. Looks like the poolController is ignoring the second one (or perhaps not serializing simultaneous commands).

I’ve posted this issue on the nodejs-poolController gitter lobby. They’ve been very responsive in the past.

But if anyone else has run into this issue and has a solution, please let me know.

Again thanks so much for this thread. It was a real time saver.

I also want to say thanks for this. I installed the EasyTouch system this weekend and got the EW11 installed and communicating with the nodejs-poolController running on a raspberry pi 3B+. For the most part everything was smooth. I had to enable MQTT from the poolController-dashPanel interface before home assistant was able to get sensor information. I must have missed something when I set up MQTT in the config.json file.

I also ran into an issue with the nodejs-poolController process being stopped when I backgrounded the task. Running the task in the foreground fixed that issue.

I ended up going with the EW11a and have the antenna protruding from one of the holes at the bottom of the low voltage compartment.

Here’s a screenshot of my HA pool controller UI

Here’s a pic showing the EW11a antenna protruding from the bottom of the low voltage compartment.

With the door to the EasyTouch closed and the EW11a antenna inside the enclosure I had a very weak wifi connection. Moving the EW11a so the antenna was outside of the bottom of the enclosure fixed that issue.

Regarding running the nodejs-PC process and backgrounding, I ended up using pm2 as suggested in gitter: https://gitter.im/nodejs-poolController/Lobby?at=5cda2be3bdc3b64fcf4158b7


How to get PM2 installed and running poolController on RPi or Linux

  1. Install PM2 with npm sudo npm install -g pm2
  2. Quit nodejs-poolController if its running.
  3. Launch nodejs-poolController with PM2 pm2 start /home/pi/nodejs-poolController/src/index.js —name=“poolController” —watch
  4. Adding the —watch in the line above will auto restart the app if you make a change such as an update with git pull. If you don’t want that action to occur simply don’t include the watch flag.
  5. Run pm2 ls to see your app(s) running with pm2. It will show uptime of the app and reset counter.
  6. Type pm2 startup If you want pm2 to auto-start at boot (recommended). This command will give you a command based on your platform to run so pm2 starts on its own. pm2 unstartup will reverse this behavior.
  7. Finally run pm2 save to save what apps you have running so if your machine reboots or crashes, it when PM2 starts back up again it will launch your saved apps again.

pm2 logs is useful for looking at the console logs of your app(s) for troubleshooting.

I’m not using --watch and have a cron job doing pm2 restart all overnight for stability.

1 Like

I’m interested in adding UI to LoveLace that lets me select the intellibrite mode (i.e. Party, Caribbean, etc.) or fixed color. But since it’s 11 light show modes and 8 colors per light, I’d like it to be compact, like a popup menu.

Has anyone figured this out? If not, maybe I’ll look into general popup selection like hass-browser_mod.

@acronce - I don’t have intellibright lights yet, but I’d be interested to see what you come up with.

Just added a few iOS actions to be able to control the spa from my Apple Watch. It’s nice to have since the watch goes with me in the pool & the phone doesn’t.