I’m trying to find a way to have my pool drain automatically. The code below works to start the pool draining but the condition inside the action does not work as the condition does not see a state change. Can someone suggest a better way using template that will allow the pump to turn on when the pool level is high (with a customized TTS message) and turn off when the pool level returns to normal (with the new message)?
- alias: 'Pool Pump Auto Drain On'
# If the pool pump and swimming season input booleans are off and the aggregate pool sensor reads 'high', ##
# the pool pump will switch on until the aggregate pool level returns a 'normal' value ##
trigger:
- platform: state
entity_id: sensor.aggregate_pool_level
to: 'High'
condition:
- condition: state
entity_id: switch.pool_pump
state: 'off'
# - condition: state
# entity_id: input_boolean.pool_pump_auto_drain_pool
# state: 'on'
- condition: state
entity_id: input_boolean.swimming_season
state: 'off'
action:
- service: homeassistant.turn_on
entity_id: switch.pool_pump
#- delay: "{{ states('input_number.pump_delay_slider') | multiply(60) | timestamp_custom('%H:%M:%S',False) }}"
# Waits for the pool level sensor to go from High to Normal and the continues with the next action #
- service: script.ghm_tts ## Calls the Google Home app group called media_player.tts_homes
data_template:
tts: "Uh oh. The pool level is too high. I've started to drain it automatically"
volume: 0.5
- condition: state
entity_id: sensor.aggregate_pool_level
state: 'Normal'
- service: homeassistant.turn_off
entity_id: switch.pool_pump
- service: script.ghm_tts ## Calls the Google Home app group called media_player.tts_homes
data_template:
tts: "The pool level has returned to normal. I've switched off the pump"
volume: 0.5