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

Just realised you can’t use a variable like {{ states('sensor.pool1_channels0_mode') }} in the friendly_name: :frowning: :frowning: I think you could create a HA lovelace sensor button instead that shows the state of the sensor and calls the service switch.turn_on for the switch created above which includes the update_entity - I’ve shared this with my bro to test

type: button
tap_action:
  action: call-service
  service: switch.turn_on
  service_data: {}
  target:
    entity_id: switch.pool_channel1
entity: sensor.pool1_channels0_mode
show_state: true

UPDATE: my brother confirmed this is working with a small delay 2-4 seconds. Could try removing the - delay: 1

One thing that I have noticed in regards to setting a specific state on the Channels - when you switch between ‘POOL’ and ‘SPA’ mode, the Viron10 sets the states instantly without needing to press any buttons, so that means it is technically possible to execute an automation or set a state on a channel.

Has anyone else noticed this? When I click pool, the jets set from OFF to ON, the Lights come on, the Heater turns on and the Pool Filter pump sets to HIGH.

When I click Auto again, everything goes back to Auto.

Is it possible its using a favourite? My brother did say when he cycles through channel for Filter Pump it stops heating when it moves to ‘Off’

Yes, this is what mine does as well.
Pool mode is based on favorite 1 and Spa mode is favorite 2 from what I have found.

When I switch to spa mode, it starts the spa jets and turn the heater on. My issue is that when I change back to pool mode, it either turns everything off, or starts the filter pump depending on how Favorite 1 is set. Seems to be the same as what you are saying. Would like Pool mode to return to “All Auto”

I am still waiting for my API Key.

I am also thinking of using the 2 customisable switch’s, I am thinking of connecting a Wemos D1 running ESPHome using 2 relays, I could then use this to activate these to activate the 'All Auto" once back in pool mode. Unless these is a way to do this with the API.

Hi all,
I’ve just about got everything I wanted working by using favourites for everything.

I’m trying to see if there is a way with the “pool lights” button card can I do a hold_action to then call up the input select for the colour options.

        - type: button
          tap_action:
            action: call-service
            service: rest_command.poolaction
            service_data:
              action_code: 8
              device_number: 4
            target: {}
          hold_action:
            action: call-service
            service: input_select.select_option
            service_data: input_select.pool_light_colour
          name: Pool Lights

my pool light options are;

 pool_light_colour:
    name: Pool Lights Colour
    options:
      - "Red"
      - "Orange"
      - "Green"
      - "Blue"
      - "White"
      - "Magenta"
      - "Cyan"
      - "Disco"
      - "Rainbow"
      - "Ocean"

I’m guessing its target function but I have no idea on the syntax for that.
If I’m way off and it can’t be done, I’ll break it back out to two cards.

thanks again for for your help

Wow that’s great on HA. I gather I need the Connect 10 Internet Gateway. About $580 right?

BTW given HA runs locally - can you connect directly to the connect 10 gateway device rather than having to go via the connectmypool.com.au - surely it would be much more responsive being locally connected. I gather @smck83 @remsta you’ve investigated this previously… anyway very cool.

