Help with pool automation / temperature difference

Hi,

I want to start my pool pump based on the temperature difference between the pool water temperature and the temperature on the roof where a solar heating is installed. I use a Shelly 1 + Addon and Temperature sensors to obtain the temperatures. This works well.

Second, I made an entity for the temperature difference in my templates.yaml


      temperature_difference:
        friendly_name: "Temperaturdifferenz Pool"
        unit_of_measurement: '°C'
        value_template: >
          {{ states('sensor.temperatursensor_pool_temperature')|float - states('sensor.temperatursensor_pool_temperature_2')|float }}

This also works well.

Then I made an automation:

alias: Poolpumpe einschalten
description: Poolpumpe einschalten
trigger:
  - platform: numeric_state
    entity_id: sensor.temperature_difference
    above: 3
condition:
  - condition: sun
    before: sunset
    after: sunrise
action:
  - type: turn_on
    device_id: xyz
    entity_id: switch.pool
    domain: switch
mode: single

So, I want to turn on the pump when the temperature on the roof is >3°C and it’s daytime.

Two problems:

  • Documentation at Automation Trigger - Home Assistant says that it only triggers when the value is crossed. I’d think that this will most likely be sufficient on most days, but sometimes it could be warmer on the roof even before sunrise and then it won’t trigger. How can I depend it on the value instead of crossing the value?

  • The second temperature sensor is on the solar mat itself (I cant change that). When the pool pump is triggered, cold water will float through the solar mat and temperature on that sensor will fall for a short while. Is there a way to ensure that the pump is running for at least x minutes before switching it off through a trigger that switches off the pump when the temp. difference is < specified value?

Thanks for help!

Just add some other triggers and conditions… Something like this:


alias: Poolpumpe einschalten
description: Poolpumpe einschalten
trigger:
  - platform: numeric_state
    entity_id: sensor.temperature_difference
    above: 3
  - platform: sun
    event: sunrise
    offset: 0
  - platform: homeassistant
    event: start
condition:
  - condition: sun
    before: sunset
    after: sunrise
  - condition: numeric_state
    entity_id: sensor.temperature_difference
    above: 3
action:
  - type: turn_on
    device_id: xyz
    entity_id: switch.pool
    domain: switch
mode: single

This will force the system to check for the conditions when sun rises and when Home Assistant starts, but won’t run unless the sun is in the sky (which could be replaced by “above horizon”) and the delta temperature is above 3.

Maybe if you share the automation responsible for stopping the pump will be easier to help, but anyways, you can have a condition for the pump to be on for X number of seconds or, probably better, not trigger that until the temperature difference is below 3 for at least X amount of seconds.
In any case, make sure to add a catch up trigger for the case the pump is on for more than what is a reasonable time.

Thanks a lot!

So I made this automation for switching it off:

alias: Pool ausschalten
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.temperature_difference
    below: 1
condition:
  - condition: device
    type: is_on
    device_id: xxx
    entity_id: switch.pool
    domain: switch
    for:
      hours: 0
      minutes: 10
      seconds: 0
action:
  - type: turn_off
    device_id: xxx
    entity_id: switch.pool
    domain: switch
mode: single

(and I will add one more automation that switches off the pump at sunset no matter what other triggers do).

That should do the trick, I suppose?

I believe so, however you can remove the need for other automation by doing something like this:

alias: Pool ausschalten
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.temperature_difference
    below: 1
    for:
      hours: 0
      minutes: 10
      seconds: 0
  - platform: state
    entity_id:
      - sun.sun
    to: below_horizon
  - platform: state
    entity_id:
      - switch.pool
    to: "on"
    for:
      hours: 6
      minutes: 0
      seconds: 0
condition:
  - condition: state
    entity_id: switch.pool
    state: "on"
action:
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.pool
mode: single

Yes, but that would prevent the pool pump switching off when the weather conditions change (e.g. it’s getting cloudy after a sunny morning and temperatures drop).

If the temperature difference is below 1 for 10min it will turn off the pump. Or at the sunset.
You could even add another trigger for HA starting, so you catch the case where the system is restarting exactly at sunset.
Do you have other triggers for turning it off?

I have 2 triggers:
1 is absolute (shut down pump at sunset), 1 is relative (shutdown when temp diff <1°C and pump is running for at least 10 minutes.) Thanks!