Rest Sensor receiving JSON - Astralpool - connectmypool.com.au

I have included everything in the Climate domain in my Homekit configuration, so the Pool Thermostat came up automatically.

If you haven’t got HomeKit integrated to HomeAssistant, you need the Homekit Bridge: HomeKit Bridge - Home Assistant

Has someone makde a light template for the pool light?

I’ve made a switch to turn it on/off and an input_select to change the colour. But not something that look&feel like your usual light settings.

Would be nice if someone did already, if not I’ll wrap something.

Sorry it has been a while since you posted this - but only just saw it! Although I have a d1 mini connected to my system as described much earlier in this thread I don’t bother using it now. Instead I have the following in my ‘switches.yaml’ file:

  - platform: template
    switches:
      pool_fave_filter:
        value_template: "{{ is_state('sensor.pool1_active_favourite', '2') }}"
        friendly_name: Pool Favourite Filter only
        turn_on:
         - service: rest_command.poolaction
           data: 
             action_code: 8 # Set favourite
             device_number: 2 # Filter only= 2, filter and heat pump = 3, all off = 128, all auto = 129, none = 255 - find using api test utility downloaded from connectmypool
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
        turn_off:
         - service: rest_command.poolaction
           data: 
             action_code: 8
             device_number: 255
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
      pool_fave_filterheat:
        value_template: "{{ is_state('sensor.pool1_active_favourite', '3') }}"
        friendly_name: Pool Favourite Filter and Heatpump
        turn_on:
         - service: rest_command.poolaction
           data: 
             action_code: 8
             device_number: 3 
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
        turn_off:
         - service: rest_command.poolaction
           data: 
             action_code: 8
             device_number: 255
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
      pool_fave_allauto:
        value_template: "{{ is_state('sensor.pool1_active_favourite', '129') }}"
        friendly_name: Pool Favourite All Auto
        turn_on:
         - service: rest_command.poolaction
           data: 
             action_code: 8
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
        turn_off:
         - service: rest_command.poolaction
           data: 
             action_code: 8
             device_number: 255
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
      pool_fave_alloff:
        value_template: "{{ is_state('sensor.pool1_active_favourite', '128') }}"
        friendly_name: Pool Favourite All Off
        turn_on:
         - service: rest_command.poolaction
           data: 
             action_code: 8 
             device_number: 128 
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
        turn_off:
         - service: rest_command.poolaction
           data: 
             action_code: 8
             device_number: 255
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status

I have basically setup the favourites as follows:

  • “Filter Only” that has everything off except for the filter pump on medium. For me, using the api tool from connectmypool, this resolves to device number 2
  • “Filter and Heatpump” that has the filter AND my electric heat pump on. For me, this resolves to device number 3.

In addition to those there is the “All Auto” (device 129), “All Off” (device 128). There is also a “none” which is device 255. It seems you can use either 128 or 255 to turn everything off.

With these switches, rather than having to cycle through the settings I can jump straight to what I need. For example, I have an automation that turns on the filter & heat pump (by selecting “Filter and Heatpump”) and sets the target water temp to 26 when my solar panels are generating more than 4kW.

alias: Pool - turn on heat pump if solar > 4kW
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.symo_15_0_3_m_1_ac_power
    for:
      hours: 0
      minutes: 20
      seconds: 0
    above: 4000
condition:
  - condition: state
    entity_id: sensor.pool1_heaters1_mode
    state: "Off"
action:
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.pool_fave_filterheat
  - action: climate.set_temperature
    metadata: {}
    data:
      temperature: 26
    target:
      entity_id: climate.pool_electric_heater_thermostat
  - data:
      title: Pool - Solar greater than 4kW so turning on heatpump! 🌊🏊
      message: |
        Pool - Solar greater than 4kW so turning on heatpump! 🌊🏊
        The pool is currently: {{states('sensor.pool1_temperature') }}
    action: persistent_notification.create
  - data:
      message: Pool - Solar greater than 4kW so turning on heatpump! 🌊🏊
      title: Pool - Solar greater than 4kW so turning on heatpump! 🌊🏊
    action: notify.mobile_app_google_pixel_watch
  - metadata: {}
    data:
      message: >-
        Pool - Solar greater than 4kW so turning on heatpump! Water temp is
        currently {{states('sensor.pool1_temperature')}} 🌊🏊
      title: Pool - Solar greater than 4kW so turning on heatpump! 🌊🏊
      target: [email protected] <- change this
    action: notify.test_gmail_com <- change this
