I am very new to Home Assistant and just started with a few actions in HA.
Sometimes little rocky, but I’ll come along
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.
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
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
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:
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.