Very doable - see my code above (Rest Sensor receiving JSON - Astralpool - connectmypool.com.au - #59 by zagnuts). It definitely can be done via the API though, so probably not a huge advantage to do it other than because you can… :wink:

Great work guys, got my API today and already have it up and running.

Does anyone have a separate spa, the spa temperature doesn’t seem to be exposed to the API, I have noticed that the app always shows the pool temp regardless of mode.

Yes you do @hammermcg , not sure on the cost. requested mine as part of the pool install

Super thanks - I’ll go ahead and order

Yeah - it’s not cheap, and don’t forget you’ll need to allow for installation etc. If you don’t have it, but do have a remote control, it might be cheaper to get a rm pro or similar and use that instead.

I haven’t seen a way to connect directly to it, but yes that would have been nice. Response wise though, it’s proving not to be too bad other than a brief outage the other day. The other thing is you do have the option for activating the ‘all auto’ and a user selected favourite by connecting a couple of relays to the main controller, so that also avoids having to go through a remote service…

Thanks @zagnuts - I’d already connected a Fibaro Implant (z-wave) to the two inputs on the Connect 10 main board to switch on the spa and back to all-auto. Was using the Vera Z-wave controller, but moved to HA. I’ve ordered internet gateway. Will let you know how I get on.

Sweet. Have a vera as well - integrates well with HA as well as vera concierge… :slight_smile:

@zagnuts

Did you have any luck with this?

No - I got distracted trying moving my Tuya kit to the new integration. I might have another look at it this weekend if I get the chance. I promise to update this thread if I do get it to work using multiscrape rather than parsehub… I should note that it definitely does work with parsehub, it just (for me) seemed to not always fire.

So, I’ve given up trying to get the info via the built in scrape tool, or by multiscrape. For whatever reason, I suspect the authentication side of things simply isn’t working. I expect it should be possible, but the solution eludes me. If someone else would like to give it a go, please feel free, but I’ve gone back to using parsehub with some minor tweaks as follows:

  • Create a project on parsehub that is able to grab the pH info. I also grabbed the orp status, setting, and last update info although they are all fairly pointless.
  • Use the shell command to run the scrape every (say) 30 mins. The levels shouldn’t fluctuate all that much so that should be more than enough. Also keep in mind that the info will only update when the pool filter is running. I found that this would stop running randomly when I first set it up, so instead I changed this to be executed via an automation eg: in your automations.yaml, create the following (easiest thing is to create it via the gui, edit in yaml, and paste:
alias: Parsehub - run pool scrape
description: ''
trigger:
  - platform: time_pattern
    minutes: /30
condition:
  - condition: time
    after: '09:00:00'
    before: '18:00:00'
action:
  - service: shell_command.run_pool_parsehub
mode: single

This runs the parsehub scrape command every 30 minutes, between 9am and 6pm. Obviously you can change that if you want. I figure that the pH etc won’t change that quickly, plus I don’t want to hit the parsehub or connectmypool servers too hard. Also keeping in mind that the data only gets updated whilst the filter pump is running.

And in configuration.yaml insert:

shell_command:
  run_pool_parsehub: 'curl -X POST "https://www.parsehub.com/api/v2/projects/magicnumbers/run?api_key=magicnumbers"'

Changing the ‘magicnumbers’ to match your project and api key in parsehub. This asks parsehub to run the saved project.

  • Use the command_line integration to download the info as a gzip json file, and add the attributes to a sensor. So add this into your sensor.yaml file (or configuration.yaml file if you have everything in the one file)
  - platform: command_line
    name: Pool Scrape
    json_attributes:
      - ORP_Status
      - ORP_SetPoint
      - pH
      - LastUpdate
    command: 'curl -X GET "https://www.parsehub.com/api/v2/projects/[magic stuff]/last_ready_run/data?api_key=[more magic stuff]&format=json"|gunzip'
    value_template: "{{ value_json.pool }}"
    scan_interval: 300
  • Create individual sensors to pull out the info from the main sensor attribute, again in the sensor.yaml or configuration.yaml file
  - platform: template
    sensors:
      pool1_ph_status:
        friendly_name: Pool - pH
        value_template: '{{ states.sensor.pool_scrape.attributes["pH"] }}'
        unit_of_measurement: 'pH'
      pool1_orp_status:
        friendly_name: Pool - ORP Status
        value_template: '{{ states.sensor.pool_scrape.attributes["ORP_Status"] }}'
      pool1_orp_setpoint:
        friendly_name: Pool - ORP Set Point
        value_template: '{{ states.sensor.pool_scrape.attributes["ORP_SetPoint"] }}'
        unit_of_measurement: 'mV'
      pool1_lastupdate:
        friendly_name: Pool - pH Last Update
        value_template: '{{ states.sensor.pool_scrape.attributes["LastUpdate"] }}'
      pool1_lastscrape:
        friendly_name: Pool - pH Last Scrape
        value_template: "{{ as_timestamp(state_attr('automation.parsehub_run_pool_scrape', 'last_triggered')) | timestamp_custom('%A @ %-I:%M %p') }}"

  • Enjoy

I should note that by moving the commands to fire off the parsehub project into an automation, I’ve found this to be pretty reliable. It is also a lot easier to tweak when it actually runs than it was before. As an aside, I did try to combine everything into the one command - and it would have worked but the script takes just over a minute to run and HA has a non-configurable 60 second limit to scripts so it would timeout. So computer says no. :wink:

Looks like www.connectmypool.com.au has been down (for a couple of days?)

image

It would be good not to depend on going through the cloud to read/write data to the Astral internet gateway device to avoid situations like this.

PS I’ve got a number of things going with the code above. Also using a Fibaro Smart Implant added to our Hayward Heatpump unit - connected in to measure the input/output temperature sensors (measuring the voltage) and converting it from voltage to temp - seems to work ok.

A big +1 from me, in particular given that the server has gone down a few times over the past couple of months. Sadly, however, I don’t think that we have much choice. I’ve done a quick scan of the gateway, and no obvious ports seem to be open. Now of course this is pool equipment, not a mainframe at the CIA, so I have to assume it would be more than possible to somehow capture the info going to/from the gateway and then in turn spoof that but meh, I have better things to do with my life. :wink:

Speaking of which, I updated my sensor code above to include an extra one that lets me know when the scrape last ran. Not super critical, but hey - why not.

I’ve got most stuff working.

Yet to play with the code for the Ph etc a go - but will do that next - thanks for sharing (and updating).

Read with interest this thread. Got my pool completed last Friday and got an internet gateway. As mentioned, the app is really poor.

So I wrapped this screen today:

All buttons are effective and will reflect within a few seconds the action performed.

To sync the input_select list I used the following script:

- alias: Sync Light Colour from Input Select
  trigger:
    - platform: state
      entity_id: input_select.pool_light_colour
      for: 00:00:02
  condition: []
  action:
    - service: rest_command.poolaction
      data_template:
        action_code: 7
        device_number: 0
        value: >
          {% set coloursDict = { '-': 0, 'Red' : 1, 'Orange': 2 , 'Yellow' : 3 , 'Green' : 4 , 'Blue' : 5, 'Purple' : 6, 'White' : 7, 'User 1' : 8, 'User 2': 9, 'Disco': 10, 'Smooth': 11, 'Fade': 12, 'Magenta':13, 'Cyan':14, 'Pattern':15, 'Rainbow': 16, 'Ocean': 17 } %}
          {{ coloursDict[states('input_select.pool_light_colour')] }}
    - delay: 5
    - service: homeassistant.update_entity
      entity_id: sensor.pool_status
  mode: single
- alias: Sync Light Colour from Sensor
  trigger:
    - platform: state
      entity_id: sensor.pool_light_colour
      for: 00:00:02
  condition: []
  action:
    - service: input_select.select_option
      target:
        entity_id: input_select.pool_light_colour
      data_template:
        option: >
          {{ states('sensor.pool_light_colour') }}
  mode: single

- alias: Sync Gas Heater Temperature
  trigger:
    - platform: state
      entity_id: input_select.pool_gas_set_temp
      for: 00:00:02
  condition: []
  action:
    - service: rest_command.poolaction
      data_template:
        action_code: 5
        device_number: 1
        value: >
          {{ states('input_select.pool_gas_set_temp') }}
    - delay: 5
    - service: homeassistant.update_entity
      entity_id: sensor.pool_status
  mode: single

- alias: Sync Heat Pump Heater Temperature
  trigger:
    - platform: state
      entity_id: input_select.pool_heatpump_set_temp
      for: 00:00:02
  condition: []
  action:
    - service: rest_command.poolaction
      data_template:
        action_code: 5
        device_number: 2
        value: >
          {{ states('input_select.pool_heatpump_set_temp') }}
    - delay: 5
    - service: homeassistant.update_entity
      entity_id: sensor.pool_status
  mode: single

Which I believe is a bit better than the solution given above that creates as many automations as there are colours.

All buttons are toggles: in the spa can set the blower and the two different jets pump.
The list of pumps have a tap action to cycle between the modes and the text will reflect that.

The action to switch in the entities card is call this script:

alias: Cycle Channel
mode: single
sequence:
  - service: rest_command.cyclechannel
    data:
      channel: "{{ channel }}"
  - delay: 5
  - service: homeassistant.update_entity
    entity_id: sensor.pool_status

The rest_command.yaml being:

poolaction:
  url: "https://www.connectmypool.com.au/api/poolaction"
  method: post
  content_type: "application/json; charset=utf-8"
  payload: '{"pool_api_code": "ABCDEF-1234567","action_code": {{ action_code }}, "device_number": {{ device_number }}, "value": "{{ value }}", "wait_for_execution": false}'
  verify_ssl: true

cyclechannel:
  url: "https://www.connectmypool.com.au/api/poolaction"
  method: post
  content_type: "application/json; charset=utf-8"
  payload: '{"pool_api_code": "ABCDEF-1234567","action_code": 1, "device_number": {{ channel }}, "value": "", "wait_for_execution": false}'
  verify_ssl: true

It shouldn’t be too complicated to write an integration that automatically create the input_select list for t for the favourites as can be retrieved from the poolconfig action.
And that present the lighting like a proper coloured lights.

Though, as everything is really custom with likely no generic configuration, I’m not sure it’s worth spending the time on this.

View with blower on, phone in landscape:

Tapping on the pool temperature in the centre also let you change it.

Do you guys know if it’s possible to get the status of the pump or heater when in Auto mode?

On the Astral app or website, you see a little symbol next to the switch to indicate that it’s on. But I don’t see that anywhere in the poolstatus data.