Control of water circulation pump

Hi,

I am very new to Home Assistant and just started with a few actions in HA.
Sometimes little rocky, but I’ll come along :slight_smile:

Following challenge:
I want to limit the runtime of a water circulation pump to a minimum.
Currently the pump is controlled by a simple timer-controlled plug, which let the pump run at certain times for about 15 min.
However, even with this limited runtime, the (relative small) water boiler looses too much temperature.
Furthermore, the house isn’t occupied all times, then the pump can be disabled completly.

So idea was the following:
Switch the circulation pump with a Shelly Plug, combined in an automation task where the pump is only turned on when people at home, (i.e. certain Smartphones are logged in WiFi) and at several time slots. Will a configuration like this be possible in Home Assistant?
What devices would you propose, is a Shelly plug good for this kind of task?
Any help / links appreciated, didn’t find something similar.

Thanks,
MaxMM

Any smart plug will do, wifi or zigbee

The “configuration” is done in the /Settings/automation-section

Here is what I use…

I create a group of all of the relevant motion sensors:

group:
  wh_recirc_motion:
    name: Water Heater Recirc Motion Sensors
    icon: mdi:walk
    entities:
      - binary_sensor.computer_room_camera_motion
      - binary_sensor.livingroom_camera_motion
      - binary_sensor.kitchen_camera_motion
      - binary_sensor.diningroom_camera_motion
      - binary_sensor.upper_hall_camera_motion
      
      - binary_sensor.main_hallway_motion
      - binary_sensor.kitchen_door_motion
      - binary_sensor.computer_room_motion_sensor
      - binary_sensor.upper_hall_motion
      
      - binary_sensor.computer_room_camera_motion_bi
      - binary_sensor.diningroom_camera_motion_bi
      - binary_sensor.kitchen_camera_motion_bi
      - binary_sensor.livingroom_camera_motion_bi
      - binary_sensor.upper_hall_camera_motion_bi

and a binary sensor to let me know that everyone is either not home or in bed:

binary_sensor:
  - platform: template
    sensors:
      wh_everyone_in_bed:
        friendly_name: Everyone Home is in Bed
        value_template: >
          {% set wife_in_bed = is_state('person.wife', 'home') and (is_state('binary_sensor.left_is_in_spare_bed', 'on') or is_state('binary_sensor.right_is_in_spare_bed', 'on')) %}
          {% set me_in_bed = is_state('person.me', 'home') and (is_state('binary_sensor.me_is_in_master_bed', 'on') or is_state('binary_sensor.wife_is_in_master_bed', 'on')) %}
          {% set wife_not_home = not is_state('person.wife', 'home') %}
          {% set me_not_home = not is_state('person.me', 'home') %}
          {{ (wife_in_bed  or wife_not_home) and (me_in_bed or me_not_home) }}

then I use the following automations to control the pump:

- alias: WH Recirc Pump Timed Control
    id: wh_recirc_pump_timed_control
    mode: restart
    trigger:
      - platform: state
        entity_id: group.wh_recirc_motion
        to: 'on'
    condition:
      - condition: state
        entity_id: binary_sensor.wh_everyone_in_bed
        state: 'off'
      - condition: numeric_state
        entity_id: zone.home
        above: 0
    action:
      - service: switch.turn_on
        entity_id: switch.water_heater_recirc_pump
      - delay: '00:05:00'
      - service: switch.turn_off
        entity_id: switch.water_heater_recirc_pump
        
  - alias: WH Recirc Pump Off
    id: wh_recirc_pump_off
    trigger:
      - platform: state
        entity_id: group.wh_recirc_motion
        to: 'off'
        for:
          minutes: 5
      - platform: state
        entity_id: binary_sensor.wh_everyone_in_bed
        to: 'on'
        for:
          minutes: 5
      - platform: time
        at: '23:00:00'
      - platform: state
        entity_id: zone.home
        to: '0'
    condition:
      - condition: state
        entity_id: switch.water_heater_recirc_pump
        state: 'on'
      - condition: state
        entity_id: group.wh_recirc_motion
        state: 'off'
    action:
      - service: switch.turn_off
        entity_id: switch.water_heater_recirc_pump
2 Likes

That is Cool ! :wink: , i could rethink my “half automatic Shunt” using that, controlling the circulation in a “Combo”

1 Like

Ok, so I am going to order one of these, thanks.

Thank you very much for sharing the code!
It will be a good starting point, I’ll come back once I have fully reviewed (and hopefully understand it) and get it to work.
Only one question: You don’t have sensors in your bed, don’t you?
Cheers,
Markus

actually yes I have sensors for the bed.

they are DIY sensors and made using info from this thread here

After long time of fiddling, reading in different posts and try and error, I finally got it working. I wasn’t able to get the automation working when putting the code direct into automation.yaml, instead I did this with automation in UI, the created automation works now almost like desired.
This is the code extracted from the UI:

alias: Zirkulation
description: ""
trigger:
  - platform: numeric_state
    entity_id: zone.home
    for:
      hours: 0
      minutes: 0
      seconds: 10
    above: 0
condition:
  - condition: time
    after: "06:30:00"
    before: "23:00:00"
    weekday:
      - fri
      - thu
      - wed
      - tue
      - mon
      - sat
      - sun
action:
  - repeat:
      sequence:
        - type: turn_on
          device_id: 07c735da82c1649cfddb3c70d3a4e94c
          entity_id: 6e9d838d7f60b1c2f26bf70c48944dae
          domain: switch
        - delay:
            hours: 0
            minutes: 1
            seconds: 0
            milliseconds: 0
        - type: turn_off
          device_id: 07c735da82c1649cfddb3c70d3a4e94c
          entity_id: 6e9d838d7f60b1c2f26bf70c48944dae
          domain: switch
        - delay:
            hours: 0
            minutes: 15
            seconds: 0
            milliseconds: 0
      until:
        - condition: state
          entity_id: zone.home
          state: "0"
          for:
            hours: 0
            minutes: 5
            seconds: 0
mode: single

I really got stuck with the mode of the automation (single, not restart) and the repeat step inside the automation to get it running continously.
The Shelly configuration as the actor for the pump was the far simplest part of all. I additionally added the OpenWRT integration to discover the smartphones in the homezone (local polling). So for now I am happy with this.

Thanks for your replies.

So you just turn on the circ pump for 1 minute every 15 minutes? Isn’t it better to always keep it on when someone’s home?

Also, what if you go home between 23:00 and 6:30, then the pump will not turn on at all?

I don’t want to hijack your topic, so just the info here, I want to design a complete spa control, which I posted in a separate topic:

Maybe you guy can help.
Thanks.