Count down Timer function?

Hi - is there a simple way to create a count down timer in Home Assistant?

I want to start my pool water feature and then let it stop in 3 hours etc. I dont want to use a permanent schedule - just want to use it when we are outside.

I have installed simple scheduler that works great for devices i want to switch on or off during the same time each day - but I would also like to use a timer.

Thanks

If you have the pool water feature controllable in Home Assistant, you could just have an automation that is triggered when you turn the switch on, then the action could be:-

  action:
  - delay: 03:00:00
  - data: {}
    entity_id: switch.your_switch
    service: switch.turn_off

Thanks - but that means it will always switch off in 3 hours - I want to be able to set a custom time period each time I switch it on in HA app.

You could link the delay to an input_number slider, or something similar and then just pop the related entities on to a card in lovelace.

   action:
     - delay: '00:{{ states('input_number.minutes') | int }}:{{ states('input_number.seconds') | int }}'
     - service: switch.turn_off
       entity_id: switch.something

You can set an input_number to configure the minutes : -

  action: 
    - service: switch.turn_on
      entity_id: switch.my_switch
    - delay: '00:{{ states('input_number.pump_on_minutes') }}:00'
    - service: switch.turn_off
      entity_id: switch.my_switch

Edit: Adam beat me to it !

1 Like

There is a Timer that might be useful. I haven’t looked in to the details.

Hi, this my example of how i use a timer to controll a fan. This way you can change the duration of the timmer from the front end, if you wish.

1) create a inmput number example:

  ha_fan_timmer_min:
    name: "HA fanMin"
    initial: 10
    min: 0
    max: 55
    step: 1
    icon: mdi:timer
  ha_fan_timmer_sec:
    name: "HA fanSec"
    initial: 30
    min: 0
    max: 60
    step: 1
    icon: mdi:timer   
    
2) Automation example:    

  - alias: 'HA temperature fan'
    trigger:
      platform: numeric_state
      entity_id: sensor.ha_temperature
      above: 28
      for:
        minutes: "{{ states('input_number.ha_fan_timmer_min')|int }}"
        seconds: "{{ states('input_number.ha_fan_timmer_sec')|int }}"
        
    condition:
      - condition: state
        entity_id: 'binary_sensor.pfsense_status'
        state: 'on'
    action:
      - service: switch.turn_on
        entity_id: switch.ha_fan
                   
  - alias: 'HA temperature fan off'
    trigger:
      platform: numeric_state
      entity_id: sensor.ha_temperature
      below: 26
      for:
        minutes: "{{ states('input_number.ha_fan_timmer_min')|int }}"
        seconds: "{{ states('input_number.ha_fan_timmer_sec')|int }}"
        
    action:
      - service: switch.turn_off
        entity_id:
          - switch.ha_fan
1 Like