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

no I think you miss understood me…it shouldn’t flog on and off every 30 seconds.

and i probably don’t understand why it isn’t working

at the moment the automation will only run if i force a state change of sensor.pool1_temperature in the developer tool. it also shows that this variables doesn’t update often…says now last update and last change were 2 hours ago when i forced a change

meanwhile sensor.pool_status is updating every 35seconds the status of the pool variables.

i think the automation isn’t working because of this discrepancy

Worked out what the issue with my automations is. Trying to trigger with an attribute. Pool current temp is an attribute as is electricity.

Not sure yet how to solve

Create a template sensor using the attribute. Then use that sensor as the trigger

Ok. I’ll have a look and try and figure it out…I thought that was what sensor.pool1_temperature was and that I could just use that value as above or below to trigger. But doesn’t seem to trigger

I rebuilt the automations, starting with notify and then adding…but without time conditions and it works fine…hmmm…was relying on the time components to keep it from making loops switching on and off gear too soon

but at least it is triggering now…no idea what im doing or why it wouldn’t work, but now does

- id: '1644103858438'
  alias: Price Alert - Pool Off
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.durst_home_general_price
    above: '0.28'
  condition:
  - condition: state
    entity_id: sensor.pool1_channels4_mode
    state: 'On'
  action:
  - service: notify.notify
    data:
      message: Pump Off - Expensive
      title: Electricity - High Price - Pump Off
  - service: rest_command.poolaction
    data:
      action_code: 1
      device_number: 5
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: homeassistant.update_entity
    entity_id: sensor.pool_status
  mode: single
- id: '1644105194977'
  alias: Pool Hot - Pump Off
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.pool1_temperature
    above: '30'
  condition:
  - condition: state
    entity_id: sensor.pool1_channels4_mode
    state: 'On'
  action:
  - service: notify.notify
    data:
      message: Pool Hot - Pump Off
      title: Pool Hot - Pump Off
  - service: rest_command.poolaction
    data:
      action_code: 1
      device_number: 5
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: homeassistant.update_entity
    entity_id: sensor.pool_status
  mode: single
1 Like

Was Working…but now getting some warnings and errors and not working again ugh…

Logger: homeassistant.helpers.template
Source: helpers/template.py:1822 
First occurred: 3:29:50 AM (2 occurrences) 
Last logged: 3:29:50 AM

Template variable warning: 'mappingproxy object' has no attribute 'temperature' when rendering '{{ states.sensor.pool_status.attributes["temperature"] }}'
Template variable warning: 'mappingproxy object' has no attribute 'active_favourite' when rendering '{{ states.sensor.pool_status.attributes["active_favourite"] }}'
Logger: homeassistant.components.template.template_entity
Source: components/template/template_entity.py:167 
Integration: Template (documentation, issues) 
First occurred: 3:29:50 AM (8 occurrences) 
Last logged: 3:29:50 AM

TemplateError('UndefinedError: 'mappingproxy object' has no attribute 'heaters'') while processing template 'Template("{{ states.sensor.pool_status.attributes["heaters"][0]["spa_set_temperature"]|int }}")' for attribute '_attr_native_value' in entity 'sensor.pool1_heaters0_spa_settemp'
TemplateError('UndefinedError: 'mappingproxy object' has no attribute 'lighting_zones'') while processing template 'Template("{{ ['Off', 'Auto', 'On'][states.sensor.pool_status.attributes["lighting_zones"][0]["mode"]|int] }}")' for attribute '_attr_native_value' in entity 'sensor.pool1_lighting_zones'
TemplateError('UndefinedError: 'mappingproxy object' has no attribute 'channels'') while processing template 'Template("{{ ['Off', 'Auto', 'On'][states.sensor.pool_status.attributes ["channels"][4]["mode"]|int] }}")' for attribute '_attr_native_value' in entity 'sensor.pool1_channels4_mode'
TemplateError('UndefinedError: 'mappingproxy object' has no attribute 'channels'') while processing template 'Template("{{ ['Off', 'Auto', 'On', 'Low Speed', 'Medium Speed', 'High Speed'][states.sensor.pool_status.attributes ["channels"][0]["mode"]|int] }}")' for attribute '_attr_native_value' in entity 'sensor.pool1_channels0_mode'
TemplateError('UndefinedError: 'mappingproxy object' has no attribute 'channels'') while processing template 'Template("{{ ['Off', "Auto", 'On'][states.sensor.pool_status.attributes ["channels"][5]["mode"]|int] }}")' for attribute '_attr_native_value' in entity 'sensor.pool1_channels5_mode'

