Vistapool Integration

Hi!

I based everything on the great work @kajmaj did - all credits to him :slight_smile:

snippet of code:
Modus:
- name: MBF_RELAY_STATE # MBF_RELAY_STATE Status relais
slave: 1
address: 270
input_type: holding
data_type: uint16

sensors:
pomp_speed:
friendly_name: “Pomp Snelheid”
value_template: >-
{% if is_state(‘sensor.MBF_RELAY_STATE’, ‘290’ ) %}
Slow
{% elif is_state(‘sensor.MBF_RELAY_STATE’, ‘546’ ) %}
Medium
{% elif is_state(‘sensor.MBF_RELAY_STATE’, ‘1058’ ) %}
Fast
{% elif is_state(‘sensor.MBF_RELAY_STATE’, ‘0’ ) %}
Off
{% else %}
???
{% endif %}

@ppenders thx, worked perfectly

I only get “???”, and when I trace sensor.mbf_relay_state, I get “258”, when my pump is pumping “medium” speed…

You’ll need to change the values to match your pump speed settings

2 Likes

Can you please post a current working version of the yml code?
I cannot get it wo work…

Sensors example

modbus:
- name: bazen
  type: tcp
  host: 192.168.1.5
  port: 8899
  sensors:
    - name: MBF_MEASURE_PH
      slave: 1
      address: 258
      input_type: holding
      data_type: uint16
      scale: 0.01
      precision: 1
      scan_interval: 30
      unit_of_measurement: pH
      state_class: measurement

Filtration switch snippet:

switch:
- platform: template
  switches:
    bazen_modbus_filtrace_solnicka:
      value_template: "{{ states('sensor.mbf_par_filtration_state') | int(0)  == 1 }}" 
      turn_on:
        - service: modbus.write_register
          data:
            hub: bazen
            unit: 1
            address: 1041
            value: [0]
        - service: modbus.write_register
          data_template:
            hub: bazen
            unit: 1
            address: 1043
            value: [1]
        - service: modbus.write_register
          data:
            hub: bazen
            unit: 1
            address: 752
            value: [1]
        - delay: 00:00:01
        - service: modbus.write_register
          data:
            hub: bazen
            unit: 1
            address: 757
            value: [1]
      turn_off:
        - service: modbus.write_register
          data:
            hub: bazen
            unit: 1
            address: 1041
            value: [0]
        - service: modbus.write_register
          data_template:
            hub: bazen
            unit: 1
            address: 1043
            value: [0]
        - service: modbus.write_register
          data:
            hub: bazen
            unit: 1
            address: 752
            value: [1]
        - delay: 00:00:01
        - service: modbus.write_register
          data:
            hub: bazen
            unit: 1
            address: 757
            value: [1]
1 Like

Thank you for this. What would be the yaml code to switch from Auto to Manual or Smart Filtration mode?

If the unit is in Auto mode, would this code you posted switch it to Manual and turn it off (or on), or does it have to be already in Manual mode for it to work?

Thanks.

As stated here the device has to be in manual mode if you want to control Vistapool via HA + MODBUS. All automation (timers, smart filtration etc. ) is done by HA.

But can the mode be changed through Modbus write?

I do not know about it.

I use node-red unfortunately I can only read the registers.

works well.

Thank you! Can you post the nodered-export aswell?

I think I figured this out. You can change modes by writing to MBF_PAR_FILT_MODE the same way you did above, but using 1 for Auto (and 3 for Smart in my system, but Auto and Manual are just what I needed). Just for safety, in the Auto mode script I start by turning MANUAL_STATE Off in case it was running (I don’t know what the behavior would be if MANUAL_STATE is ON and FILT_MODE is also turned to 1) before switching FILT_MODE to 1. Seems to be working fine. Very convenient if you want to switch modes via Siri (for pool cleaning) etc. Now I need to figure out two things:

  • How to force a reading of the Modbus values right after changing modes (so they instantly reflect the change)
  • How to turn Manual/Auto selection scripts into a switch.
vistapool_manual_mode_on:
    sequence:
    - service: modbus.write_register
      data:
            hub: pool
            unit: 1
            address: 0x0411 # MBF_PAR_FILT_MODE (0 = Manual; 1 = Auto ; 3 = Smart)
            value: [0]
    - service: modbus.write_register
      data_template:
            hub: pool
            unit: 1
            address: 0x0413 # MBF_PAR_FILT_MANUAL_STATE (off = 0; on = 1)
            value: [1]
    - service: modbus.write_register
      data:
            hub: pool
            unit: 1
            address: 0x02F0 # MBF_SAVE_TO_EEPROM
            value: [1]
    - delay: 00:00:01
    - service: modbus.write_register
      data:
            hub: pool
            unit: 1
            address: 0x02F5    # MBF_EXEC
            value: [1]

