I’d check the extra ‘for’ line missing in your code:
Which I suspect means - because there’s no line asking what attribute state to check for - that it will check the state every two seconds no matter what. This means the input_select status will be updated correctly even if it has to go through a few states on the way. Personally, I’d probably do it less frequently - maybe once a minute - but that’s a personal choice!
it’s not that. It will only trigger the action if the state has been stable for over 2s.
It’s to reduce the time it takes to change say temperature by doing +, +, + ; otherwise it would send a REST command immediately when you’re adjusting the temperature or like scrolling in the list.
This allows the final command to be sent to the server much quicker. The average time for the server to acknowledge a command is very low sometimes, up to 30s.
So if you to change the temp from 25 to 28 you had sent 4 times a command, it would take over 2 minutes for the final one to be the active one.
Hence why I added a delay of 2s when the state change.
Thanks @jyavenard BTW did anyone figure out how to detect if a channel is actually turned on. EG Pump can have settings Off, Auto, On. And in Auto, it will come on, but the status still returns Auto.
I see in the actual ConnectMyPool app / webinterface that is shows if the pump is actually on or off next to the mode.
@zagnuts I finally made it back to Australia to visit my family after configuring this pool from New York for a full year
Now that I have had time to play with the Viron Connect it makes a little more sense how the channels etc. are all configured. But it has been SO long since I did the configuration.yaml stuff I have totally forgotten how I got there.
So in my yaml I have the following code below (I think I might have copied it from you or did it get auto created when I added the sensor.pool_status?
I configured a bunch of new favourites today, should they automatically be pulled into this code?
Did anyone ever figure out how to control channels through a dropdown in Lovelace so we can simply select a state (i.e. Water Fountain - ON, OFF, AUTO. Same with any other channels?
How are people getting 'Pool Temperature"? I see we can set the heater temp but I am not sure what is measuring the pool temperature as I just get “–” on the gauge.
Anyone have some pre-written code I can copy? I am only in Australia for 3 weeks before heading overseas again.
############################
####Connect My Pool Core####
############################
sensor:
- platform: rest
name: Pool Status
resource: https://www.connectmypool.com.au/api/poolstatus
method: POST
payload: '{ "pool_api_code": "xxxxxxx" }'
force_update: true
json_attributes:
- pool_spa_selection
- heat_cool_selection
- active_favourite
- heaters
- solar_systems
- channels
- valves
- lighting_zones
value_template: 'OK'
scan_interval: 35
verify_ssl: true
headers:
User-Agent: Home Assistant
Content-Type: application/json
###############################
####Connect My Pool Sensors####
###############################
- platform: template
sensors:
pool1_heat_cool_selection:
friendly_name: Pool - Heat Cool Selection
value_template: >-
{{ ['Cooling', 'Heating'][states.sensor.pool_status.attributes["heat_cool_selection"]|int] }}
pool1_temperature:
friendly_name: Heater Temperature
value_template: '{{ states.sensor.pool_status.attributes["temperature"] }}'
device_class: temperature
unit_of_measurement: '°C'
pool1_active_favourite:
friendly_name: Pool - Active Favourite
value_template: '{{ states.sensor.pool_status.attributes["active_favourite"] }}'
pool1_heaters0_mode:
friendly_name: Pool - Heater Mode
value_template: >-
{{ ['Off', 'On'][states.sensor.pool_status.attributes["heaters"][0]["mode"]|int] }}
pool1_heaters0_settemp:
friendly_name: Pool - Heater set temperature
value_template: >-
{{ states.sensor.pool_status.attributes["heaters"][0]["set_temperature"]|int }}
device_class: temperature
unit_of_measurement: '°C'
pool1_channels1_mode:
friendly_name: Pool - Pump Mode
value_template: >-
{{ ['Off', 'Auto', 'On', 'Low Speed', 'Medium Speed', 'High Speed'][states.sensor.pool_status.attributes["channels"][0]["mode"]|int] }}
pool1_light_status:
friendly_name: Pool - Light Status
value_template: >-
{{ ['Off', 'Auto', 'On'][states.sensor.pool_status.attributes["lighting_zones"][0]["mode"]|int] }}
pool1_valves1_mode:
friendly_name: Pool - Valve Mode
value_template: >-
{{ ['Off', 'Auto', 'On'][states.sensor.pool_status.attributes["valves"][0]["mode"]|int] }}
pool1_channels2_mode:
friendly_name: Spa Blower 1
value_template: >-
{{ ['Off', 'Auto', 'On'][states.sensor.pool_status.attributes["channels"][0]["mode"]|int] }}
pool1_channels3_mode:
friendly_name: Second Spa Pump - Current Channel Mode
value_template: >-
{{ ['Off', 'Auto', 'On', 'Low Speed', 'Medium Speed', 'High Speed'][states.sensor.pool_status.attributes["channels"][0]["mode"]|int] }}
pool1_valves3_mode:
friendly_name: Second Spa Pump - Valve Mode
value_template: >-
{{ ['Off', 'Auto', 'On'][states.sensor.pool_status.attributes["valves"][0]["mode"]|int] }}
pool1_channels4_mode:
friendly_name: Waterfall- Current Channel Mode
value_template: >-
{{ ['Off', 'Auto', 'On', 'Low Speed', 'Medium Speed', 'High Speed'][states.sensor.pool_status.attributes["channels"][0]["mode"]|int] }}
pool1_valves0_mode:
friendly_name: Water Feature - Valve Mode
value_template: >-
{{ ['Off', 'Auto', 'On'][states.sensor.pool_status.attributes["valves"][0]["mode"]|int] }}
####################################
####Connect My Pool REST Command####
####################################
rest_command:
poolaction:
url: "https://www.connectmypool.com.au/api/poolaction"
method: post
content_type: 'application/json; charset=utf-8'
# Change the API to match yours. You might want to put this in your secrets file.
payload: '{"pool_api_code": xxxxxxxxx","action_code": {{action_code}},"device_number": {{device_number}},"value": "{{value}}","wait_for_execution": false}'
#########################################
####### ASTRAL SWTICHES ########
#########################################
input_select:
pool_lights_mode:
name: Pool Lights Mode
options:
- "off"
- "auto"
- "on"
icon: mdi:dome-light
pool_light_colour:
name: Pool Lights Colour
options:
- "Ocean"
- "Red"
- "White"
- "Blue"
- "Disco"
icon: mdi:palette
pool_set_temp:
name: Pool Set Temp
options:
- "15"
- "25"
- "35"
icon: mdi:coolant-temperature
waterfall_mode:
name: Waterfall Status
options:
- "off"
- "auto"
- "on"
icon: mdi:dome-light
spa_first_blower:
name: Top Spa Bubbles
options:
- "Auto"
- "On"
- "Off"
icon: mdi:dome-light
water_fountain:
name: Water Fountain
options:
- "Auto"
- "On"
- "Off"
icon: mdi:dome-light
pool_pump:
name: Pool Pump Mode
options:
- "Auto"
- "On"
- "Off"
- "High Speed"
- "Medium Speed"
- "Low Speed"
icon: mdi:dome-light
I am watch this with great interest…I’ve tried to implement some of it…but beyond my 48hours of HA experience. was able to get the first parts to work like status. but once i tried to add switching/status change…isn’t working for me.
be interested if someone is going to pull this together as an add-on/integration to take some of the programming out of it. or is it to variable with how people have implemented the devices on the connect10 to do that?
clear i’ve got more reading…be good if some of the code was condensed into packages with instructions for adding it to the various yaml files or Lovelace cards.
Thank you guys for the hard work…I’m sure I’ll be back with some questions. and posting my code for help soon
my set-up in the Connect 10
-Channel 1 Filter Pump (Viron Variable)
-Channel 2 Lights
-Channel 3 Gas Heater Power
-Channel 4 Blower 1 (Spa)
-Channel 5 Blower 2 (Runway Entry)
-Channel 6 Pump Spa Jets
-Channel 7 Pump for Heat Pump
Would ideally like 2 automations
When an Amber Price spike occurs all pumps turn off
When pool isn’t at temp and Amber price is below $X that HeatPump Pump Runs (Heat Pump turns on and off with flow switch and remains constantly on (poop temp is grabbed by Gas Heater on circuilation/filter pump)
- platform: rest
name: Pool Status
resource: https://www.connectmypool.com.au/api/poolstatus
method: POST
# Change the API to match yours. You might want to put this in your secrets file.
payload: '{ "pool_api_code": "xxxxxx-xxxxxx" }'
force_update: true
json_attributes:
- pool_spa_selection
- heat_cool_selection
- temperature
- active_favourite
- heaters
- solar_systems
- channels
- valves
- lighting_zones
value_template: 'OK'
scan_interval: 120
verify_ssl: true
headers:
User-Agent: Home Assistant
Content-Type: application/json
- platform: template
sensors:
pool1_pool_spa_selection:
friendly_name: Pool - Pool Spa Selection
value_template: >-
{{ ['Spa', 'Pool'][states.sensor.pool_status.attributes["pool_spa_selection"]|int] }}
pool1_temperature:
friendly_name: Pool - Current Temperature
value_template: '{{ states.sensor.pool_status.attributes["temperature"] }}'
device_class: temperature
unit_of_measurement: '°C'
pool1_active_favourite:
friendly_name: Pool - Active Favourite
value_template: '{{ states.sensor.pool_status.attributes["active_favourite"] }}'
pool1_heaters0_mode:
friendly_name: Pool - Heater Mode
value_template: >-
{{ ['Off', 'On'][states.sensor.pool_status.attributes["heaters"][0]["mode"]|int] }}
pool1_heaters0_settemp:
friendly_name: Pool - Heater set temperature
value_template: >-
{{ states.sensor.pool_status.attributes["heaters"][0]["set_temperature"]|int }}
device_class: temperature
unit_of_measurement: '°C'
pool1_heaters0_spa_settemp:
friendly_name: Spa - Heater set temperature
value_template: >-
{{ states.sensor.pool_status.attributes["heaters"][0]["spa_set_temperature"]|int }}
device_class: temperature
unit_of_measurement: '°C'
rest_command:
poolaction:
url: "https://www.connectmypool.com.au/api/poolaction"
method: post
content_type: 'application/json; charset=utf-8'
payload: '{"pool_api_code": "xxxxxx-xxxxxx","action_code": {{action_code}},"device_number": {{device_number}},"value": "{{value}}","wait_for_execution": false}'
verify_ssl: true
switch:
- platform: template
switches:
pool_heater:
value_template: "{{ is_state('sensor.pool1_heaters0_mode', 'On') }}"
friendly_name: Pool Heater Switch
turn_on:
- service: rest_command.poolaction
data:
action_code: 4
device_number: 0
value: 1
- delay: 2
- service: homeassistant.update_entity
entity_id: sensor.pool_status
turn_off:
- service: rest_command.poolaction
data:
action_code: 4
device_number: 0
value: 0
- delay: 2
- service: homeassistant.update_entity
entity_id: sensor.pool_status
Switch doesn’t change anything…do i need to add anything to the automation.yaml or lovelace card to make it work?
I can see the rest_command pool in the developer tools under services
log doesn’t have anything
I made some small changes and added a lighting switch…which works fine…argh
Heater Switch comes right after and looks fine, but doesn’t work…however i did something and now reflects the active state…so that is a bonus
those settings all work perfect to bring in the parameters and current status
I tried changing it and it broke! Button just doesn’t work…but lighting one does!! lol
what is the process to get a switch i can use in an automation for a channel now? because the channels are a sequence…off,auto,on/speeds…moveing forward with each click.
I need an automation to know the state and advance till correct state, but there is significant delay at times
I’ve used this bit of code and it seems to work to advance the mode.
what you describe isn’t particularly complicated, it’s just an automation based on the criteria you want.
You create two automations : one for when to turn off the pool and one on when to turn it on.
for turning it off, the trigger is a numeric state of entity when above 30 or Amber Price above XX
The other to turn on is when pool temp goes < 30 and price is below 0.20
The action for each is to turn on or off the switch you created.
In the triggers, I would add that the value needs to be at that value for say over 5 minutes to avoid turning on and on the HP all the time.
Edit: not working…I don’t see in the visual editor how to toggle the switch that I made…but I can just reuse the code as the YAML in the action section.
Problem is that Pool temp has to change for Automation to activate and despite polling every 35 second and the pool status entity updating, the current pool temp sensor derived from the status entity doesn’t seem to update unless there is a change. or it isn’t updating…can trigger the automation by changing the temp state manual…but isn’t working in auto.
These are the Automations I came up with
Turn On with Price During the Day - If needed (below 30)