Logger: homeassistant.components.homeassistant.triggers.numeric_state
Source: components/homeassistant/triggers/numeric_state.py:179 
Integration: Home Assistant Core Integration (documentation, issues) 
First occurred: 3:29:50 AM (2 occurrences) 
Last logged: 3:29:50 AM

Error in 'Pool Hot - Pump Off' trigger: In 'numeric_state' condition: entity sensor.pool1_temperature state '' cannot be processed as a number
Error in 'Pump On - Pool Cold' trigger: In 'numeric_state' condition: entity sensor.pool1_temperature state '' cannot be processed as a number

here is one of the automations (works fine if manual update in developer tools, but isn’t triggering on its own…but the temp gauge on dashboard is working

- id: '1644106618859'
  alias: Pump On - Pool Cold
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.pool1_temperature
    below: '31'
  condition:
  - condition: time
    after: 08:10:00
    before: '20:30:00'
  - condition: state
    entity_id: switch.pool_channel4
    state: 'off'
  - condition: numeric_state
    entity_id: sensor.durst_home_general_price
    below: '0.15'
  action:
  - service: notify.notify
    data:
      message: Pump On - Pool Cold
      title: Pump On - Pool Cold
  - service: rest_command.poolaction
    data:
      action_code: 1
      device_number: 5
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: homeassistant.update_entity
    entity_id: sensor.pool_status
  mode: single

and Here is my entire config file (which is only for this at this point)…switches work and update status correctly, temp sensor on dashboard shows correct current temp…not sure.

although think it is time I split my config file


# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate
##

##
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
##
sensor:
#
  - 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-xxxxxxx" }'
    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: 35
    verify_ssl: false
    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'
      pool1_lighting_zones:
        friendly_name: Lighting Mode
        value_template:   >-
          {{ ['Off', 'Auto', 'On'][states.sensor.pool_status.attributes["lighting_zones"][0]["mode"]|int] }}
      pool1_channels4_mode:
        friendly_name: HeatPump Pump
        value_template:   >-
          {{ ['Off', 'Auto', 'On'][states.sensor.pool_status.attributes ["channels"][4]["mode"]|int] }}
      pool1_channels0_mode:
        friendly_name: Pool Circulation Pump
        value_template:   >-
          {{ ['Off', 'Auto', 'On', 'Low Speed', 'Medium Speed', 'High Speed'][states.sensor.pool_status.attributes ["channels"][0]["mode"]|int] }}
      pool1_channels5_mode:
        friendly_name: Spa Jets Mode
        value_template:   >-
          {{ ['Off', "Auto", 'On'][states.sensor.pool_status.attributes ["channels"][5]["mode"]|int] }}
#          
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

  cyclechannel:
    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": 1, "device_number": {{ channel }}, "value": "", "wait_for_execution": false}'
    verify_ssl: true
##

switch:

#########################################
####### ASTRAL POOL LIGHT SWTICH ########
#########################################
  - platform: template
    switches:
      pool_lights:
        value_template: "{{ is_state('sensor.pool1_lighting_zones', 'On') }}"
        friendly_name: Pool Light Switch
        turn_on:
         - service: rest_command.poolaction
           data: 
             action_code: 6
             device_number: 0
             value: 2
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
        turn_off:
         - service: rest_command.poolaction
           data: 
             action_code: 6
             device_number: 0
             value: 1
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
#
  - platform: template
    switches:
      pool_spa_selection:
        value_template: "{{ is_state('sensor.pool_spa_selection', 'Pool') }}"
        friendly_name: Pool Spa Mode Switch
        turn_on:
         - service: rest_command.poolaction
           data: 
             action_code: 3
             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: 3
             device_number: 0
             value: 0
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
#
  - platform: template
    switches:
      pool_heater:
        value_template: "{{ is_state('sensor.pool1_heaters0_mode', 'On') }}"
        friendly_name: "Pool Heater Switch - {{ states('sensor.pool1_heaters0_mode') }}"
        turn_on:
         - service: rest_command.poolaction
           data: 
             action_code: 4
             device_number: 1
             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: 1
             value: 0
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
#########################################
####### ASTRAL POOL CHANNEL4 TOGGLE #####
#########################################
  - platform: template
    switches:
      pool_channel4:
        value_template: "{{ is_state('sensor.pool1_channels4_mode', 'On') }}" 
        friendly_name: "Heater Pump - {{ states('sensor.pool1_channels4_mode') }}"
        turn_on:
         - service: rest_command.poolaction
           data: 
             action_code: 1
             device_number: 5
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
        turn_off:
         - service: rest_command.poolaction
           data: 
             action_code: 1
             device_number: 5
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
#########################################
####### ASTRAL POOL CHANNEL5 TOGGLE #####
#########################################
  - platform: template
    switches:
      pool_channel5:
        value_template: "{{ is_state('sensor.pool1_channels5_mode', 'On') }}" 
        friendly_name: "Spa Jets - {{ states('sensor.pool1_channels5_mode') }}"
        turn_on:
         - service: rest_command.poolaction
           data: 
             action_code: 1
             device_number: 6
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
        turn_off:
         - service: rest_command.poolaction
           data: 
             action_code: 1
             device_number: 6
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
#########################################
####### ASTRAL POOL CHANNEL0 TOGGLE #####
#########################################
  - platform: template
    switches:
      pool_channel0:
        value_template: "{{ is_state('sensor.pool1_channels0_mode', 'Auto') }}" 
        friendly_name: "Circulation Pump - {{ states('sensor.pool1_channels0_mode') }}"
        turn_on:
         - service: rest_command.poolaction
           data: 
             action_code: 1
             device_number: 0
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
        turn_off:
         - service: rest_command.poolaction
           data: 
             action_code: 1
             device_number: 0
         - delay: 2
         - service: homeassistant.update_entity
           entity_id: sensor.pool_status
#########################################
####### ASTRAL POOL CHANNEL1 TOGGLE #####
#########################################
##

Started on this Journey almost solely to get some better control of the pool heating…/.by turning off the pump rather then Heater (Heatpump) when either temp was reached or electricity through amber was expensive…beofe 5 days ago, I had zero HA experience…and haven’t ever done programming beyond a high school class or two… 30 Years ago

I posted a pretty big question last week but unfortunately still haven’t made any progress - wondering if anyone has the answer?

In addition, did you work out how to set a specific state for a Channel. i.e. Spa Jet - like you said, we dont want to press the button 3 times - off/auto/on - how can we get straight to just on and off.

Thanks

You can’t.

I’ve tried using a condition to check on channel status in my automation. Which works most of the time.

But 2-3 times a day it shits itself. Think the pool status call returns null or something. See my errors above. And both triggers the automation and mis-reads the pump state. Turning it off when it is on or vice versa.

I removed timer access on the Connect10 to get that channel down to a binary set of options.

Was hoping to start automation on circulation pump next. Which would require minimum 3-4 states, even if I remove timer/auto from the Connect10 panel. Wondering about just having a loop that moves it forward, waits, checks, moves it forward, waits, checks. Until desired state is achieved.

Problem is that the system does occasionally take long periods to respond or even end up in a bit of a lock

Going to look today at using the favorites as a more reliable way of getting the settings I want.

I’ve got my automations working. The errors are still messing them up a little, which requires manual intervention occasionally. Wondering if I could add some kind of delay or condition of the state being stable for a period of time to have the automation skip these events.

Well, many months later I finally received my API key after having to call up to request it as the website did not result in me getting one. I have finished my first round of controls, which was just a modest list of things to do. I have a ZigBee remote control to switch the heater and blower for my spa on and off, one to manually turn the lights on and off and one to set the whole lot back to All Auto. This way I can control the spa while in it rather than needing my phone, to get out and use the touch screen or the expensive Astral remote control.

Because of the limitations within the API for controlling the channels, I definitely think we are better off using favourites to set a specific state and then recall that favourite rather than try to cycle through states. It just seems far more reliable and less complicated.

Is the only way to switch the circulation pump through Connect10, if that is proving problematic?

I control my pump by switching the power socket on/ off remotely and it seems to work smoothly.

If it was a single speed pump then it is relatively as I have set up with the heater pump…because the options are binary (just have to figure out how to deal with the exception where an error occurs…either call isn’t replied or something…I think returning null values)

the issue is variable speed pumps…where you want to run it on high for one application (spa mode circulation to ensure sufficient flow for gas heater, or first 2x turnover off the pool in the morning (mixes all the water and stabilises ph, orp and temp readings…then advances to a lower speed to save money…it is dealing with changing the pump from various speeds that is a problem. (assuming you are removing timer functions with create and additional state.

Pumps can have the following states ‘Off’ = 0, ‘Auto’ =1, ‘On’ =2, ‘Low Speed’ =3, ‘Medium Speed’=4, ‘High Speed’=5

Single speed pump will return a status of 1 or 2 on the channel if auto is disabled and 1,2,3 if timers are enabled

Variable speed pumps will return 0,?2?,3,4,5

the only way to change a channel mode is to advance it with a command of action code 1 to the device/channel number (circulation pump controlled by chlorinator is device/channel0)

Issues 1) state can’t be called directly, 2) there is a delay in updating that is slightly inconsistent

Homekit integration works well…I can control spa jets, blower, switch to spa mode and turning on and off the gas heater, lights by talking to my apple watch…saves both the touch screen panel or the app.

The nice thing about having a remote with dedicated buttons is that anyone can use it. I have the app setup on my wifes phone but it doesn’t get used, she normally just askes me to turn it on. So with a remote the kids or wife can just grab it and go, also it was $20 so if it gets destroyed I don’t mind. A lot of what I do at home revolves around being unintimidating so that anyone can use the technology without needing to know what they are doing.

I’m in the same boat…three young kids and wife that is not into technology.

I’m deep into HomeKit as a system and apple since 198X when i was kid and my mom brought home our first computer a Apple Mac Plus.

Kids each have iPads (school and entertainment) and a HomePod Mini in their room. Plus we have 3 original home pods and an appleTV.

Talking is just so natural…asking for what you want…Key is getting the naming of devices right so requests are natural and don’t confuse Siri…like the light on out ceiling fan - siri kept saying she couldn’t control two devices at once because I named it “Ceiling Fan Light” - but “Ceiling Fan LED” was fine :crazy_face: - Broadlink RF controlled instead of original remote

Yeah, I have it both working with Alexa and HomeKit.

So hey Siri, turn on the spa blower
or hey Siri, turn on the spa jet, or pool lights.

works great.
Can do it with my Apple Watch while sitting in the spa. Having to get out to press the button on the controller was a PITA

@ThirtyDursty and @jyavenard I agree nothing worse than getting out to change something :frowning:. We are anti voice assistant here, although I have a google mini that was sent to me for free it is still in the box.

do you get those template errors in your log?

Template variable warning: 'mappingproxy object' has no attribute 'temperature' when rendering '{{ states.sensor.pool_status.attributes["temperature"] }}'
Template variable warning: 'mappingproxy object' has no attribute 'active_favourite' when rendering '{{ states.sensor.pool_status.attributes["active_favourite"] }}'

is a digression from the thread…but I would never give Google or Amazon voice…think both are fairly moraless in the pursuit of their missions…

and while Apple isn’t perfect or Mother Teresa, I do feel they have some better ethics that underpin their focus on privacy

So this is wierd - one my my channels (5) Spa Jet does not have an auto function - it is only showing ‘Off’/‘On’ both online and on the Viron itself. Not show how on earth that happened but it might be possible to get rid of the ‘Auto’ on each channel. Because when I set everything back to Auto - it goes to off. Then when I select Spa Mode it switches on… so there is no need for auto.

Anyone have any ideas how that happened?