vistapool_manual_mode_off:
    sequence:
        - service: modbus.write_register
          data:
            hub: pool
            unit: 1
            address: 0x0411 # MBF_PAR_FILT_MODE (0 = Manual; 1 = Auto ; 3 = Smart)
            value: [0]
        - service: modbus.write_register
          data_template:
            hub: pool
            unit: 1
            address: 0x0413 # MBF_PAR_FILT_MANUAL_STATE (off = 0; on = 1)
            value: [0]
        - service: modbus.write_register
          data:
            hub: pool
            unit: 1
            address: 0x02F0 # MBF_SAVE_TO_EEPROM
            value: [1]
        - delay: 00:00:01
        - service: modbus.write_register
          data:
            hub: pool
            unit: 1
            address: 0x02F5    # MBF_EXEC
            value: [1]
      
vistapool_auto_mode:
    sequence:
        - service: modbus.write_register
          data_template:
            hub: pool
            unit: 1
            address: 0x0413 # MBF_PAR_FILT_MANUAL_STATE (off = 0; on = 1)
            value: [0]
        - service: modbus.write_register
          data:
            hub: pool
            unit: 1
            address: 0x0411 # MBF_PAR_FILT_MODE (0 = Manual; 1 = Auto ; 3 = Smart)
            value: [1]
        - service: modbus.write_register
          data:
            hub: pool
            unit: 1
            address: 0x02F0 # MBF_SAVE_TO_EEPROM
            value: [1]
        - delay: 00:00:01
        - service: modbus.write_register
          data:
            hub: pool
            unit: 1
            address: 0x02F5    # MBF_EXEC
            value: [1]

How to force a reading of the Modbus values right after changing modes (so they instantly reflect the change)?
Make “scan_interval” shorter as possible but you will need to wait for modbus report (within this scan_interval) anyhow. Or “persuade” Vistapool device to instant reporting somehow.

How to turn Manual/Auto selection scripts into a switch?
Either switch template or create any selector and choose

Could you tell why do you need to switch Vistapool between Auto and Manual mode? I am just curious :wink: BTW good finding :+1:

Turns out homeassistant.update_entity service also works with modbus sensors, so calling the service instantly updates the state after the filtration mode change. This is the final script:

vistapool_auto_mode:
    sequence:
        - service: modbus.write_register
          data_template:
            hub: pool
            unit: 1
            address: 0x0413 # MBF_PAR_FILT_MANUAL_STATE (off = 0; on = 1)
            value: [0]
        - service: modbus.write_register
          data:
            hub: pool
            unit: 1
            address: 0x0411 # MBF_PAR_FILT_MODE (0 = Manual; 1 = Auto ; 3 = Smart)
            value: [1]
        - service: modbus.write_register
          data:
            hub: pool
            unit: 1
            address: 0x02F0 # MBF_SAVE_TO_EEPROM
            value: [1]
        - delay: 00:00:01
        - service: modbus.write_register
          data:
            hub: pool
            unit: 1
            address: 0x02F5    # MBF_EXEC
            value: [1]    
        - service: homeassistant.update_entity
          data_template:
              entity_id: sensor. pool_filtration_mode

I ended up going the easy way. First I created a sensor template to reflect the state after executing any of the 3 scripts (Manual Mode Off, Manual Mode On and Auto; Smart is just there for fun):

  - platform: template
    sensors:
      filtration:
        friendly_name: "Filtration Mode"
        value_template: >-
          {% if is_state('sensor. pool_filtration_mode', '0' ) and is_state('sensor. pool_filtration_manual_state', '0' ) %}
              MANUAL (OFF)
          {% elif is_state('sensor. pool_filtration_mode', '0' ) and is_state('sensor. pool_filtration_manual_state', '1' ) %}
              MANUAL (ON)              
          {% elif is_state('sensor. pool_filtration_mode', '1' ) %}
              AUTO
          {% elif is_state('sensor. pool_filtration_mode', '3' ) %}
              SMART
          {% else %}
              ???
          {% endif %}

And then I just call the script when I need to change modes:

