Vistapool Integration

For people with Vistapool, Hidrolife, etc pool automation system, I found a (very dirty) way of integrating data into Home Assistant. I only wanted sensors for temperature and pH level, but you can modify it to get any other parameter.

First use this PHP script (thanks Chris) with your username/password to get your pool data. You can modify the script so the output is a simple json file with {"temp":12.3,"pH”:4.5} in it. Just add this at the end of the script:

$fp = fopen('vistapool.json’, 'w+');
fwrite($fp, '{"temp":');
fwrite($fp, substr(($result["temp"]), 0, -3));
fwrite($fp, ',"ph":');
fwrite($fp, ($result["PH"]));
fwrite($fp, '}');

Then I created a batch file in Windows to execute the script every 15 minutes and copy (and subsequently replace) the file into the Hassio \www\vistapool\ folder.

php vistapool.php
xcopy /y C:\Users\me\sensor\vistapool.json H:\www\vistapool\
timeout 900
goto start

Finally, create two file sensors to read the values from the file:

  - platform: file
    name: Pool Temp
    file_path: /config/www/vistapool/vistapool.json
    value_template: '{{ value_json.temp }}'
    unit_of_measurement: '°C'
    scan_interval: 900
  - platform: file
    name: Pool pH
    file_path: /config/www/vistapool/vistapool.json
    value_template: '{{ }}'
    scan_interval: 900

And here you go:

32%20AM 59%20AM

The original PHP script can read all values and control all functions. That would be great to have, but if anybody can help with a simple login + get temp&ph Python script, everything could be done inside Home Assistant. Having to depend on another OS to execute the PHP script might not be very reliable.

Thanks for this, it works fine. I’m trying to get the data directly from the pool system without passing through the vistapool website (I try to keep my LAN closed). I can connect to it via Telnet and I got the list of Modbus registers, but I’m stuck there… do you know anything about that?

I wish I could help you. Local access would be the ideal solution, but I’m guessing a lot of programming knowledge would be involved. I’m also trying to get this to work inside Home Assistant, but so far I’m unable to log into the web site with a Python script. Let me know if you get somewhere.

I found the modbus platform and the modbus sensor, which look exactly like what we need.

I’m corresponding with the Vistapool guys to understand how to connect via TCP, as I’m unable to see any information. The only open port seem to be 23 (telnet), but by using it HA doesn’t report anything at all (no errors, nothing).

I keep you posted!

Were the Vistapool guys helpful? I’ve had no luck getting in touch with them…

Until now very responsive. They sent me this doc which has all the modbus details, but I have no idea how to connect via TCP. As said, I can only go in via Telnet, but I’m totally out of my expertise.

If you log into your account and you go to (change XXXX for your 4-digit pool ID) you get a json file with all the info. If you could ask them to explain how to access that page without having to log in (or maybe including login info in the url address) we could at least build sensors with all the info. Let know if I can help in any way, or any advance on your findings.

In this thread you commented in, the last post seems to be correct to achieve that.

My objective is the local access, so I’ll keep digging!

I am digging as well :slight_smile:
But I have a limited time to experiment at the moment.

In my understanding:
script itself should

  • go throught login and save cookies to an any local storage -it might be SD, NAS, USB - really des not matter.
  • open web from the link and write/rewrite data provided to local storage as well

If it works, HASSIO automation will fire a script in preset period and read dedicated data in json format
If it works, hypothetically it should be possible to extend it to the full control.

The only way to have full local controll is through MODBUS.
Related to the MODBUS.
There are three main issues:

  1. How to read data from connected device registers
  2. How to interpret data red from device.
  3. How to control device (the most tricky, due to multiple confirmation needed for any change and possibility of bricking the device when data are written in inproper register)
    Data itself are described in the document from vistapool (description of registers), it is relatively clear.
    Some time ago I was experimenting with this
    I was able to connect, read data (even by HASSIO modbus sensor) but they were different to the vistapool document, and I was not able to interpret them properly.
    I do not know anybody who knows modbus on the needed level (format of data, parity etc.) :woozy_face::woozy_face:
    so the HF 2211 is somewhere deep in the drawer.

I found a better way to do it. I wrote a simple Python script to log in and get all the values as sensor attributes. That way all is done by Home Assistant, with no outside PHP script being run.

You need to get your pool ID. It’s just 4 numbers you can get from the url address bar when you log into your account.

Then create this Python script (I save it as Fill in your username and password and change 1234 to match your pool ID:

#!/usr/bin/env python
# coding: utf-8

# In[ ]:

import requests

# Fill in your details here to be posted to the login form.
payload = {
    'user': ‘[email protected]’,
'pass': ‘yourpassword’,
'remember_password': '0',
'entrar': 'Enter'

# Use 'with' to ensure the session context is closed after use.
with requests.Session() as s:
    p ='', data=payload)

# An authorised request.
    r = s.get('’)

Then create a command_line sensor pointing at the file. I chose to run mine every 10 minutes and timeout at 30 seconds if there are connection problems. You can include any of the json file values as json_attributes to the main sensor (temp). Just execute the scrip in a terminal window to see what values are available. Here’s the command line sensor and the extra sensor for what I wanted: filtration status, ph level and RX. I added | replace("º","") | replace("C","") to avoid duplication of the temp unit of measurement:

  - platform: command_line
    name: Pool
    scan_interval: 600
    command_timeout: 30
      - filtration_stat
      - PH
      - RX
    command: "python3 /config/www/vistapool/"
    value_template: '{{ value_json.temp | replace("º","") | replace("C","") }}'
    unit_of_measurement: '°C'
  - platform: template
        friendly_name: pH Level
        value_template: '{{ states.sensor.pool.attributes.PH }}'
        friendly_name: Filtration Status
        value_template: '{{ states.sensor.pool.attributes.filtration_stat }}'
        friendly_name: RX Level
        value_template: '{{ states.sensor.pool.attributes.RX }}'

This script is obviously read-only, can not modify values on the server. My Python skills are worse than rudimentary so I have no idea how to do that, but at least you can monitor every aspect of the system.

Thanks. Well done :+1:
Going to try right now.


Hmm, did not work for me :frowning:

Command failed: python3 /config/www/vistapool/
19:32 components/command_line/ (ERROR) - message first occured at 19:22 and shows up 2 times

I did copy-paste, the same folder, same sensors, well, except RX, changed login details and pool ID.
Other my scripts working well.

Hmm, let me think about it, it’s working great for me. Did you create the vistapool dir?

Yep. It is a real copy/paste, www/vistapool dir included.
I run Homeassistant 0.97.1

What do you get when you run the py script in a terminal window? It should print out all the json values

Traceback (most recent call last):
  File "C:\Users\B\python27\Scripts\", line 6, in <module>
    import requests
ImportError: No module named requests

You need to update your python environment with pip install requests

From a terminal window on Win 10, with requests installed, script works.
As I run hassio, there is no way to use pip :frowning:

Uups :+1:. I’ve installed requests library through python_exec addon
Your script works now.
Thank you for guiding me :slightly_smiling_face:

Glad it works! :+1: