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…
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…
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.
Looks like www.connectmypool.com.au has been down (for a couple of days?)
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.
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.
unfortunately not through the API. you could try scrapping the website as mentioned above. I am planning on doing this for my gas heater so i can see when it is actually heating so I can then make some assumptions on the gas usage.
Hi guys,
Fantastic work!
I’ve have everything working with my system, but I’m a little stuck on configuring a dropdown in Lovelace to set the heater temperature.
Would anyone be able to help with the required code, please?
Thanks so much!
I wrote that code in the post above.
This is the input_select
components I’ve created
pool_lights_mode:
name: Pool Lights Mode
options:
- "off"
- "auto"
- "on"
icon: mdi:dome-light
pool_light_colour:
name: Pool Lights Colour
options:
- "Red"
- "Orange"
- "Green"
- "Blue"
- "White"
- "User1"
- "Disco"
- "Magenta"
- "Cyan"
- "Pattern"
- "Rainbow"
- "Ocean"
pool_heatpump_set_temp:
name: Heat Pump Set Temp
options:
- "18"
- "19"
- "20"
- "21"
- "22"
- "23"
- "24"
- "25"
- "26"
- "27"
- "28"
- "29"
- "30"
icon: mdi:coolant-temperature
pool_gas_set_temp:
name: Gas Heater Set Temp
options:
- "18"
- "19"
- "20"
- "21"
- "22"
- "23"
- "24"
- "25"
- "26"
- "27"
- "28"
- "29"
- "30"
- "31"
- "32"
- "33"
- "34"
- "35"
- "36"
- "37"
- "38"
icon: mdi:coolant-temperature
pool_set_favourite:
name: Pool Set Favourite
options:
- "All Off"
- "All Auto"
- "Pool"
- "Spa"
icon: mdi:heart-plus-outline
The automations to sync all of those into the required REST commands are in the post prior to yours
Hi @zagnuts, others, I’ve been trying to update the state of the input_select for the pool favourite to match that from the API, but doesn’t seem to be working. IE when someone changes the pool mode on the controller or changes the mode via myconnect app.
I tried adding the automation below to the automations.yaml. The names of the favourites match the input_select options. Any thoughts anyone? have you used some other mechanism to update the input_select value to match the sensor.pool_favourite_active. One issue I can see is that the sensor takes a while to update - but should be ok still ??
- id: '1640827860154'
alias: Pool Mode - Update Selector
description: If the state changes update the input_select for Pool Mode
trigger:
- platform: state
entity_id: sensor.pool_active_favourite
condition: []
action:
- service: input_select.select_option
target:
entity_id: input_select.pool_favourites
data:
option: "{{ states('sensor.pool_active_favourite') }}"
mode: single
I see what you’re trying to do there - I had noticed the same issue (the state of the input_select doesn’t get updated if it is changed outside of HA), but hadn’t really bothered to make a work around. Check out the post above from Jean-Yves (Rest Sensor receiving JSON - Astralpool - connectmypool.com.au - #97 by jyavenard).
Thanks - my solution doesn’t work very reliably as there is a bit of a delay and loop in that the input_select is changing the sensor favourites which seems to go to All Off before going to the new state which then sets input_select to All Off and this triggers the sensor (actual state to go to All Off) rather than the new state. I think because a) goes through All Off before the new state and b) the delay in updates.
Will look at Jean-Yves post - I didn’t seen anything pop out for this on first pass. Cheers