Screenshot 2023-08-18 at 6.07.24 PM

I always have the system in Auto mode, but for pool bottom cleaning and backwash I need to turn it on and off manually. The device is not very easily accessible and Vistapool cloud connection is… well, a hit or miss. This saves some time and effort. Thanks!

here is the code of my nodered.
unfortunately I can only read out I am still looking for the white register of the boost mode and the setpiont of ph and redox

[
    {
        "id": "618881f6ac67f894",
        "type": "tab",
        "label": "X valley",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "8540ac185c4f0b5c",
        "type": "modbus-read",
        "z": "618881f6ac67f894",
        "name": "",
        "topic": "",
        "showStatusActivities": false,
        "logIOActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "unitid": "1",
        "dataType": "InputRegister",
        "adr": "258",
        "quantity": "1",
        "rate": "10",
        "rateUnit": "s",
        "delayOnStart": false,
        "startDelayTime": "",
        "server": "4a874db92373c071",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "x": 250,
        "y": 220,
        "wires": [
            [
                "eb7ef75e92679c2f"
            ],
            []
        ]
    },
    {
        "id": "d45189fa80d3d138",
        "type": "comment",
        "z": "618881f6ac67f894",
        "name": "pH Waarde Zwembad (258)",
        "info": "",
        "x": 300,
        "y": 180,
        "wires": []
    },
    {
        "id": "5793be3be6a7dd43",
        "type": "debug",
        "z": "618881f6ac67f894",
        "name": "debug 4",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 960,
        "y": 100,
        "wires": []
    },
    {
        "id": "cf588a1fb85903b3",
        "type": "modbus-read",
        "z": "618881f6ac67f894",
        "name": "",
        "topic": "",
        "showStatusActivities": false,
        "logIOActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "unitid": "1",
        "dataType": "InputRegister",
        "adr": "262",
        "quantity": "1",
        "rate": "500",
        "rateUnit": "ms",
        "delayOnStart": false,
        "startDelayTime": "",
        "server": "4a874db92373c071",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "x": 250,
        "y": 100,
        "wires": [
            [
                "57cc04d605365961"
            ],
            []
        ]
    },
    {
        "id": "57cc04d605365961",
        "type": "function",
        "z": "618881f6ac67f894",
        "name": "function 4",
        "func": "msg.payload = msg.payload / 10;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 600,
        "y": 100,
        "wires": [
            [
                "5793be3be6a7dd43"
            ]
        ]
    },
    {
        "id": "dca10515cbd93b57",
        "type": "comment",
        "z": "618881f6ac67f894",
        "name": "Water Temperatuur Zwembad (262)",
        "info": "",
        "x": 320,
        "y": 60,
        "wires": []
    },
    {
        "id": "eb7ef75e92679c2f",
        "type": "function",
        "z": "618881f6ac67f894",
        "name": "function 5",
        "func": "msg.payload = msg.payload / 100;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 600,
        "y": 220,
        "wires": [
            [
                "6bd9fc6ce913243a"
            ]
        ]
    },
    {
        "id": "8bb62b999eff31d9",
        "type": "modbus-read",
        "z": "618881f6ac67f894",
        "name": "",
        "topic": "",
        "showStatusActivities": false,
        "logIOActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "unitid": "1",
        "dataType": "InputRegister",
        "adr": "259",
        "quantity": "1",
        "rate": "10",
        "rateUnit": "s",
        "delayOnStart": false,
        "startDelayTime": "",
        "server": "4a874db92373c071",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "x": 250,
        "y": 340,
        "wires": [
            [
                "e924bfc049eebdef"
            ],
            []
        ]
    },
    {
        "id": "532dcaf323292c93",
        "type": "comment",
        "z": "618881f6ac67f894",
        "name": "Rodux Sensor (259)",
        "info": "",
        "x": 270,
        "y": 300,
        "wires": []
    },
    {
        "id": "201cd07d0c2ca092",
        "type": "modbus-read",
        "z": "618881f6ac67f894",
        "name": "",
        "topic": "",
        "showStatusActivities": false,
        "logIOActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "unitid": "1",
        "dataType": "InputRegister",
        "adr": "257",
        "quantity": "1",
        "rate": "10",
        "rateUnit": "s",
        "delayOnStart": false,
        "startDelayTime": "",
        "server": "4a874db92373c071",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "x": 250,
        "y": 460,
        "wires": [
            [
                "855b18d3038c2974"
            ],
            []
        ]
    },
    {
        "id": "5a2bfab46dca6801",
        "type": "comment",
        "z": "618881f6ac67f894",
        "name": "Hydrolysis (257)",
        "info": "",
        "x": 260,
        "y": 420,
        "wires": []
    },
    {
        "id": "855b18d3038c2974",
        "type": "function",
        "z": "618881f6ac67f894",
        "name": "function 6",
        "func": "msg.payload = msg.payload / 10;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 580,
        "y": 460,
        "wires": [
            [
                "1eaef61f7ae507dd"
            ]
        ]
    },
    {
        "id": "6bd9fc6ce913243a",
        "type": "openhab2-out2",
        "z": "618881f6ac67f894",
        "name": "",
        "controller": "6d29cbc8a3dbce62",
        "itemname": "Zwemspa_Sugar_Valley_PH",
        "topic": "ItemUpdate",
        "payload": "",
        "onlywhenchanged": false,
        "x": 1020,
        "y": 220,
        "wires": [
            []
        ]
    },
    {
        "id": "e924bfc049eebdef",
        "type": "openhab2-out2",
        "z": "618881f6ac67f894",
        "name": "",
        "controller": "6d29cbc8a3dbce62",
        "itemname": "Zwemspa_Sugar_Valley_Rodux",
        "topic": "ItemUpdate",
        "payload": "",
        "onlywhenchanged": false,
        "x": 1030,
        "y": 340,
        "wires": [
            []
        ]
    },
    {
        "id": "1eaef61f7ae507dd",
        "type": "openhab2-out2",
        "z": "618881f6ac67f894",
        "name": "",
        "controller": "6d29cbc8a3dbce62",
        "itemname": "Zwemspa_Sugar_Valley_Hydrolysis",
        "topic": "ItemUpdate",
        "payload": "",
        "onlywhenchanged": false,
        "x": 1040,
        "y": 460,
        "wires": [
            []
        ]
    },
    {
        "id": "8f5bcd6107c34e12",
        "type": "comment",
        "z": "618881f6ac67f894",
        "name": "Pool Target PH (1284)",
        "info": "",
        "x": 280,
        "y": 620,
        "wires": []
    },
    {
        "id": "7ef11bb47471170c",
        "type": "comment",
        "z": "618881f6ac67f894",
        "name": "Pool Target Redox (1288)",
        "info": "",
        "x": 290,
        "y": 760,
        "wires": []
    },
    {
        "id": "2e3d0e9dd3ebed73",
        "type": "comment",
        "z": "618881f6ac67f894",
        "name": "Pool Filtration (1057)",
        "info": "",
        "x": 270,
        "y": 860,
        "wires": []
    },
    {
        "id": "933ce1153517a269",
        "type": "comment",
        "z": "618881f6ac67f894",
        "name": "Pool Filtration mode (1041)",
        "info": "",
        "x": 290,
        "y": 980,
        "wires": []
    },
    {
        "id": "01e94f6f2bfd0cab",
        "type": "debug",
        "z": "618881f6ac67f894",
        "name": "debug 11",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 980,
        "y": 660,
        "wires": []
    },
    {
        "id": "a0e76710700e84fa",
        "type": "modbus-read",
        "z": "618881f6ac67f894",
        "name": "",
        "topic": "",
        "showStatusActivities": false,
        "logIOActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "unitid": "1",
        "dataType": "HoldingRegister",
        "adr": "1284",
        "quantity": "1",
        "rate": "500",
        "rateUnit": "ms",
        "delayOnStart": false,
        "startDelayTime": "",
        "server": "4a874db92373c071",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "x": 250,
        "y": 660,
        "wires": [
            [
                "723055f85d83ac73"
            ],
            []
        ]
    },
    {
        "id": "723055f85d83ac73",
        "type": "function",
        "z": "618881f6ac67f894",
        "name": "function 35",
        "func": "msg.payload = msg.payload / 100;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 590,
        "y": 660,
        "wires": [
            [
                "01e94f6f2bfd0cab"
            ]
        ]
    },
    {
        "id": "960ae8868fffdaad",
        "type": "debug",
        "z": "618881f6ac67f894",
        "name": "debug 12",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 980,
        "y": 800,
        "wires": []
    },
    {
        "id": "e1f222950981c090",
        "type": "modbus-read",
        "z": "618881f6ac67f894",
        "name": "",
        "topic": "",
        "showStatusActivities": false,
        "logIOActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "unitid": "1",
        "dataType": "HoldingRegister",
        "adr": "1288",
        "quantity": "1",
        "rate": "500",
        "rateUnit": "ms",
        "delayOnStart": false,
        "startDelayTime": "",
        "server": "4a874db92373c071",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "x": 250,
        "y": 800,
        "wires": [
            [
                "960ae8868fffdaad"
            ],
            []
        ]
    },
    {
        "id": "1424f8d71512dd56",
        "type": "debug",
        "z": "618881f6ac67f894",
        "name": "debug 13",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1000,
        "y": 900,
        "wires": []
    },
    {
        "id": "48c8116905002b2f",
        "type": "modbus-read",
        "z": "618881f6ac67f894",
        "name": "",
        "topic": "",
        "showStatusActivities": false,
        "logIOActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "unitid": "1",
        "dataType": "HoldingRegister",
        "adr": "1057",
        "quantity": "1",
        "rate": "500",
        "rateUnit": "ms",
        "delayOnStart": false,
        "startDelayTime": "",
        "server": "4a874db92373c071",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "x": 250,
        "y": 900,
        "wires": [
            [
                "1424f8d71512dd56"
            ],
            []
        ]
    },
    {
        "id": "ab076dab24091524",
        "type": "debug",
        "z": "618881f6ac67f894",
        "name": "debug 14",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1000,
        "y": 1020,
        "wires": []
    },
    {
        "id": "e92fb0055f7b6121",
        "type": "modbus-read",
        "z": "618881f6ac67f894",
        "name": "",
        "topic": "",
        "showStatusActivities": false,
        "logIOActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "unitid": "1",
        "dataType": "HoldingRegister",
        "adr": "1041",
        "quantity": "1",
        "rate": "500",
        "rateUnit": "ms",
        "delayOnStart": false,
        "startDelayTime": "",
        "server": "4a874db92373c071",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "x": 270,
        "y": 1020,
        "wires": [
            [
                "ab076dab24091524"
            ],
            []
        ]
    },
    {
        "id": "4a874db92373c071",
        "type": "modbus-client",
        "name": "x valley sugar modbus RS485",
        "clienttype": "tcp",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "queueLogEnabled": false,
        "failureLogEnabled": true,
        "tcpHost": "192.168.2.220",
        "tcpPort": "8899",
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyUSB",
        "serialType": "RTU-BUFFERD",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "none",
        "serialConnectionDelay": "100",
        "serialAsciiResponseStartDelimiter": "0x3A",
        "unit_id": "1",
        "commandDelay": "1",
        "clientTimeout": "1000",
        "reconnectOnTimeout": true,
        "reconnectTimeout": "2000",
        "parallelUnitIdsAllowed": true,
        "showWarnings": true,
        "showLogs": true
    },
    {
        "id": "6d29cbc8a3dbce62",
        "type": "openhab2-controller2",
        "name": "Openhab 3",
        "protocol": "http",
        "host": "localhost",
        "port": "8080",
        "path": "",
        "username": "",
        "password": "",
        "ohversion": "v3",
        "token": ""
    }
]