mode: single

I also have another automation that, when the solar generation drops to below 3.5kW it turns off the heater but leaves the filter pump running (by selecting “Filter Only”) then ten mins later (the delay is important - if you turn off the heater AND filter pump at the same time, you risk damaging your water pipes by causing a vacuum as the water cools) it switches the system to “All Auto”

alias: Pool - turn off heater if Solar < 3.5kW
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.symo_15_0_3_m_1_ac_power
    for:
      hours: 0
      minutes: 20
      seconds: 0
    below: 3500
condition:
  - condition: state
    entity_id: sensor.pool1_heaters1_mode
    state: "On"
action:
  - action: switch.turn_on
    target:
      entity_id: switch.pool_fave_filter
    data: {}
  - delay:
      hours: 0
      minutes: 10
      seconds: 0
      milliseconds: 0
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.pool_fave_allauto
  - data:
      title: Pool - Solar less than 3.5kW so turning off heatpump! 🌊🏊
      message: >
        Pool - Solar less than 3.5kW so turning off heatpump and switching to
        auto! Note that need to keep filter running for at least 5 mins after
        switching off heater So will turn off heater, but keep filter running on
        medium for ten mins Then will change to 'auto' The pool is currently:
        {{states('sensor.pool1_temperature') }}
    action: persistent_notification.create
  - data:
      message: Pool - Solar less than 3.5kW so turning off heatpump! 🌊🏊
      title: Pool - Solar less than 3.5kW so turning off heatpump! 🌊🏊
    action: notify.mobile_app_google_pixel_watch
  - metadata: {}
    data:
      message: >-
        Pool - Solar less than 3.5kW so turning off heatpump! Water temp is
        currently {{states('sensor.pool1_temperature')}} 🌊🏊
      title: Pool - Solar less than 3.5kW so turning off heatpump! 🌊🏊
      target: [email protected] <- change this
    action: notify.test_gmail_com <- change this
mode: single

I have put a delay between when the solar trigger (high or low) is seen and when the automations start, to try to minimise ‘flapping’. FWIW We have a gas water heater as well - so basically combined with a pool blanket we can keep the pool water temp close to 26 most of the time mainly using solar so it’s free (well I am losing a little bit by not feeding it back into the grid, but the amount we get paid for that is minimal so no huge loss), which is on the cold side of acceptable for general swimming. If people want it hotter, we can manually use the gas to quickly bump the temperature up as required pretty quickly.

Word to the wise - I noted above:

Ask me how I know. OK, I’ll tell you. If you turn the heater off using the control panel, the system automatically prompts you to say the pump should be left running to avoid damage. If you continue, it will keep the pump running for a few minutes after turning off the heater unless you choose to shut everything off immediately (perhaps because of an emergency such as a water leak).

We discovered that the system did NOT provide that automatic cool down feature if you used the remote control. Astral were not aware of this either, and initially did not believe me when I told them that the remote immediately turned everything off without the safety delay. But basically one day we found that one of the water pipes had collapsed into itself and needed to be replaced. This was a month or two after we installed the second (gas) heater so perhaps because the gas heats the water much more than the electric heat pump the risk of damage is higher. Don’t know. Anyhow, Astral were able to confirm what I told them so they told me that - at least from now on - they were going to warn people about this issue but personally after that I just hid the remote.

I discovered all this before I worked out how to actually control the pool infrastructure via the api, before you ask, but that is why I thought I should mention it being important to keep the filter pump running for a few minutes (I’d suggest 10 minutes) after turning off the heater…

…again, sorry but I only just saw this! As far as I know, no. The challenge is although the lights themselves are probably RGBW the ability to adjust individual colour percentages is not open in the api. It’s even worse than that - although the API provides for up to 50 different pre selected colour combinations, including two colours called “User1” and “User2”, there does not appear to be a way that we can modify what “User1” or “User2” is and only a subset of the colours are likely available as mentioned in the api docs ie “Note that only some options are available based on the type of lighting system installed”. For me, that leaves me just red (1), orange (2), green (4), blue (5), white (7), magenta (13), cyan (14), disco (10), rainbow (16), ocean (17), user1 (8), and pattern (15). Trying to do a standard colour wheel using those - without the ability to blend colours or change brightness - is just going to be broken. For those reasons I’ve just stuck with my input_select option I described earlier in this thread.

As an aside, if you try to set one of the colours that are not supported, in my case for example yellow or purple, you just get an error 17 “Chosen color is not valid for the selected lighting zone”. Yep ‘colour’ without a ‘u’. Tish.

