Pool Pump control

Hi everyone, I’m new to this community.

I have a problem that I can’t solve.

I would like to activate the pool pump for a certain number of hours which vary according to the water temperature.

The formula is water temperature / 2 = number of hours of operation.
ES Temperature 30° / 2 = 15 hours of operation

I have a Sonoff TH Origin/elite that measures water temperature and a Shelly pro 1 PM that controls the pump.

In your opinion, is it possible to create the control procedure with Home Assistant? Thank you!

1 Like

What is the temperature sensor entity id and what time do you want the pump to start?

Hi, the sensor id is sensor.ewelink_smart_home_temp and the pump start at 8.00 am

Here’s one way to do it:

On automation:

trigger:
  - platform: time
    at: '08:00:00'
action:
  - service: input_number.set_value
    target:
      entity_id: input_number.pool_pump_duration_hours
    data:
      value: "{{ (states('sensor.ewelink_smart_home_temp')|float(1) / 2)|round(0)|int }}"
  - service: switch.turn_on
    target:
      entity_id: switch.pool_pump

Off automation:

trigger:
  - platform: state
    entity_id: switch.pool_pump
    to: 'on'
    for:
      hours: "{{ states('input_number.pool_pump_duration_hours')|int }}"
action:
  - service: switch.turn_off
    target:
      entity_id: switch.pool_pump

You would of course have to create the input number. Also change the number 1 in float(1) to the default run time (in hours) you want if the temperature sensor is unavailable.

Another way to do this would be to start a timer after turning the pump on and setting its duration to the temperature times 1800 to give the duration in seconds.

The off automation would then trigger on the timer finishing event.

This is probably a better way to do it as timers do survive restarts. Don’t forget to create the timer.

On automation

trigger:
  - platform: time
    at: '08:00:00'
action:
  - service: timer.start
    target:
      entity_id: timer.pool_pump_duration
    data:
      duration: "{{ (1800 * states('sensor.ewelink_smart_home_temp')|float(1) )|round(0)|int }}"
  - service: switch.turn_on
    target:
      entity_id: switch.pool_pump

Off automation:

trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.pool_pump_duration
action:
  - service: switch.turn_off
    target:
      entity_id: switch.pool_pump

many many thanks!!! I try