Hi Guys,

Small problem/ question.
After my upgrade to HA core-2023.9.0 I have problems with my modbus setup, I don’t get any info from my Oxilife 2 anymore! My EW11 is perfectly reachable, and he says he is connected to HA and is sending and receiving data!

And in my log I see following error:

Logger: homeassistant.components.modbus.modbus
Source: components/modbus/modbus.py:401
Integration: Modbus (documentation, issues)
First occurred: 10:58:44 (1 occurrences)
Last logged: 10:58:44

Pymodbus: EW11: Modbus Error: [Input/Output] Modbus Error: [Invalid Message] No response received, expected at least 8 bytes (0 received)

Any idea?

regards,

 Jurgen

You might try this

Done, but the success was temporary, 2 minutes! :wink:
Again no data anymore.

I also managed to successfully connect my Sugar Valley Oxilife 2 to my Home Asssitant. There was a question in this thread whether the Oxilife can supply power to the ModBus/RS485 interface device. I measured it and tried it out and can confirm that this is possible. So here is my set-up:

As ModBus/RS485 interface device I’m using the HF5111S from hi-flying.com, here is the overview of their serial server devices: Ethernet Serial Server. You’ll find this in the internet for around 33,-€ incl. shipping:

This one is connected to the EXTERN connector on the Oxilife motherboard:

in the following way:
Oxilife_ModBus_Connection