If anyone can find out how to actually change the user1/user2 colours then maybe that might be a way to provide a colour wheel - but at this stage I am not optimistic.

Hi - love your work on this - thanks very much,

If you are still active on the community, is there any chance you can post a sample json formatted file with the ph/orp data etc - just trying to get my file formatting right as my Pool Scape command line sensor has no attributes and I suspect that is because it can’t pull the data into the json pool correctly…

Thanks…

Also - the sensor formatting for command line has changed since '21- think i have it correct as per new yaml, but if you have any updates that might be pertinent that would be terrific…

yep - still here :wink:

okeydoke - not sure if it will be of much help, but here’s what I pull out via parsehub:

{
 "ORP_Status": "OK",
 "ORP_SetPoint": "660",
 "pH": "7.5",
 "LastUpdate": "3 minutes ago"
}

and

My current configuration.yaml has this:

command_line:
  - sensor:
      name: Pool Scrape
      json_attributes:
        - ORP_Status
        - ORP_SetPoint
        - pH
        - LastUpdate
      value_template: "{{ value_json.pool }}"
      scan_interval: 300
      command: 'curl -X GET "https://www.parsehub.com/api/v2/projects/[insert project]/last_ready_run/data?api_key=[insert key]&format=json"|gunzip'

Working for me as of 3 minutes ago, and I’m on 2024.10.1. Easiest thing to do if it’s not working for you is to just paste the url into a web browser and check that the output is sane. eg to pull out the example json above, I just pasted

curl -X GET "https://www.parsehub.com/api/v2/projects/[insert project]/last_ready_run/data?api_key=[insert key]&format=json

into chrome, well with my project and api key of course! Cheers.

Hi Guys!

New to home assistant and been playing around a heap with integrating my pool.
I have everything pretty much going the way i want except for the life of me i cant get the thermostat to work the way i want… I have use the code supplied by @markha and have it able to change the temp of the spa correctly however, the current temp is always wrong… If i use the thermostat to change the pool temp then it updates the pool temp and shows current temp correctly… its just the spa temp i am having issues with…

Hope i have explained that well enough…
Can anyone give me some pointers?

Maybe if you change something and it doesn’t immediately update in home assistant, try the “update_entity” option to force an immediate refresh eg:

  - platform: template
    switches:
      pool_fave_allauto:
        value_template: "{{ is_state('sensor.pool1_active_favourite', '129') }}"
        friendly_name: Pool Favourite All Auto
        turn_on:
         - service: rest_command.poolaction
           data: 
             action_code: 8 # Set favourite
             device_number: 129 # Filter only= 2, filter and heat pump = 3, all off = 128, all auto = 129, none = 255
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
        turn_off:
         - service: rest_command.poolaction
           data: 
             action_code: 8
             device_number: 255
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status

Cheers

Very grateful. All working. Also used the parsehub to grab the solar roof temp and some other things that are not API-able.

This was a terrific solution - thanks for your effort and time.

1 Like

No problem. I enjoy giving back when I can, and I also know that I have in turn benefited from others who have done the same. Not sure that it’s such a great solution long term as these sorts of things are prone to stop working when anything changes, but when there is no other option then yep, is way better than nothing! Cheers.

I am trying to get this first step without success.
I am unsure of [project name] but I do have something in the format of #18 which appears in the top left of my app home screen…
I’ve entered that into the url together with the api key without success - I’ve tried with and without the square brackets. The app on the phone is able to control the pool. Any suggestions welcome

Remove the square brackets, and replace that whole bit with the info from parshub… not sure about the app screen you mention - might be easier to use a pc?

I am on a PC running chrome with latest of everything. I definitely have the api code (from connect my pool) but am continuing to struggle with what should go inside the [insert project]. I think that is all that I am missing but have tried everything I can think of. sorry for a being a bit dumb on this - parsehub is new to me
with thanks

I’ve done some more work and now understand parsehub to an extent! I almost have it working and have set the project up with 2 templates. The first handles the login and seems to cycle okay when run as a test but the 2nd one is pointing to a separate url in the form ‘https://www.connect
mypool.com.au/account/chemistry.aspx’.
unfortunately I don’t seem to get to this point. Any ideas please? (the space in the url is deliberate as it kept being shortened when I posted it)

Ah. I think I see the problem. Keep in mind that there must be a link for the code to jump to the next template.



thank you - I think that has done the trick - regards

1 Like