Temp Sensor not triggering Automation

Hello

Trying to build an automation that uses a pool temp sensor entity to trigger

Built on the Astral Connect My Pool API

can’t even get it to trigger. have tried also mapping it to entity_id: sensor.pool_status and attribute: temperature but no luck there either

- id: '1644365985041'
  alias: Pool Cold - Pump On
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.pool1_temperature
    below: '31'
  condition: []
  action:
  - service: notify.notify
    data:
      message: Pool Cold Pump On
      title: Pool Cold Pump On
  mode: single

Sensor shows up on dashboard and updates every 61 seconds…is accurate to the pool
sensor config

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": "xxxx-xxxx" }'
    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: 61
    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] }}
#          

No associated log errors or warnings

Developer tools shows the entities correctly with the values expected and align with pool controller

I’m not sure but I think you shouldn’t quote the number in

below: '31'

This is a number not a string.

Has the temperature ever gone above 31 and then back below 31 yet?

Ok. This might be the issue. I assumed I’d get a call since it is under 31.

Was going to add to this. With some other conditions. Maybe this is the wrong trigger?

But basically I want the pump to turn on

  • anytime the temp goes below 31 (as it is whole numbers will turn on at 30 or less)
  • 8:30 - 9pm
  • and energy price is less than 0.15/kWh

-needs to turn off and on with temperature
-off and on with energy price

  • Turn off at 9pm
  • and turn back on the next day (pool will already be cooler, as it looses ~2c overnight in summer and 3-5c in winter) the first time and anytime those conditions are met.

Plan was for one on automation using temp below and then conditions and then a few pump off automations.

Maybe not skinning the cat the right way.

If you are happy for it to only trigger when the temp goes from 31 or higher to below 31 then this will work. If the pool temp is already 30 or below then nothing will happen, as finity has eluded to.

Since you now have other parameters you want to check against you can simply use the time as the trigger and the temp and energy price as conditions

2 Likes

Won’t that just run it once at 8:30am and turn it on if conditions met.

what if conditions (electricity price) isn’t met till 10am?

or what if it hits temp and then cools. do I need a second automation…or can I just use multiple triggers? with those triggers also conditions?

if I have multiple triggers, could I use all these as a trigger?
Triggers
Time 8:30am
Temp Below 31c
Elec Below 0.16/kwh

Conditions
Time 8:30am-9pm
Temp Below 31c
Elec Below 0.16/kwh

Action: Pump On

Then another Automation in reverse for pump off?
Time 9pm
Temp Above 31c
Elec Above 0.16/kwh

Conditions
Time 8:30am-9pm
Temp Above 31c
Elec Above 0.16/kwh

Action Pump Off

Correct. However you can also use a time trigger to check say every 5 mins and then include the 8 til 9:30 time parameter as a condition also.

Definitely. I do this for a few things myself.

1 Like

Thank you

This is what I came up with

we’ll see what happens :slight_smile:

- id: '1644384248232'
  alias: Pump On
  description: ''
  trigger:
  - platform: time
    at: 08:00:00
  - platform: numeric_state
    entity_id: sensor.pool_status
    below: '31'
    attribute: temperature
  - platform: numeric_state
    entity_id: sensor.durst_home_general_price
    below: '0.16'
  condition:
  - condition: time
    after: 08:00:00
    before: '21:00:00'
  - condition: numeric_state
    entity_id: sensor.durst_home_general_price
    below: '0.16'
  - condition: numeric_state
    entity_id: sensor.pool_status
    attribute: temperature
    below: '31'
  - condition: state
    entity_id: switch.pool_heater
    state: 'off'
  action:
  - service: notify.notify
    data:
      message: Heater Pump On
      title: Heater Pump On
  - 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: '1644384944967'
  alias: Heater Pump Off
  description: ''
  trigger:
  - platform: time
    at: '21:00:00'
  - platform: numeric_state
    entity_id: sensor.pool_status
    attribute: temperature
    above: '31'
  - platform: numeric_state
    entity_id: sensor.durst_home_general_price
    above: '0.16'
  condition:
  - condition: state
    entity_id: switch.pool_channel4
    state: 'On'
  action:
  - service: notify.notify
    data:
      message: Heater Pump Off
      title: Heater Pump Off
  mode: single

so small problem…it seems that about once every 3hours the the Rest call fails/returns no value and I get the following warning

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

and error on the entity that is the pool heater pump

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'

Result is that the Temperature Entity triggers the automation. I guess because the error current, in the conditions it believes the pump is off - when it is in fact on. Which results in the the action running and turning off the pump I want to remain on.

The Action is a Rest Command that is the same action_code to turn off as on. If it is off it turns it on and iff it is on it turns it off…that is why i have the condition to check it’s current status.

what could i do to delay between trigger and condition check? or ignore when this error occurs? I don’t think there is anything I can do to stop the error…just something that occasionally happens

In your template, change the int for int(0) so it defaults to 0 if no other value is available, replacing the zero with another number if needed.

1 Like